diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-04-06 13:06:11 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-04-07 14:02:36 +0000 |
commit | bce41e0c41cf8e25c0d46fe90f7ea1b1b358454a (patch) | |
tree | 1bd8397d53fa821b0069eaa9d47104fb8603e4fb /CMakeLists.txt | |
parent | f7605d562b83aef5b098ea18bf6c89f30ec4e920 (diff) |
CMake: Choose better defaults for qt_add_plugin STATIC/SHARED
There was a recent behavior change where the public CMake API
qt_add_plugin API took into account the value of BUILD_SHARED_LIBS
to decide whether the plugin should be a static or shared library.
Instead, use the following new behavior
- If no explicit option STATIC / SHARED option is passed, default to
whatever flavor Qt was built as.
Aka if Qt was configured with -shared, qt_add_plugin defaults
to creating shared plugins. If it's a -static Qt, create static
plugins.
- If an explicit STATIC / SHARED option is set, override the default
computed value with the given value.
As a result BUILD_SHARED_LIBS does not affect Qt plugins anymore. This
is more in line with Qt expectations.
Add SHARED as a new valid option to pass to qt_add_plugin (it wasn't
before).
Add tests to check for the above behavior.
Amends aa4a1006cbccbc180c600f9b4dc9e882bb5ed5ca
Fixes: QTBUG-92361
Task-number: QTBUG-88763
Change-Id: Iae806024ddd5cf10cfe58ddbcebd2818084b0bd7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit d0c2425d791edd75e35cce65ddbcfaab9a7f16ed)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e05aa52e8..316430391d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,6 +71,10 @@ if(NOT QT_BUILD_STANDALONE_TESTS) option(BUILD_SHARED_LIBS "Build Qt statically or dynamically" ON) set(QT_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) + # This variable is also set in Qt6CoreConfigExtras.cmake, but it's not loaded when building + # qtbase. Set it here so qt_add_plugin can compute the proper plugin flavor. + set(QT6_IS_SHARED_LIBS_BUILD ${BUILD_SHARED_LIBS}) + ## Should this Qt be built with Werror? option(WARNINGS_ARE_ERRORS "Build Qt with warnings as errors" ${FEATURE_developer_build}) |