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 Qt6<Foo>ExtraProperties.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 461020a86a
Amends b56dc55c3a

Pick-to: 6.8 6.9 6.10
Task-number: QTBUG-139986
Change-Id: I80a13aed2027b55a3b5b9a8f6b5757454d73bc61
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Alexandru Croitor 2025-09-08 11:27:31 +02:00
parent 3f853f79a6
commit e6984bc55b
1 changed files with 25 additions and 1 deletions

View File

@ -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 Qt6<Foo>ExtraProperties.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)