CMake: make ccache + pch + clang build more robust

The ccache man page says we have to compile with -fno-pch-timestamp when
using clang and precompiled headers.

"Professional CMake" also recommends this approach, and the ccache
statistics report a marginally better hit rate with this patch.

Task-number: QTBUG-131650
Change-Id: Ic1c17a3977771673ac256674143dbdf8d5ffa28c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Joerg Bornemann 2025-04-06 17:50:08 +02:00
parent 7b66c906bf
commit 86c250d98f

View File

@ -381,6 +381,15 @@ if(QT_FEATURE_stdlib_libcpp)
target_compile_definitions(PlatformCommonInternal INTERFACE _LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
endif()
if(QT_USE_CCACHE AND CLANG AND BUILD_WITH_PCH)
# The ccache man page says we must compile with -fno-pch-timestamp when using clang and pch.
foreach(language IN ITEMS C CXX OBJC OBJCXX)
target_compile_options(PlatformCommonInternal INTERFACE
"$<$<COMPILE_LANGUAGE:${language}>:SHELL:-Xclang -fno-pch-timestamp>"
)
endforeach()
endif()
# Hardening options
qt_internal_apply_intel_cet_harderning(PlatformCommonInternal)