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 ) diff --git a/cmake/QtPluginConfig.cmake.in b/cmake/QtPluginConfig.cmake.in index 5fde0bc511..7b9eacc766 100644 --- a/cmake/QtPluginConfig.cmake.in +++ b/cmake/QtPluginConfig.cmake.in @@ -9,8 +9,8 @@ get_filename_component(_import_prefix "${_import_prefix}" REALPATH) if (NOT QT_NO_CREATE_TARGETS) # Find required dependencies, if any. - if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@target@Dependencies.cmake") - include("${CMAKE_CURRENT_LIST_DIR}/@target@Dependencies.cmake") + if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake") endif() include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake") diff --git a/cmake/QtPluginDependencies.cmake.in b/cmake/QtPluginDependencies.cmake.in index f25d0bed43..eb1d9c3433 100644 --- a/cmake/QtPluginDependencies.cmake.in +++ b/cmake/QtPluginDependencies.cmake.in @@ -31,7 +31,7 @@ foreach(_target_dep ${_target_deps}) if (NOT ${pkg}_FOUND) find_dependency(${pkg} ${version} - PATHS "${CMAKE_CURRENT_LIST_DIR}/.." ${QT_EXAMPLES_CMAKE_PREFIX_PATH} NO_DEFAULT_PATH + PATHS @find_dependency_paths@ ${QT_EXAMPLES_CMAKE_PREFIX_PATH} NO_DEFAULT_PATH ) endif() 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"