summaryrefslogtreecommitdiffstats
path: root/examples/widgets/painting/shared
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2021-05-17 14:09:37 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2021-05-17 17:14:10 +0200
commitdb25a067b0e1b5905e9cd3316df45f2be1b44594 (patch)
treee81f4af249469b5651f4aacc79d250947414fe1f /examples/widgets/painting/shared
parent536a4ab07988ccf52e071c5ab831069084b0cb71 (diff)
Fix build of standalone painting examples
Since commit f5c69a51956 the examples/widgets/painting examples could not be built standalone anymore. Move the find_package calls out of the examples/widgets/painting/shared subdirectory and add a .cmake file that can be included to use the library conveniently. Change-Id: I35cb5bd8419a67c782d109104c4a88d64477a8be Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'examples/widgets/painting/shared')
-rw-r--r--examples/widgets/painting/shared/CMakeLists.txt8
-rw-r--r--examples/widgets/painting/shared/use_lib.cmake13
2 files changed, 13 insertions, 8 deletions
diff --git a/examples/widgets/painting/shared/CMakeLists.txt b/examples/widgets/painting/shared/CMakeLists.txt
index 9d43e4a980..0fc65d3d99 100644
--- a/examples/widgets/painting/shared/CMakeLists.txt
+++ b/examples/widgets/painting/shared/CMakeLists.txt
@@ -1,14 +1,6 @@
# special case skip regeneration
# Port of shared.pri to be included by painting examples
-if(NOT TARGET Qt::Widgets)
- find_package(Qt6 REQUIRED COMPONENTS Widgets)
-endif()
-
-if(NOT TARGET Qt::OpenGL)
- find_package(Qt6 OPTIONAL_COMPONENTS OpenGL)
-endif()
-
add_library(painting_shared OBJECT)
add_library(painting_shared::painting_shared ALIAS painting_shared)
qt6_wrap_cpp(moc_files arthurwidgets.h hoverpoints.h) # no automoc for OBJECT libs:-/
diff --git a/examples/widgets/painting/shared/use_lib.cmake b/examples/widgets/painting/shared/use_lib.cmake
new file mode 100644
index 0000000000..11e9c2cf71
--- /dev/null
+++ b/examples/widgets/painting/shared/use_lib.cmake
@@ -0,0 +1,13 @@
+# Include this file in your example project to use the library defined in this directory.
+# This avoids find_package calls in a directory scope different from the directory scope of the
+# consuming target.
+
+if(NOT TARGET Qt::Widgets)
+ find_package(Qt6 REQUIRED COMPONENTS Widgets)
+endif()
+
+if(NOT TARGET Qt::OpenGL)
+ find_package(Qt6 OPTIONAL_COMPONENTS OpenGL)
+endif()
+
+add_subdirectory("${CMAKE_CURRENT_LIST_DIR}" painting_shared)