build: switch from RULE_LAUNCH_COMPILE to CXX_COMPILER_LAUNCHER

This commit is contained in:
Gabriel Ferreira
2022-12-23 20:08:16 -03:00
parent e3b8bc49b5
commit c4ba542e7a
3 changed files with 19 additions and 7 deletions

View File

@@ -106,7 +106,7 @@ if(${NS3_CCACHE})
find_program(CCACHE ccache)
if(NOT ("${CCACHE}" STREQUAL "CCACHE-NOTFOUND"))
message(STATUS "CCache is enabled.")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE})
execute_process(
COMMAND
${CCACHE} --set-config

View File

@@ -71,25 +71,25 @@ if(${NS3_COLORED_OUTPUT} OR "$ENV{CLICOLOR}")
# Replace the default message macro with a custom colored one
function(message)
list(GET ARGV 0 MessageType)
list(REMOVE_AT ARGV 0)
# Transform list of arguments into a single line.
string(REPLACE ";" " " ARGV "${ARGV}")
if((${MessageType} STREQUAL FATAL_ERROR) OR (${MessageType} STREQUAL
SEND_ERROR)
)
list(REMOVE_AT ARGV 0)
_message(${MessageType} "${BoldRed}${ARGV}${ColourReset}")
elseif(MessageType STREQUAL WARNING)
list(REMOVE_AT ARGV 0)
_message(${MessageType} "${Yellow}${ARGV}${ColourReset}")
elseif(MessageType STREQUAL AUTHOR_WARNING)
list(REMOVE_AT ARGV 0)
_message(${MessageType} "${BoldCyan}${ARGV}${ColourReset}")
elseif(MessageType STREQUAL HIGHLIGHTED_STATUS) # Custom message type
list(REMOVE_AT ARGV 0)
_message(STATUS "${Yellow}${ARGV}${ColourReset}")
elseif(MessageType STREQUAL STATUS)
list(REMOVE_AT ARGV 0)
_message(${MessageType} "${ARGV}")
else()
_message(${ARGV})
_message(${MessageType} "${ARGV}")
endif()
endfunction()
endif()

View File

@@ -478,6 +478,18 @@ macro(process_options)
if("${CLANG_TIDY}" STREQUAL "CLANG_TIDY-NOTFOUND")
message(FATAL_ERROR "Clang-tidy was not found")
else()
if((${CMAKE_VERSION} VERSION_LESS "3.12.0") AND ${NS3_CCACHE}
AND (NOT ("${CCACHE}" STREQUAL "CCACHE-NOTFOUND"))
)
# CMake <3.12 puts CMAKE_CXX_COMPILER_LAUNCHER in the incorrect place
# and CCache ends up being unable to cache anything if calling
# clang-tidy https://gitlab.kitware.com/cmake/cmake/-/issues/18266
message(
FATAL_ERROR
"The current CMake ${CMAKE_VERSION} won't ccache objects correctly when running with clang-tidy."
"Update CMake to at least version 3.12, or disable either ccache or clang-tidy to continue."
)
endif()
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY}")
endif()
else()