]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
build: Set both C/CXX launchers if either is set (#1343)
authorRafael Kitover <rkitover@gmail.com>
Sat, 16 Dec 2023 15:19:33 +0000 (07:19 -0800)
committerGitHub <noreply@github.com>
Sat, 16 Dec 2023 15:19:33 +0000 (16:19 +0100)
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 <rkitover@gmail.com>
CMakeLists.txt
cmake/EnableCcache.cmake [new file with mode: 0644]

index dcfc82981cf9c46d13153fee1223e915390d07f3..381d3e724c8bff5fb43a98b03c570fe6e0eeb2b9 100644 (file)
@@ -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 (file)
index 0000000..eba2ced
--- /dev/null
@@ -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()