From 638ac41293da9c6ae5e4ccb9baa7819c772ba9dd Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 27 Oct 2020 12:07:51 +0100 Subject: CMake: Fix painting examples to build as standalone projects 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 --- examples/widgets/painting/gradients/CMakeLists.txt | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'examples/widgets/painting/gradients') diff --git a/examples/widgets/painting/gradients/CMakeLists.txt b/examples/widgets/painting/gradients/CMakeLists.txt index 0570ccfa37..6ad4dfa771 100644 --- a/examples/widgets/painting/gradients/CMakeLists.txt +++ b/examples/widgets/painting/gradients/CMakeLists.txt @@ -37,11 +37,17 @@ target_include_directories(gradients PUBLIC ../shared ) +# special case begin +if(NOT TARGET painting_shared::painting_shared) + add_subdirectory(../shared painting_shared) +endif() +# special case end + target_link_libraries(gradients PUBLIC Qt::Core Qt::Gui Qt::Widgets - painting_shared # special case + painting_shared::painting_shared # special case ) @@ -209,15 +215,18 @@ qt6_add_resources(gradients "gradients" ${gradients_resource_files} ) -if(QT_FEATURE_opengl) - target_sources(gradients PUBLIC - ../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h - ) +# special case begin +# remove files from ../shared +#if(QT_FEATURE_opengl) + #target_sources(affine PUBLIC + #../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h + #) - target_link_libraries(gradients PUBLIC - Qt::OpenGL - ) -endif() + #target_link_libraries(affine PUBLIC + #Qt::OpenGL + #) +#endif() +# special case end install(TARGETS gradients RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" -- cgit v1.2.3