From 47fc772529e88012bffe7a6065c1a6df6bd0ca41 Mon Sep 17 00:00:00 2001 From: Eric Lunderberg Date: Wed, 4 Jan 2023 11:40:54 -0600 Subject: [PATCH] [Build][Bugfix] Use CMAKE_ prefix for _COMPILER_LAUNCHER (#13697) Previously, when using `set(USE_CCACHE AUTO)`, the cmake config would set variables `CXX_COMPILER_LAUNCHER` and `C_COMPILER_LAUNCHER`. While there are the target-specific properties named [`_COMPILER_LAUNCHER`](https://cmake.org/cmake/help/latest/prop_tgt/LANG_COMPILER_LAUNCHER.html), cmake doesn't check for their use as global variables. This commit updates the build file to instead set the [`CMAKE__COMPILER_LAUNCHER`](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_LAUNCHER.html) variables, which are used as the default for the `_COMPILER_LAUNCHER` property. --- cmake/utils/CCache.cmake | 10 +++++----- cmake/utils/Summary.cmake | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmake/utils/CCache.cmake b/cmake/utils/CCache.cmake index f38a36b5dee8..446542b4b0be 100644 --- a/cmake/utils/CCache.cmake +++ b/cmake/utils/CCache.cmake @@ -16,11 +16,11 @@ # under the License. if(USE_CCACHE) # True for AUTO, ON, /path/to/ccache - if(DEFINED CXX_COMPILER_LAUNCHER OR DEFINED C_COMPILER_LAUNCHER) + if(DEFINED CMAKE_CXX_COMPILER_LAUNCHER OR DEFINED CMAKE_C_COMPILER_LAUNCHER) if("${USE_CCACHE}" STREQUAL "AUTO") - message(STATUS "CXX_COMPILER_LAUNCHER or C_COMPILER_LAUNCHER already defined, not using ccache") + message(STATUS "CMAKE_CXX_COMPILER_LAUNCHER or CMAKE_C_COMPILER_LAUNCHER already defined, not using ccache") elseif("${USE_CCACHE}" MATCHES ${IS_TRUE_PATTERN}) - message(FATAL_ERROR "CXX_COMPILER_LAUNCHER or C_COMPILER_LAUNCHER is already defined, refusing to override with ccache. Either unset or disable ccache.") + message(FATAL_ERROR "CMAKE_CXX_COMPILER_LAUNCHER or CMAKE_C_COMPILER_LAUNCHER is already defined, refusing to override with ccache. Either unset or disable ccache.") endif() else() if("${USE_CCACHE}" STREQUAL "AUTO") # Auto mode @@ -45,8 +45,8 @@ if(USE_CCACHE) # True for AUTO, ON, /path/to/ccache endif() # Set the flag for ccache if(DEFINED PATH_TO_CCACHE) - set(CXX_COMPILER_LAUNCHER "${PATH_TO_CCACHE}") - set(C_COMPILER_LAUNCHER "${PATH_TO_CCACHE}") + set(CMAKE_CXX_COMPILER_LAUNCHER "${PATH_TO_CCACHE}") + set(CMAKE_C_COMPILER_LAUNCHER "${PATH_TO_CCACHE}") endif() endif() endif(USE_CCACHE) diff --git a/cmake/utils/Summary.cmake b/cmake/utils/Summary.cmake index e3ea925a9ae1..acb5703f600a 100644 --- a/cmake/utils/Summary.cmake +++ b/cmake/utils/Summary.cmake @@ -42,7 +42,7 @@ macro(print_summary) message(STATUS " C++ compiler ID : ${CMAKE_CXX_COMPILER_ID}") message(STATUS " C++ compiler version : ${CMAKE_CXX_COMPILER_VERSION}") message(STATUS " CXX flags : ${CMAKE_CXX_FLAGS}") - message(STATUS " CXX launcher : ${CXX_COMPILER_LAUNCHER}") + message(STATUS " CXX launcher : ${CMAKE_CXX_COMPILER_LAUNCHER}") message(STATUS " Linker flags : ${CMAKE_SHARED_LINKER_FLAGS}") message(STATUS " Build type : ${CMAKE_BUILD_TYPE}") get_directory_property(READABLE_COMPILE_DEFS DIRECTORY ${PROJECT_SOURCE_DIR} COMPILE_DEFINITIONS)