638ac41293
The examples use an intermediate object library to avoid duplicate file compilation. The examples worked when built as part of Qt because the shared directory was always added, and Qt::OpenGL is available implicitly. Change each project to add_subdirectory(../shared) if the object library is not available, thus making the examples build as standalone projects. Call find_package inside the shared project, to ensure the Qt packages are found. Create an alias called 'painting_shared::painting_shared' and link against that to ensure that any failure is caught at configure time rather than build time. Adapt the pathstroke example to use the object library. Comment out the code for the OpenGL scopes, because it's handled by the object library. Make sure the OpenGL dependency is public. Make sure to run moc and compile the OpenGL specific files as well. Task-number: QTBUG-87444 Change-Id: Ib0ecb68948581c5267ca04f19d8043fa44ff3d54 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
35 lines
1.2 KiB
CMake
35 lines
1.2 KiB
CMake
# 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:-/
|
|
target_sources(painting_shared PRIVATE
|
|
arthurstyle.cpp arthurstyle.h
|
|
arthurwidgets.cpp arthurwidgets.h
|
|
hoverpoints.cpp hoverpoints.h
|
|
${moc_files}
|
|
)
|
|
target_link_libraries(painting_shared PUBLIC Qt::Widgets)
|
|
target_include_directories(painting_shared PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
## Scopes:
|
|
#####################################################################
|
|
|
|
if (TARGET Qt::OpenGL OR QT_FEATURE_opengles2)
|
|
target_compile_definitions(painting_shared PRIVATE QT_OPENGL_SUPPORT)
|
|
target_link_libraries(painting_shared PUBLIC
|
|
Qt::OpenGL
|
|
)
|
|
qt6_wrap_cpp(moc_files_gl fbopaintdevice.h) # no automoc for OBJECT libs
|
|
target_sources(painting_shared PRIVATE fbopaintdevice.cpp fbopaintdevice.h ${moc_files_gl})
|
|
endif()
|