Skip to content

Commit

Permalink
[Build][Bugfix] Use CMAKE_ prefix for <LANG>_COMPILER_LAUNCHER (apach…
Browse files Browse the repository at this point in the history
…e#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.
  • Loading branch information
Lunderberg authored and fzi-peccia committed Mar 27, 2023
1 parent 91c8004 commit 47fc772
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions cmake/utils/CCache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
2 changes: 1 addition & 1 deletion cmake/utils/Summary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 47fc772

Please sign in to comment.