summaryrefslogtreecommitdiffstats
path: root/cmake/QtPlugins.cmake.in
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2021-03-22 20:43:25 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2021-03-26 11:52:00 +0100
commit98e8180e56322ce065e39cc1ef1d65b54caa8c25 (patch)
tree5a1879eb18d9359ba66038a2f72e30d81d71af77 /cmake/QtPlugins.cmake.in
parent27ebeeb50e192ead7f839cbfcf13a2a42132a920 (diff)
Fix error when re-configuring an already installed Qt repository
When building and installing a Qt repo that provides plugins for a Qt module within a different repository (for example, qtimageformats providing imageformat plugins for QtGui), re-configuring that repository would result in configuration errors like "add_library cannot create ALIAS target "Qt6::QTgaPlugin" because another target with the same name already exists." This happened, because the find_package(Qt6 COMPONENTS Gui) calls pulled in the Qt6*PluginConfig.cmake files that create imported targets for the plugins we want to build. To fix this, when building Qt, we now load only plugins that are provided by repositories the currently building repository depends on. We read the repo dependencies from dependencies.yaml when the Qt6BuildInternals package is loaded, but only in static builds and only if we're currently building a Qt repository. To find out whether we're building a Qt repository, we check whether QT_REPO_MODULE_VERSION is defined. We cannot check QT_BUILDING_QT, because that variable is not available for the first find_package calls in the repository's top-level project file. In each Qt6*PluginConfig.cmake file, we bail out if the plugin's repository is not one of the ones in QT_REPO_DEPENDENCIES. Fixes: QTBUG-86670 Fixes: QTBUG-91887 Change-Id: I8f6c8398032227032742f1ca019e983ff2bcd745 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtPlugins.cmake.in')
-rw-r--r--cmake/QtPlugins.cmake.in4
1 files changed, 3 insertions, 1 deletions
diff --git a/cmake/QtPlugins.cmake.in b/cmake/QtPlugins.cmake.in
index d57611caec..3e554a43ad 100644
--- a/cmake/QtPlugins.cmake.in
+++ b/cmake/QtPlugins.cmake.in
@@ -19,7 +19,9 @@ function(__qt_internal_add_static_plugins_once)
foreach(_config_file ${_qt_plugin_config_files})
string(REGEX REPLACE "^.*/@INSTALL_CMAKE_NAMESPACE@(.*Plugin)Config.cmake$" "\\1" _qt_plugin "${_config_file}")
include("${_config_file}")
- list(APPEND _qt_plugins ${_qt_plugin})
+ if(TARGET "@INSTALL_CMAKE_NAMESPACE@::${_qt_plugin}")
+ list(APPEND _qt_plugins ${_qt_plugin})
+ endif()
endforeach()
set_property(TARGET ${_module_target} PROPERTY QT_PLUGINS ${_qt_plugins})