diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-09-23 16:55:11 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-09-29 16:14:44 +0200 |
commit | edc4357ae4893dd952ce1c07b180b4b334047606 (patch) | |
tree | 8bbcacc28972b851161e005b40555ed28bba0ce1 /examples/quick/threading/CMakeLists.txt | |
parent | 2a04bfaf3a2054222cc8a508ecd11727f2b2269b (diff) |
CMake: Fix examples that use 'shared' project when using a static Qt
When using a static Qt, linking of examples that use the 'shared' Qml
module would fail with the following error
Undefined symbols for architecture x86_64:
"qt_static_plugin_sharedPlugin()", referenced from:
StaticsharedPluginPluginInstance::StaticsharedPluginPluginInstance()
in window_shared_init.cpp.o
This happened because the 'shared' project pre-created its
plugin target with qt_add_library instead of qt_add_plugin.
qt_add_plugin passes an additional QT_STATICPLUGIN compile definition
when compiling the moc'ed file to ensure that the QT_MOC_EXPORT_PLUGIN
macro creates a qt_plugin_instance_PLUGIN_NAME symbol.
Unfortunately we can't use qt_add_plugin for shared Qt builds, because
some of the projects link directly against the plugin target and it's
not possible to link against a MODULE_LIBRARY target which
qt_add_plugin creates in shared Qt build.
We could try to conditionally switch between using qt_add_library for
a shared Qt build and qt_add_plugin for a static Qt build, but that
further complicates the build system code because it requires
specifying a class name and plugin type explicitly.
Remove the direct linkage against the libraries in the examples and
instead rely on plugin loading.
This simplifies the logic of not having to pre-create a target.
Amends 7b6eea37aeea55cdf1bcb1fd9c3091d6753f95e8
Pick-to: 6.2
Fixes: QTBUG-96805
Change-Id: I5b2f3992ccda29b59f1e99748005381c73daca69
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'examples/quick/threading/CMakeLists.txt')
-rw-r--r-- | examples/quick/threading/CMakeLists.txt | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/quick/threading/CMakeLists.txt b/examples/quick/threading/CMakeLists.txt index 86e17ac1b3..eb08dbe612 100644 --- a/examples/quick/threading/CMakeLists.txt +++ b/examples/quick/threading/CMakeLists.txt @@ -34,8 +34,8 @@ target_link_libraries(threadingexample PUBLIC Qt::Gui Qt::Qml Qt::Quick - threading_shared ) +add_dependencies(threadingexample threading_shared) qt_add_qml_module(threadingexample URI threading |