File tree Expand file tree Collapse file tree 3 files changed +24
-8
lines changed Expand file tree Collapse file tree 3 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ endif()
1818# Link this 'library' to use the warnings specified in CompilerWarnings.cmake
1919add_library (project_warnings INTERFACE )
2020
21+ # enable cache system
22+ include (cmake/Cache .cmake)
23+
2124# standard compiler warnings
2225include (cmake/CompilerWarnings.cmake)
2326set_project_warnings(project_warnings)
Original file line number Diff line number Diff line change 1+ option (ENABLE_CACHE "Enable cache if available" ON )
2+ if (NOT ENABLE_CACHE)
3+ return ()
4+ endif ()
5+
6+ set (CACHE_OPTION "ccache" CACHE STRING "Compiler cache to be used" )
7+ set (CACHE_OPTION_VALUES "ccache" "sccache" )
8+ set_property (CACHE CACHE_OPTION PROPERTY STRINGS ${CACHE_OPTION_VALUES} )
9+ list (FIND CACHE_OPTION_VALUES ${CACHE_OPTION} CACHE_OPTION_INDEX)
10+
11+ if (${CACHE_OPTION_INDEX} EQUAL -1)
12+ message (STATUS "Using custom compiler cache system: '${CACHE_OPTION} ', explicitly supported entries are ${CACHE_OPTION_VALUES} " )
13+ endif ()
14+
15+ find_program (CACHE_BINARY ${CACHE_OPTION} )
16+ if (CACHE_BINARY)
17+ message (STATUS "${CACHE_OPTION} found and enabled" )
18+ set (CMAKE_CXX_COMPILER_LAUNCHER ${CACHE_BINARY} )
19+ else ()
20+ message (WARNING "${CACHE_OPTION} is enabled but was not found. Not using it" )
21+ endif ()
Original file line number Diff line number Diff line change @@ -10,14 +10,6 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
1010 "MinSizeRel" "RelWithDebInfo" )
1111endif ()
1212
13- find_program (CCACHE ccache)
14- if (CCACHE)
15- message ("using ccache" )
16- set (CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE} )
17- else ()
18- message ("ccache not found cannot use" )
19- endif ()
20-
2113# Generate compile_commands.json to make it easier to work with clang based
2214# tools
2315set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
You can’t perform that action at this time.
0 commit comments