CMake: Fix auto-linking of static plugins in standalone tests

The change introduced in 98e8180e56
fixes reconfiguration issues for repositories that provide plugins
associated with modules from a different repository
(QSvgPlugin -> QtGui -> qtbase).

It does so by only loading the public Plugin CMake packages of
dependent repositories.

For executables / tests that are built as part of the current
repository, plugins are linked via a different simplified mechanism in
qt_add_internal_plugin and qt_internal_add_plugin in order to prevent
exporting link cycles between plugins and Qt modules.

This works for the majority of in-tree tests, but unfortunately breaks
static standalone tests.

For example in qtbase neither mechanism will link plugins to the
standalone tests:

 - qtbase has no repo dependencies, so the first mechanism (loading of
   public plugin packages) is skipped because we assume we are merely
   reconfiguring the main build of qtbase and we don't want to
   accidentally create duplicate plugin targets

 - because a standalone test configuration does not call
   qt_internal_add_plugin, no association is done between qt plugin
   and module and thus all tests (qt_internal_add_test ->
   qt_internal_add_executable) don't get the simplified plugin
   linking

Fix this by allowing loading of the public CMake plugin packages when
doing standalone tests. It should be safe to do so because we don't
build any plugins in this case, only tests.

Amends 98e8180e56

Pick-to: 6.1
Task-number: QTBUG-87580
Change-Id: I690a0366c73a24e7f49c65ed13cd70362c273d81
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2021-04-20 17:23:47 +02:00
parent 2e2ef31d41
commit be1ee03a0f

View File

@ -1,6 +1,6 @@
include_guard(DIRECTORY)
if(DEFINED QT_REPO_DEPENDENCIES)
if(DEFINED QT_REPO_DEPENDENCIES AND NOT QT_BUILD_STANDALONE_TESTS)
# We're building a Qt repository.
# Skip this plugin if it has not been provided by one of this repo's dependencies.
string(TOLOWER "@PROJECT_NAME@" lower_case_project_name)