Skip to content

Commit

Permalink
CMake: Fix auto-linking of static plugins in standalone tests
Browse files Browse the repository at this point in the history
The change introduced in 98e8180
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 98e8180

Pick-to: 6.1
Task-number: QTBUG-87580
Change-Id: I690a0366c73a24e7f49c65ed13cd70362c273d81
Reviewed-by: Qt CI Bot <[email protected]>
Reviewed-by: Joerg Bornemann <[email protected]>
  • Loading branch information
alcroito committed Apr 21, 2021
1 parent 2e2ef31 commit be1ee03
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmake/QtPluginConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit be1ee03

Please sign in to comment.