From e6984bc55b84278c1eb8813a9bfb5e59fe3781be Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 8 Sep 2025 11:27:31 +0200 Subject: [PATCH] CMake: Export feature properties for INTERFACE libraries as well We didn't use to export them, presumably because CMake doesn't allow us to export INTERFACE_* properties via EXPORT_PROPERTIES. Use our own property export infrastructure to export the properties in the module-specific Qt6ExtraProperties.cmake file. This came up because some of the qtscxml tests are gated by features from the ScxmlGlobalPrivate module, which means the tests were never built, because we never exported the state of the features. Amends 461020a86aa5822325edba9ec565db39e5df8092 Amends b56dc55c3a5c4164ad84fd61c44638a3cb196978 Pick-to: 6.8 6.9 6.10 Task-number: QTBUG-139986 Change-Id: I80a13aed2027b55a3b5b9a8f6b5757454d73bc61 Reviewed-by: Joerg Bornemann Reviewed-by: Ulf Hermann Reviewed-by: Alexey Edelev --- cmake/QtFeature.cmake | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake index 86b1201792d..618bf839bfe 100644 --- a/cmake/QtFeature.cmake +++ b/cmake/QtFeature.cmake @@ -1248,12 +1248,36 @@ function(qt_feature_module_end) if (NOT ("${target}" STREQUAL "NO_MODULE") AND NOT arg_ONLY_EVALUATE_FEATURES) get_target_property(targetType "${target}" TYPE) + + set(properties_to_export + QT_ENABLED_PUBLIC_FEATURES + QT_DISABLED_PUBLIC_FEATURES + QT_ENABLED_PRIVATE_FEATURES + QT_DISABLED_PRIVATE_FEATURES + QT_QMAKE_PUBLIC_CONFIG + QT_QMAKE_PRIVATE_CONFIG + QT_QMAKE_PUBLIC_QT_CONFIG + + ) if("${targetType}" STREQUAL "INTERFACE_LIBRARY") set(propertyPrefix "INTERFACE_") + list(TRANSFORM properties_to_export PREPEND "${propertyPrefix}") + # CMake doesn't allow us to export INTERFACE_* properties via EXPORT_PROPERTIES, it + # says INTERFACE_* properties are reserved. + # Instead, use our own property export infrastructure that places the values in the + # module-specific Qt6ExtraProperties.cmake file. + # qt_internal_add_genex_properties_export was originally intended for properties with + # genexes, but we can use it for this use case as well. + # Before, we didn't use to export the properties at all for INTERFACE_ libraries, + # but we need to, because certain GlobalPrivate modules have features which are used + # in configure-time conditions for tests. + qt_internal_add_genex_properties_export("${target}" ${properties_to_export}) else() set(propertyPrefix "") - set_property(TARGET "${target}" APPEND PROPERTY EXPORT_PROPERTIES "QT_ENABLED_PUBLIC_FEATURES;QT_DISABLED_PUBLIC_FEATURES;QT_ENABLED_PRIVATE_FEATURES;QT_DISABLED_PRIVATE_FEATURES;QT_QMAKE_PUBLIC_CONFIG;QT_QMAKE_PRIVATE_CONFIG;QT_QMAKE_PUBLIC_QT_CONFIG") + set_property(TARGET "${target}" + APPEND PROPERTY EXPORT_PROPERTIES ${properties_to_export}) endif() + foreach(visibility public private) string(TOUPPER "${visibility}" capitalVisibility) foreach(state enabled disabled)