qt5base-lts/cmake/QtBuildInternals
Joerg Bornemann 98e8180e56 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>
2021-03-26 11:52:00 +01:00
..
QtStandaloneTestTemplateProject CMake: Fix standalone tests to work properly on reconfiguration 2020-06-04 22:28:06 +02:00
QtBuildInternalsConfig.cmake Fix error when re-configuring an already installed Qt repository 2021-03-26 11:52:00 +01:00