-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathccache.cmake
46 lines (35 loc) · 1.68 KB
/
ccache.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#
# Copyright (C) 2018-2025 QuasarApp.
# Distributed under the MIT software license, see the accompanying
# Everyone is permitted to copy and distribute verbatim copies
# of this license document, but changing it is not allowed.
#
# This module adds support of the ccache.
# If you include this cmake file in the main cmakList file then your project will be use the ccace on to the compilator
if(DEFINED CCACHE_SUPPORT)
return()
else()
set(CCACHE_SUPPORT 1)
endif()
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
message("using ccache in ${CCACHE_PROGRAM}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_PROGRAM}") # Less useful to do it for linking, see edit2
if(CMAKE_GENERATOR STREQUAL "Xcode")
set(CC_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/ccahe_cc_launcher.sh)
set(CXX_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/ccahe_cxx_launcher.sh)
configure_file("${CC_LAUNCHER}.in" "${CC_LAUNCHER}")
configure_file("${CXX_LAUNCHER}.in" "${CXX_LAUNCHER}")
execute_process(COMMAND chmod +x
"${CC_LAUNCHER}"
"${CXX_LAUNCHER}"
)
# Set Xcode project attributes to route compilation and linking
# through our scripts
set(CMAKE_XCODE_ATTRIBUTE_CC ${CC_LAUNCHER} CACHE INTERNAL "override CMAKE_XCODE_ATTRIBUTE_CC" )
set(CMAKE_XCODE_ATTRIBUTE_CXX ${CXX_LAUNCHER} CACHE INTERNAL "override CMAKE_XCODE_ATTRIBUTE_CC")
message("CMAKE_XCODE_ATTRIBUTE_CC = ${CMAKE_XCODE_ATTRIBUTE_CC}")
message("CMAKE_XCODE_ATTRIBUTE_CXX = ${CMAKE_XCODE_ATTRIBUTE_CXX}")
endif()
endif()