diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-08-10 16:44:13 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-08-12 14:20:40 +0200 |
commit | 81ea5f1906c74527b74c2b7a92396a520ed47f9f (patch) | |
tree | 9ae439fd7348f707f49056cb18792717e61b7a8e /cmake/QtPostProcess.cmake | |
parent | 3e3fdbe831f24365780383b3c45a3d53f23ba435 (diff) |
CMake: Prepare ground work for static Qml plugins importing
For qt_import_qml_plugins to work, it needs to have access to the Qml
plugin targets by the time find_package(Qt6Qml) is called.
To do that, we modify the generation of Qml plugin Config, Targets and
Dependencies files to go into a special 'QmlPlugins' subfolder of the
Qml package.
The Qml package will then GLOB include all the Config files in that
folder, to make them available whenever find_package(Qt6Qml) is
called.
This is similar to how the Qt plugins were glob included in the CMake
integration of Qt 5.15. In fact that glob including is missing in Qt 6
for regular Qt plugins, and should be implemented in a following
change. Currently the Qt Plugins config files that are included are
hardcoded to the list of known plugins at Qt configuration time.
As a drive-by to make this all work, the naming of the various Config
and Dependencies files has been normalized to include the Qt6 prefix.
This is done for both regular Qt plugins and Qml plugins.
Task-number: QTBUG-85961
Change-Id: Id20da72337ca2945fa330ea6fb43535e44a83292
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake/QtPostProcess.cmake')
-rw-r--r-- | cmake/QtPostProcess.cmake | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/cmake/QtPostProcess.cmake b/cmake/QtPostProcess.cmake index 2bc6d7ae3a..02c1905f8b 100644 --- a/cmake/QtPostProcess.cmake +++ b/cmake/QtPostProcess.cmake @@ -210,7 +210,7 @@ function(qt_internal_create_module_depends_file target) endfunction() function(qt_internal_create_plugin_depends_file target) - get_target_property(qt_module "${target}" QT_MODULE) + get_target_property(plugin_install_package_suffix "${target}" _qt_plugin_install_package_suffix) get_target_property(depends "${target}" LINK_LIBRARIES) get_target_property(public_depends "${target}" INTERFACE_LINK_LIBRARIES) get_target_property(target_deps "${target}" _qt_target_deps) @@ -238,8 +238,14 @@ function(qt_internal_create_plugin_depends_file target) if(third_party_deps OR target_deps) # Setup build and install paths - if(qt_module) - set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${qt_module}") + set(find_dependency_paths "\${CMAKE_CURRENT_LIST_DIR}/..") + if(plugin_install_package_suffix) + set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${plugin_install_package_suffix}") + if(plugin_install_package_suffix MATCHES "/QmlPlugins") + # Qml plugins are one folder deeper. + set(find_dependency_paths "\${CMAKE_CURRENT_LIST_DIR}/../..") + endif() + else() set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target}") endif() @@ -250,12 +256,12 @@ function(qt_internal_create_plugin_depends_file target) # Configure and install ModuleDependencies file. configure_file( "${QT_CMAKE_DIR}/QtPluginDependencies.cmake.in" - "${config_build_dir}/${target}Dependencies.cmake" + "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Dependencies.cmake" @ONLY ) qt_install(FILES - "${config_build_dir}/${target}Dependencies.cmake" + "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Dependencies.cmake" DESTINATION "${config_install_dir}" COMPONENT Devel ) @@ -346,8 +352,21 @@ function(qt_internal_create_plugins_files) get_target_property(qt_plugins "${QT_MODULE}" QT_PLUGINS) if(qt_plugins) foreach (pluginTarget ${qt_plugins}) - set(QT_MODULE_PLUGIN_INCLUDES "${QT_MODULE_PLUGIN_INCLUDES}include(\"\${CMAKE_CURRENT_LIST_DIR}/${pluginTarget}Config.cmake\")\n") + set(QT_MODULE_PLUGIN_INCLUDES "${QT_MODULE_PLUGIN_INCLUDES}include(\"\${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${pluginTarget}Config.cmake\")\n") endforeach() + endif() + + if(QT_MODULE STREQUAL "Qml") + set(QT_MODULE_PLUGIN_INCLUDES "${QT_MODULE_PLUGIN_INCLUDES} +file(GLOB __qt_qml_plugins_config_file_list \"\${CMAKE_CURRENT_LIST_DIR}/QmlPlugins/${INSTALL_CMAKE_NAMESPACE}*Config.cmake\") +if (__qt_qml_plugins_config_file_list AND NOT QT_SKIP_AUTO_QML_PLUGIN_INCLUSION) + foreach(__qt_qml_plugin_config_file \${__qt_qml_plugins_config_file_list}) + include(\${__qt_qml_plugin_config_file}) + endforeach() +endif()") + endif() + + if(QT_MODULE_PLUGIN_INCLUDES) configure_file( "${QT_CMAKE_DIR}/QtPlugins.cmake.in" "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${QT_MODULE}Plugins.cmake" |