-
Notifications
You must be signed in to change notification settings - Fork 0
/
EnableCCache.cmake
95 lines (78 loc) · 1.7 KB
/
EnableCCache.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# - Find CCache
# Find the CCache and enables it
#
# CCache_VERSION - CCache executable version.
# CCache_FOUND - True if CCache found.
#
# Include guard
include_guard(GLOBAL)
# Check cached
if (CCache_VERSION)
# Already in cache, be silent
set(
CCache_FIND_QUIETLY
TRUE
)
endif (CCache_VERSION)
# Find ccache executable
find_program(
CCache_CCache_FOUND
ccache
)
# CCache found
if (CCache_CCache_FOUND)
# Get CCache version
execute_process(
COMMAND "${CCache_CCache_FOUND}" --version
OUTPUT_VARIABLE CCache_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# CCache version value
string(
REGEX
MATCH "[0-9]+\.[0-9]+(\.[0-9]+)*"
CCache_VERSION ${CCache_VERSION}
)
# Enable CCache for C
set(
CMAKE_C_COMPILER_LAUNCHER
${CCache_CCache_FOUND}
CACHE FILEPATH "C compiler cached"
)
# Enable CCache for C++
set(
CMAKE_CXX_COMPILER_LAUNCHER
${CCache_CCache_FOUND}
CACHE FILEPATH "CXX compiler cached"
)
# Enable CCache for C (over ENV)
set(
$ENV{CMAKE_C_COMPILER_LAUNCHER}
${CCache_CCache_FOUND}
CACHE FILEPATH "C compiler cached"
)
# Enable CCache for C++ (over ENV)
set(
$ENV{CMAKE_CXX_COMPILER_LAUNCHER}
${CCache_CCache_FOUND}
CACHE FILEPATH "CXX compiler cached"
)
# Fix for MSVC debug prevention of ccache work
set(
CMAKE_MSVC_DEBUG_INFORMATION_FORMAT
"$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>"
)
endif (CCache_CCache_FOUND)
# Handle the QUIETLY and REQUIRED arguments and set CCache_FOUND to TRUE if
# all listed variables are TRUE.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
CCache
REQUIRED_VARS CCache_CCache_FOUND
VERSION_VAR CCache_VERSION
HANDLE_COMPONENTS
)
# Advanced
mark_as_advanced(
CCache_CCache_FOUND
)