From ca9200910ee29663325e3f5930c74a55b2ffe31c Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 17 Jan 2025 18:15:27 +0100 Subject: [PATCH] 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 --- cmake/QtInternalTargets.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmake/QtInternalTargets.cmake b/cmake/QtInternalTargets.cmake index 7f7dc0e02de..87512332de1 100644 --- a/cmake/QtInternalTargets.cmake +++ b/cmake/QtInternalTargets.cmake @@ -318,6 +318,13 @@ if (GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "9.2") target_compile_options(PlatformCommonInternal INTERFACE $<$:-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)