Skip to content

Commit 8088dcb

Browse files
authored
[Build][Bugfix] Use CMAKE_ prefix for <LANG>_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 [`<LANG>_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_<LANG>_COMPILER_LAUNCHER`](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_LAUNCHER.html) variables, which are used as the default for the `<LANG>_COMPILER_LAUNCHER` property.
1 parent 231882a commit 8088dcb

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

cmake/utils/CCache.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
# under the License.
1717

1818
if(USE_CCACHE) # True for AUTO, ON, /path/to/ccache
19-
if(DEFINED CXX_COMPILER_LAUNCHER OR DEFINED C_COMPILER_LAUNCHER)
19+
if(DEFINED CMAKE_CXX_COMPILER_LAUNCHER OR DEFINED CMAKE_C_COMPILER_LAUNCHER)
2020
if("${USE_CCACHE}" STREQUAL "AUTO")
21-
message(STATUS "CXX_COMPILER_LAUNCHER or C_COMPILER_LAUNCHER already defined, not using ccache")
21+
message(STATUS "CMAKE_CXX_COMPILER_LAUNCHER or CMAKE_C_COMPILER_LAUNCHER already defined, not using ccache")
2222
elseif("${USE_CCACHE}" MATCHES ${IS_TRUE_PATTERN})
23-
message(FATAL_ERROR "CXX_COMPILER_LAUNCHER or C_COMPILER_LAUNCHER is already defined, refusing to override with ccache. Either unset or disable ccache.")
23+
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.")
2424
endif()
2525
else()
2626
if("${USE_CCACHE}" STREQUAL "AUTO") # Auto mode
@@ -45,8 +45,8 @@ if(USE_CCACHE) # True for AUTO, ON, /path/to/ccache
4545
endif()
4646
# Set the flag for ccache
4747
if(DEFINED PATH_TO_CCACHE)
48-
set(CXX_COMPILER_LAUNCHER "${PATH_TO_CCACHE}")
49-
set(C_COMPILER_LAUNCHER "${PATH_TO_CCACHE}")
48+
set(CMAKE_CXX_COMPILER_LAUNCHER "${PATH_TO_CCACHE}")
49+
set(CMAKE_C_COMPILER_LAUNCHER "${PATH_TO_CCACHE}")
5050
endif()
5151
endif()
5252
endif(USE_CCACHE)

cmake/utils/Summary.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ macro(print_summary)
4242
message(STATUS " C++ compiler ID : ${CMAKE_CXX_COMPILER_ID}")
4343
message(STATUS " C++ compiler version : ${CMAKE_CXX_COMPILER_VERSION}")
4444
message(STATUS " CXX flags : ${CMAKE_CXX_FLAGS}")
45-
message(STATUS " CXX launcher : ${CXX_COMPILER_LAUNCHER}")
45+
message(STATUS " CXX launcher : ${CMAKE_CXX_COMPILER_LAUNCHER}")
4646
message(STATUS " Linker flags : ${CMAKE_SHARED_LINKER_FLAGS}")
4747
message(STATUS " Build type : ${CMAKE_BUILD_TYPE}")
4848
get_directory_property(READABLE_COMPILE_DEFS DIRECTORY ${PROJECT_SOURCE_DIR} COMPILE_DEFINITIONS)

0 commit comments

Comments
 (0)