From 2a3a99fe44d18e3560a4b7a05c230a59335da401 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 19 Oct 2020 19:50:25 +0200 Subject: [PATCH] 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 --- cmake/QtHeadersClean.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmake/QtHeadersClean.cmake b/cmake/QtHeadersClean.cmake index 0b2debdd79a..cabffcd6e74 100644 --- a/cmake/QtHeadersClean.cmake +++ b/cmake/QtHeadersClean.cmake @@ -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}"