aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-09-23 16:55:11 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-09-30 22:24:01 +0200
commit54774a5203ef45fe5b47b09f5ee1d57f07c9ecef (patch)
treea4cf12b2190e870cc43112f94dcb9a2469109010 /examples/quick
parent61b22013b192da2cfc3a061f2f5ffa65682f368b (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 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> (cherry picked from commit edc4357ae4893dd952ce1c07b180b4b334047606) Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'examples/quick')
-rw-r--r--examples/quick/animation/CMakeLists.txt2
-rw-r--r--examples/quick/delegatechooser/CMakeLists.txt2
-rw-r--r--examples/quick/shapes/CMakeLists.txt2
-rw-r--r--examples/quick/shared/CMakeLists.txt2
-rw-r--r--examples/quick/text/CMakeLists.txt2
-rw-r--r--examples/quick/threading/CMakeLists.txt2
-rw-r--r--examples/quick/touchinteraction/CMakeLists.txt2
-rw-r--r--examples/quick/views/CMakeLists.txt2
-rw-r--r--examples/quick/window/CMakeLists.txt2
9 files changed, 8 insertions, 10 deletions
diff --git a/examples/quick/animation/CMakeLists.txt b/examples/quick/animation/CMakeLists.txt
index 2d565c24f9..29c6e184e0 100644
--- a/examples/quick/animation/CMakeLists.txt
+++ b/examples/quick/animation/CMakeLists.txt
@@ -34,8 +34,8 @@ target_link_libraries(animationexample PUBLIC
Qt::Gui
Qt::Qml
Qt::Quick
- animation_shared
)
+add_dependencies(animationexample animation_shared)
qt_add_qml_module(animationexample
URI animation
diff --git a/examples/quick/delegatechooser/CMakeLists.txt b/examples/quick/delegatechooser/CMakeLists.txt
index 1ceecc4736..1c6abcff47 100644
--- a/examples/quick/delegatechooser/CMakeLists.txt
+++ b/examples/quick/delegatechooser/CMakeLists.txt
@@ -26,8 +26,8 @@ target_link_libraries(delegatechooserexample PUBLIC
Qt::Gui
Qt::Qml
Qt::Quick
- delegatechooser_shared
)
+add_dependencies(delegatechooserexample delegatechooser_shared)
qt_add_qml_module(delegatechooserexample
URI delegatechooser
diff --git a/examples/quick/shapes/CMakeLists.txt b/examples/quick/shapes/CMakeLists.txt
index ce83fd32cc..04d00776e6 100644
--- a/examples/quick/shapes/CMakeLists.txt
+++ b/examples/quick/shapes/CMakeLists.txt
@@ -34,8 +34,8 @@ target_link_libraries(shapesexample PUBLIC
Qt::Gui
Qt::Qml
Qt::Quick
- shapes_shared
)
+add_dependencies(shapesexample delegatechooser_shared)
qt_add_qml_module(shapesexample
URI shapes
diff --git a/examples/quick/shared/CMakeLists.txt b/examples/quick/shared/CMakeLists.txt
index 5d23f0d16a..6d93a10010 100644
--- a/examples/quick/shared/CMakeLists.txt
+++ b/examples/quick/shared/CMakeLists.txt
@@ -1,5 +1,3 @@
-qt_add_library(${PROJECT_NAME}_shared)
-
set_source_files_properties(CheckBox.qml TabSet.qml TextField.qml
PROPERTIES
QT_QML_SOURCE_VERSIONS 2.1
diff --git a/examples/quick/text/CMakeLists.txt b/examples/quick/text/CMakeLists.txt
index 8e697cd6c2..e2fa455b8b 100644
--- a/examples/quick/text/CMakeLists.txt
+++ b/examples/quick/text/CMakeLists.txt
@@ -34,8 +34,8 @@ target_link_libraries(textexample PUBLIC
Qt::Gui
Qt::Qml
Qt::Quick
- text_shared
)
+add_dependencies(textexample text_shared)
qt_add_qml_module(textexample
URI text
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
diff --git a/examples/quick/touchinteraction/CMakeLists.txt b/examples/quick/touchinteraction/CMakeLists.txt
index 5f7b0693ac..f2856b7f6e 100644
--- a/examples/quick/touchinteraction/CMakeLists.txt
+++ b/examples/quick/touchinteraction/CMakeLists.txt
@@ -34,8 +34,8 @@ target_link_libraries(touchinteractionexample PUBLIC
Qt::Gui
Qt::Qml
Qt::Quick
- touchinteraction_shared
)
+add_dependencies(touchinteractionexample touchinteraction_shared)
qt_add_qml_module(touchinteractionexample
URI touchinteraction
diff --git a/examples/quick/views/CMakeLists.txt b/examples/quick/views/CMakeLists.txt
index ca02f8d86e..59df78d940 100644
--- a/examples/quick/views/CMakeLists.txt
+++ b/examples/quick/views/CMakeLists.txt
@@ -34,8 +34,8 @@ target_link_libraries(viewsexample PRIVATE
Qt::Gui
Qt::Qml
Qt::Quick
- views_shared
)
+add_dependencies(viewsexample views_shared)
qt_add_qml_module(viewsexample
URI views
diff --git a/examples/quick/window/CMakeLists.txt b/examples/quick/window/CMakeLists.txt
index b8e81ff5c2..f8a9f45600 100644
--- a/examples/quick/window/CMakeLists.txt
+++ b/examples/quick/window/CMakeLists.txt
@@ -45,8 +45,8 @@ target_link_libraries(windowexample PRIVATE
Qt::Gui
Qt::Qml
Qt::Quick
- window_shared
)
+add_dependencies(windowexample window_shared)
install(TARGETS windowexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"