CMake: Set the correct variables for ccache.

As the RULE_LAUNCH_COMPILE documentation says,

"Note: This property is intended for internal use by ctest(1). Projects
and developers should use the <LANG>_COMPILER_LAUNCHER target properties
or the associated CMAKE_<LANG>_COMPILER_LAUNCHER variables instead."
This commit is contained in:
Gerald Combs 2022-07-25 14:01:41 -07:00
parent b093b6a992
commit 3307397da1
1 changed files with 4 additions and 3 deletions

View File

@ -1492,11 +1492,12 @@ if(ENABLE_CCACHE)
message(WARNING "Ccache is enabled, but your compiler is ${CMAKE_C_COMPILER_ID}."
" We wish you the best of luck.")
endif()
# https://stackoverflow.com/questions/1815688/how-to-use-ccache-with-cmake/24305849#24305849
find_program(CCACHE_EXECUTABLE ccache)
if(CCACHE_EXECUTABLE)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_EXECUTABLE}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_EXECUTABLE}")
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}")
set(CMAKE_C_LINKER_LAUNCHER "${CCACHE_EXECUTABLE}")
set(CMAKE_CXX_LINKER_LAUNCHER "${CCACHE_EXECUTABLE}")
endif()
endif()