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>
This commit is contained in:
parent
3e3fdbe831
commit
81ea5f1906
@ -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
|
||||
)
|
||||
|
@ -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")
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user