diff options
author | Craig Scott <craig.scott@qt.io> | 2021-08-16 15:10:38 +1000 |
---|---|---|
committer | Craig Scott <craig.scott@qt.io> | 2021-08-20 09:29:30 +1000 |
commit | a25f650c317e4886007a8beb0e9f2f7e973e6e7c (patch) | |
tree | 575ecdbf3bf260af31eef3c5df4adc45556d789b /src/qml/Qt6QmlBuildInternals.cmake | |
parent | 30e6bb35e48207a994dd4e49ca999d45266a04f5 (diff) |
Allow QML plugin's CMake target name to be specified for qmldir file
The current code assumes that the basename of the QML plugin is the
same as the CMake target it corresponds to. This won't be the case for
installed Qt packages due to the installed name including a namespace.
It also won't match when a Qt library infix is used. The current code
works around the former by trying to heuristically work out whether
a namespaced Qt target exists for the plugin. The Qt library infix is
more problematic because the plugin target name won't include the
infix whereas the plugin library basename will.
Address both of those issues by adding an internal option
INSTALLED_PLUGIN_TARGET to qt6_add_qml_module() which allows the
installed target name to be provided. When included in a qmldir file,
qt6_import_qml_plugin() will use that name, otherwise it will fall
back to using the plugin library's basename, as per the current
behavior. The option may become public in the future, but for now it
is only for Qt's internal use for the 6.2 release.
Fixes: QTBUG-95140
Pick-to: 6.2
Change-Id: I5a057c80b70ee802c0f0840e9eea2e579193d126
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/qml/Qt6QmlBuildInternals.cmake')
-rw-r--r-- | src/qml/Qt6QmlBuildInternals.cmake | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/qml/Qt6QmlBuildInternals.cmake b/src/qml/Qt6QmlBuildInternals.cmake index 3b9e99c782..f979c9f656 100644 --- a/src/qml/Qt6QmlBuildInternals.cmake +++ b/src/qml/Qt6QmlBuildInternals.cmake @@ -197,6 +197,8 @@ function(qt_internal_add_qml_module target) ) endif() + set(add_qml_module_args "") + if(NOT arg_NO_PLUGIN AND NOT arg_NO_CREATE_PLUGIN_TARGET) # If the qt_internal_add_qml_module call didn't specify a CLASS_NAME, we need to pre-compute # it here and pass it along to qt_internal_add_plugin -> qt_add_plugin so that @@ -217,6 +219,28 @@ function(qt_internal_add_qml_module target) qt_internal_add_plugin(${arg_PLUGIN_TARGET} ${plugin_args}) + # Get the last dot-separated part of the URI. There should only be one + # plugin library in the output directory, so we shouldn't need to + # include the full URI namespace. + string(REGEX REPLACE "^(.*\\.)?([^.]+)$" "\\2" plugin_basename "${arg_URI}") + # Add the infix and "plugin", lowercase that and use it as the basename + # of the plugin library. + string(TOLOWER "${plugin_basename}${QT_LIBINFIX}plugin" plugin_basename) + set_target_properties(${arg_PLUGIN_TARGET} PROPERTIES + OUTPUT_NAME "${plugin_basename}" + ) + + get_target_property(export_name ${arg_PLUGIN_TARGET} EXPORT_NAME) + if(export_name) + list(APPEND add_qml_module_args + INSTALLED_PLUGIN_TARGET "${QT_CMAKE_EXPORT_NAMESPACE}::${export_name}" + ) + else() + list(APPEND add_qml_module_args + INSTALLED_PLUGIN_TARGET "${QT_CMAKE_EXPORT_NAMESPACE}::${arg_PLUGIN_TARGET}" + ) + endif() + if(NOT arg_PLUGIN_TARGET STREQUAL target) get_target_property(lib_type ${arg_PLUGIN_TARGET} TYPE) if(lib_type STREQUAL "STATIC_LIBRARY") @@ -254,10 +278,6 @@ function(qt_internal_add_qml_module target) endif() endforeach() - if(QT_LIBINFIX) - list(APPEND add_qml_module_args __QT_INTERNAL_QT_LIBINFIX "${QT_LIBINFIX}") - endif() - # Update the backing and plugin targets with qml-specific things. qt6_add_qml_module(${target} ${add_qml_module_args} |