Do not rely on transitive includes when using libc++

Libc++ is migrating towards fine-grained headers [1], removing indirect
inclusions. To prevent breakages in client code, this feature is opt-in,
happening when one bumps the C++ version used or defines the
_LIBCPP_REMOVE_TRANSITIVE_INCLUDES macro.
This commit adds the macro when building Qt. I'm pretty confident this
won't cause breakages because we have also been building Qt on the CI in
C++ > 17 modes.

[1] https://libcxx.llvm.org/DesignDocs/HeaderRemovalPolicy.html

Change-Id: I7553274ef51ccc9b462c98fdab55b27e5715afaa
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Giuseppe D'Angelo 2025-01-17 18:15:27 +01:00
parent 34f60877bd
commit ca9200910e

View File

@ -318,6 +318,13 @@ if (GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "9.2")
target_compile_options(PlatformCommonInternal INTERFACE $<$<COMPILE_LANGUAGE:CXX>:-Wsuggest-override>)
endif()
if(QT_FEATURE_stdlib_libcpp)
# Disable transitive C++ inclusions when using libc++, on all
# language versions. See
# https://libcxx.llvm.org/DesignDocs/HeaderRemovalPolicy.html
target_compile_definitions(PlatformCommonInternal INTERFACE _LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
endif()
# Hardening options
qt_internal_apply_intel_cet_harderning(PlatformCommonInternal)