Skip to content

Commit

Permalink
cache.cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
billyzs committed Jul 10, 2024
1 parent 263ed5f commit 400e18f
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions cmake/Cache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,29 @@ function(enable_cache)
"explicitly supported entries are ${CACHE_OPTION_VALUES}"
)
endif()

find_program(
CACHE_BINARY
NAMES
${CACHE_OPTION_VALUES}
if(IS_EXECUTABLE
${CMAKE_CXX_COMPILER_LAUNCHER}
)
if(CACHE_BINARY)
message(STATUS
"${CACHE_BINARY} found and enabled"
set(CACHE_BINARY
${CMAKE_CXX_COMPILER_LAUNCHER}
)
elseif(
IS_EXECUTABLE
${CMAKE_C_COMPILER_LAUNCHER}
)
set(CACHE_BINARY
${CMAKE_C_COMPILER_LAUNCHER}
)
else()

find_program(
CACHE_BINARY
NAMES
${CACHE_OPTION_VALUES} ${CMAKE_CXX_COMPILER_LAUNCHER}
${CMAKE_C_COMPILER_LAUNCHER}
)
endif()
if(CACHE_BINARY)
set(CMAKE_CXX_COMPILER_LAUNCHER
${CACHE_BINARY}
CACHE
Expand All @@ -52,6 +65,15 @@ function(enable_cache)
CACHE
FILEPATH "C compiler cache used"
)
execute_process(
COMMAND
${CACHE_BINARY} --version
OUTPUT_VARIABLE
cache_cmd_ver
)
message(STATUS
"${CACHE_BINARY} found and enabled; version\n${cache_cmd_ver}"
)
else()
message(WARNING
"${CACHE_OPTION} is enabled but was not found. Not using it"
Expand Down

0 comments on commit 400e18f

Please sign in to comment.