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/QtBuild.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/QtBuild.cmake')
-rw-r--r-- | cmake/QtBuild.cmake | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 982ac52c5a..959581e288 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -3804,6 +3804,7 @@ function(qt_internal_add_plugin target) if(NOT plugin_type_escaped STREQUAL "qml_plugin") qt_get_module_for_plugin("${target}" "${plugin_type_escaped}") get_target_property(qt_module "${target}" QT_MODULE) + set(plugin_install_package_suffix "${qt_module}") endif() # Add the plug-in to the list of plug-ins of this module @@ -3811,6 +3812,18 @@ function(qt_internal_add_plugin target) set_property(TARGET "${qt_module}" APPEND PROPERTY QT_PLUGINS "${target}") endif() + # Change the configuration file install location for qml plugins into the Qml package location. + if(plugin_type_escaped STREQUAL "qml_plugin" AND TARGET "${INSTALL_CMAKE_NAMESPACE}::Qml") + set(plugin_install_package_suffix "Qml/QmlPlugins") + endif() + + # Save the install package suffix as a property, so that the Dependencies file is placed + # in the current location. + if(plugin_install_package_suffix) + set_target_properties("${target}" PROPERTIES + _qt_plugin_install_package_suffix "${plugin_install_package_suffix}") + endif() + set(_default_plugin 1) if (DEFINED arg_DEFAULT_IF) if (NOT ${arg_DEFAULT_IF}) @@ -3882,9 +3895,12 @@ function(qt_internal_add_plugin target) if (NOT arg_SKIP_INSTALL) # Handle creation of cmake files for consumers of find_package(). - # If we are part of a Qt module, the plugin cmake files are installed as part of that module. - if(qt_module) - set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${qt_module}") + # If we are part of a Qt module, the plugin cmake files are installed as part of that + # module. + # For qml plugins, they are all installed into the QtQml package location for automatic + # discovery. + if(plugin_install_package_suffix) + set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${plugin_install_package_suffix}") else() set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target}") endif() @@ -3894,18 +3910,18 @@ function(qt_internal_add_plugin target) configure_package_config_file( "${QT_CMAKE_DIR}/QtPluginConfig.cmake.in" - "${config_build_dir}/${target}Config.cmake" + "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Config.cmake" INSTALL_DESTINATION "${config_install_dir}" ) write_basic_package_version_file( - "${config_build_dir}/${target}ConfigVersion.cmake" + "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion ) qt_install(FILES - "${config_build_dir}/${target}Config.cmake" - "${config_build_dir}/${target}ConfigVersion.cmake" + "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Config.cmake" + "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersion.cmake" DESTINATION "${config_install_dir}" COMPONENT Devel ) |