From: Rafael Kitover Date: Sat, 16 Dec 2023 15:19:33 +0000 (-0800) Subject: build: Set both C/CXX launchers if either is set (#1343) X-Git-Tag: v4.9~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95e58aafdc21dab7a9cb97f427cb10b945f56c83;p=thirdparty%2Fccache.git build: Set both C/CXX launchers if either is set (#1343) Add cmake/EnableCcache.cmake and load it from the main file. Make the standard cmake variables CMAKE_CXX_COMPILER_LAUNCHER and CMAKE_C_COMPILER_LAUNCHER consistent with each other if either is not set. Signed-off-by: Rafael Kitover --- diff --git a/CMakeLists.txt b/CMakeLists.txt index dcfc82981..381d3e724 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,7 @@ include(UseFastestLinker) include(StaticLinkSupport) include(StandardSettings) include(StandardWarnings) +include(EnableCcache) # # Configuration diff --git a/cmake/EnableCcache.cmake b/cmake/EnableCcache.cmake new file mode 100644 index 000000000..eba2ced52 --- /dev/null +++ b/cmake/EnableCcache.cmake @@ -0,0 +1,12 @@ +# Make the CMAKE_CXX_COMPILER_LAUNCHER and CMAKE_C_COMPILER_LAUNCHER variables +# consistent if either is not set. + +if(CMAKE_CXX_COMPILER_LAUNCHER AND CMAKE_C_COMPILER_LAUNCHER) + return() +endif() + +if(CMAKE_CXX_COMPILER_LAUNCHER AND NOT CMAKE_C_COMPILER_LAUNCHER) + set(CMAKE_C_COMPILER_LAUNCHER ${CMAKE_CXX_COMPILER_LAUNCHER}) +elseif(NOT CMAKE_CXX_COMPILER_LAUNCHER AND CMAKE_C_COMPILER_LAUNCHER) + set(CMAKE_CXX_COMPILER_LAUNCHER ${CMAKE_C_COMPILER_LAUNCHER}) +endif()