CMake: Use compiler launcher for headerclean rules

This ensures ccache or sccache is used to cache the compilation of the
headerclean checks.

Task-number: QTBUG-82615
Change-Id: Ie944eb1d643e7271551c9f8337609741e419e9d8
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Alexandru Croitor 2020-10-19 19:50:25 +02:00
parent 7c23281db3
commit 2a3a99fe44

View File

@ -32,6 +32,12 @@ function(qt_internal_add_headers_clean_target
-DQT_USE_QSTRINGBUILDER
-DQT_USE_FAST_OPERATOR_PLUS)
set(compiler_to_run "${CMAKE_CXX_COMPILER}")
if(CMAKE_CXX_COMPILER_LAUNCHER)
list(PREPEND compiler_to_run "${CMAKE_CXX_COMPILER_LAUNCHER}")
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"
OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"
OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
@ -96,7 +102,7 @@ function(qt_internal_add_headers_clean_target
add_custom_command(
OUTPUT "${artifact_path}"
COMMENT "headersclean: Checking header ${header}"
COMMAND "${CMAKE_CXX_COMPILER}" -c ${cxx_flags} ${hcleanFLAGS}
COMMAND ${compiler_to_run} -c ${cxx_flags} ${hcleanFLAGS}
-I "${QT_BUILD_DIR}/include" -I "${CMAKE_INSTALL_PREFIX}/include"
${hcleanDEFS} -xc++ "${input_path}"
-o${artifact_path}
@ -121,7 +127,7 @@ function(qt_internal_add_headers_clean_target
add_custom_command(
OUTPUT "${artifact_path}"
COMMENT "headersclean: Checking header ${header}"
COMMAND "${CMAKE_CXX_COMPILER}" -nologo -c ${CMAKE_CXX_FLAGS} ${hcleanFLAGS}
COMMAND ${compiler_to_run} -nologo -c ${CMAKE_CXX_FLAGS} ${hcleanFLAGS}
-I "${QT_BUILD_DIR}/include" -I "${CMAKE_INSTALL_PREFIX}/include"
${hcleanDEFS} -FI "${input_path}"
-Fo${artifact_path} "${source_path}"