Skip to content

Commit

Permalink
Fix build of standalone painting examples
Browse files Browse the repository at this point in the history
Since commit f5c69a5 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 <[email protected]>
  • Loading branch information
jobor committed May 17, 2021
1 parent 536a4ab commit db25a06
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/widgets/painting/affine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ target_include_directories(affine PUBLIC

# special case begin
if(NOT TARGET painting_shared::painting_shared)
add_subdirectory(../shared painting_shared)
include(../shared/use_lib.cmake)
endif()
# special case end

Expand Down
2 changes: 1 addition & 1 deletion examples/widgets/painting/composition/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ target_include_directories(composition PUBLIC

# special case begin
if(NOT TARGET painting_shared::painting_shared)
add_subdirectory(../shared painting_shared)
include(../shared/use_lib.cmake)
endif()
# special case end

Expand Down
2 changes: 1 addition & 1 deletion examples/widgets/painting/deform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ target_include_directories(deform PUBLIC

# special case begin
if(NOT TARGET painting_shared::painting_shared)
add_subdirectory(../shared painting_shared)
include(../shared/use_lib.cmake)
endif()
# special case end

Expand Down
2 changes: 1 addition & 1 deletion examples/widgets/painting/gradients/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ target_include_directories(gradients PUBLIC

# special case begin
if(NOT TARGET painting_shared::painting_shared)
add_subdirectory(../shared painting_shared)
include(../shared/use_lib.cmake)
endif()
# special case end

Expand Down
2 changes: 1 addition & 1 deletion examples/widgets/painting/pathstroke/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ target_include_directories(pathstroke PUBLIC

# special case begin
if(NOT TARGET painting_shared::painting_shared)
add_subdirectory(../shared painting_shared)
include(../shared/use_lib.cmake)
endif()
# special case end

Expand Down
8 changes: 0 additions & 8 deletions examples/widgets/painting/shared/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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:-/
Expand Down
13 changes: 13 additions & 0 deletions examples/widgets/painting/shared/use_lib.cmake
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit db25a06

Please sign in to comment.