-
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Cache.cmake
25 lines (22 loc) · 961 Bytes
/
Cache.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
include_guard()
# Enable cache if available
function(enable_cache)
set(CACHE_OPTION "ccache" CACHE STRING "Compiler cache to be used")
set(CACHE_OPTION_VALUES "ccache" "sccache")
set_property(CACHE CACHE_OPTION PROPERTY STRINGS ${CACHE_OPTION_VALUES})
list(FIND CACHE_OPTION_VALUES ${CACHE_OPTION} CACHE_OPTION_INDEX)
if(${CACHE_OPTION_INDEX} EQUAL -1)
message(
STATUS
"Using custom compiler cache system: '${CACHE_OPTION}', explicitly supported entries are ${CACHE_OPTION_VALUES}"
)
endif()
find_program(CACHE_BINARY NAMES ${CACHE_OPTION_VALUES})
if(CACHE_BINARY)
message(STATUS "${CACHE_BINARY} found and enabled")
set(CMAKE_CXX_COMPILER_LAUNCHER ${CACHE_BINARY} CACHE FILEPATH "CXX compiler cache used")
set(CMAKE_C_COMPILER_LAUNCHER ${CACHE_BINARY} CACHE FILEPATH "C compiler cache used")
else()
message(WARNING "${CACHE_OPTION} is enabled but was not found. Not using it")
endif()
endfunction()