diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-08-10 11:50:39 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-08-13 14:02:32 +0200 |
commit | 7e94cf8296859ea72a7caaf1a454fe6767fce450 (patch) | |
tree | 657569f12a48a3a1c414b9dda2f307a8b2821fcd /src/qml/CMakeLists.txt | |
parent | 9a79791e7975de811102f89686a5d631eeac9d16 (diff) |
CMake: Initial work on handling Qt Qml static plugins
In Qt 5 we added a QmlImportScanner package that provided a
qt5_import_qml_plugins() function. Calling it with a target ensured
running qmlimportscanner to find and link necessary qml static plugins
for an application to work.
This is the initial port of that to Qt 6, with a few differences.
It introduces 2 function names, the version-less one and qt6_ prefixed
one, qt_import_qml_plugins and qt6_import_qml_plugins.
Implementation notes.
In Qt 5 we figured out what link flags to pass by parsing the plugin
prl files.
In Qt 6, CMake can generate appropriate plugin targets with
dependencies, as well as Config files that can look for the dependent
packages. Use that information for finding the dependencies and linking.
Note this relies on the assumption that find_package(Qt6Qml) will already
include all available Qml plugin Config files, so that the
targets exist in scope by the time qt_import_qml_plugins is called and
links against those targets.
The automatic inclusion is handled by a change in qtbase.
In Qt 5 the function was available as part of QmlImportScanner
package. In Qt 6 the function is moved to QmlMacros, so it's enough to
find_package(Qt6Qml) to use it.
A dummy QmlImportScanner package is provided for backwards
compatibility, that simply finds the Qml package.
Another change is to make the resource name added by
qt6_target_qml_files unique (include the target name), because
qmlcachegen generates a cpp file with a static initializer function
name that includes the resource name. This caused duplicate symbol
errors when linking more than one qtquickcontrols2 style plugin into
an application when the resource name was not unique.
There are a couple of TODOs left:
- Figure out if it's possible to automatically call
qt_import_qml_plugins for applications that link against Qml.
Perhaps using our hacky scope finalizers.
- Figure out how to handle scanning of resources.
Task-number: QTBUG-85961
Task-number: QTBUG-85994
Change-Id: I42f61e4acc6f74a3cdc030dba9e41ce789bc28f6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/qml/CMakeLists.txt')
-rw-r--r-- | src/qml/CMakeLists.txt | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/qml/CMakeLists.txt b/src/qml/CMakeLists.txt index 461b2b8d7c..65f59e0247 100644 --- a/src/qml/CMakeLists.txt +++ b/src/qml/CMakeLists.txt @@ -658,3 +658,14 @@ set_target_properties(Qml PROPERTIES qt6_qml_type_registration(Qml) include(Qt6QmlBuildInternals.cmake) # special case + +# special case begin +# Install Qml import scanner template cpp file. +set(target "Qml") +set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target}") +qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${path_suffix}) +qt_copy_or_install(FILES + "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}ImportScannerTemplate.cpp.in" + DESTINATION "${config_install_dir}" +) +# special case end |