From: Kefu Chai Date: Sat, 25 Jun 2022 14:27:02 +0000 (+0800) Subject: cmake: use CMAKE__COMPILER_LAUNCHER for configuring ccache X-Git-Tag: v18.0.0~616^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e56e85b8912088f175021b9b7c7cc209fd75f2ba;p=ceph.git cmake: use CMAKE__COMPILER_LAUNCHER for configuring ccache ccache only works for c and c++, so instead of using the universal `RULE_LAUNCH_COMPILE` use `CMAKE__COMPILER_LAUNCHER` instead, so ccache is only configured for c and c++ compilation. this is a better solution for integrating ccache into our building system. Signed-off-by: Kefu Chai --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b58137d1485f..c0870323a9434 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,16 +60,17 @@ endif() option(WITH_CCACHE "Build with ccache.") if(WITH_CCACHE) - find_program(CCACHE_EXECUTABLE ccache) - if(NOT CCACHE_EXECUTABLE) - message(FATAL_ERROR "Can't find ccache. Is it installed?") + if(CMAKE_C_COMPILER_LAUNCHER OR CMAKE_CXX_COMPILER_LAUNCHER) + message(WARNING "Compiler launcher already set. stop configuring ccache") + else() + find_program(CCACHE_EXECUTABLE ccache) + if(NOT CCACHE_EXECUTABLE) + message(FATAL_ERROR "Can't find ccache. Is it installed?") + endif() + message(STATUS "Building with ccache: ${CCACHE_EXECUTABLE}, CCACHE_DIR=$ENV{CCACHE_DIR}") + set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE}) + set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE}) endif() - message(STATUS "Building with ccache: ${CCACHE_EXECUTABLE}, CCACHE_DIR=$ENV{CCACHE_DIR}") - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_EXECUTABLE}") - # ccache does not accelerate link (ld), but let it handle it. by passing it - # along with cc to python's distutils, we are able to workaround - # https://bugs.python.org/issue8027. - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_EXECUTABLE}") endif(WITH_CCACHE) option(WITH_MANPAGE "Build man pages." ON)