aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/Qt6QmlBuildInternals.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2023-07-10 17:34:19 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2023-08-04 16:06:13 +0200
commit7d01e7ef8750aceffe22a05b3b222b88f0e26dbd (patch)
treec78c17500a87841475aec47b653a3327d86b1838 /src/qml/Qt6QmlBuildInternals.cmake
parent2cf9aeccddbd06a66df94bd27916714c4a5c7e24 (diff)
CMake: Duplicate backing library metatypes to its associated plugin
qmltyperegistar and other tooling expect a list of foreign metatypes derived from the full set of dependencies of the target it's processing. If a target was linking to a qml plugin, and not its backing library, the metatypes of the backing library were not passed to the tooling. The mechanism by which the metatypes are collected is via CMake's INTERFACE_SOURCES, and because the qml plugin links PRIVATEly to its backing library, in the chain app <- plugin <- backing lib the backing lib's interface sources were not passed to app. To work around this, use new qtbase api to duplicate the metatypes of the backing library to its associated qml plugin's INTERFACE_SOURCES, thus avoiding the issue. This is the best we can do given the CMake limitation of not being able to transitively propagate values of any custom property and without relying on finalizers. See https://gitlab.kitware.com/cmake/cmake/-/issues/20416 Fixes: QTBUG-115152 Change-Id: I8a1652a9b12bad01abce38bb6f381949eaa1feab Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'src/qml/Qt6QmlBuildInternals.cmake')
-rw-r--r--src/qml/Qt6QmlBuildInternals.cmake19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/qml/Qt6QmlBuildInternals.cmake b/src/qml/Qt6QmlBuildInternals.cmake
index 915c71de6c..03db29b8db 100644
--- a/src/qml/Qt6QmlBuildInternals.cmake
+++ b/src/qml/Qt6QmlBuildInternals.cmake
@@ -391,6 +391,25 @@ function(qt_internal_add_qml_module target)
FILES ${arg_OUTPUT_DIRECTORY}/$<TARGET_PROPERTY:${target},QT_QML_MODULE_TYPEINFO>
DESTINATION "${arg_INSTALL_DIRECTORY}"
)
+
+ # Assign the install time metatypes file of the backing library to the plugin.
+ # Only do it if the backing library is different from the plugin and we do generate
+ # qml types.
+ # The install time metatypes only apply to Qt's own qml plugins, not to user project
+ # qml plugins.
+ if(arg_PLUGIN_TARGET AND
+ TARGET "${arg_PLUGIN_TARGET}" AND NOT target STREQUAL arg_PLUGIN_TARGET)
+ _qt_internal_get_metatypes_install_dir(
+ ""
+ "${INSTALL_ARCHDATADIR}"
+ install_dir
+ )
+
+ _qt_internal_assign_install_metatypes_files_and_properties(
+ "${arg_PLUGIN_TARGET}"
+ INSTALL_DIR "${install_dir}"
+ )
+ endif()
endif()
if(NOT arg_NO_GENERATE_QMLDIR)