From 4f1a3924b320f0dca319cc621de57f26828119d8 Mon Sep 17 00:00:00 2001 From: Dan Church Date: Thu, 29 Jun 2023 15:07:57 -0500 Subject: [PATCH] When using ccache, don't override the user's choice If a user sets CMAKE_C_COMPILER_LAUNCHER or CMAKE_CXX_COMPILER_LAUNCHER, don't override it; it could be wrong. --- cmake/SimutransCompileOptions.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmake/SimutransCompileOptions.cmake b/cmake/SimutransCompileOptions.cmake index 4f47327cb70..96f091dfcf9 100644 --- a/cmake/SimutransCompileOptions.cmake +++ b/cmake/SimutransCompileOptions.cmake @@ -5,8 +5,14 @@ if (CCache_FOUND) option(SIMUTRANS_USE_CCACHE "Use CCache compiler cache to improve recompilation speed" ON) if (SIMUTRANS_USE_CCACHE) - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCache_EXECUTABLE}") - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCache_EXECUTABLE}") + if (NOT CMAKE_C_COMPILER_LAUNCHER) + message(STATUS "Using ccache for C compilation: ${CCache_EXECUTABLE}") + set(CMAKE_C_COMPILER_LAUNCHER ${CCache_EXECUTABLE}) + endif () + if (NOT CMAKE_CXX_COMPILER_LAUNCHER) + message(STATUS "Using ccache for C++ compilation: ${CCache_EXECUTABLE}") + set(CMAKE_CXX_COMPILER_LAUNCHER ${CCache_EXECUTABLE}) + endif () endif (SIMUTRANS_USE_CCACHE) endif (CCache_FOUND)