From aa50b377a7d904e35cf3a26e4c8a054108011ffd Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Wed, 20 Mar 2019 13:41:37 +0100 Subject: CMake: Add widgets examples Change-Id: Ib6142b93df066e3658eb189b50ca74c455fe7e56 Reviewed-by: Alexandru Croitor --- examples/widgets/touch/CMakeLists.txt | 6 ++++++ examples/widgets/touch/dials/CMakeLists.txt | 16 +++++++++++++++ examples/widgets/touch/fingerpaint/CMakeLists.txt | 25 +++++++++++++++++++++++ examples/widgets/touch/knobs/CMakeLists.txt | 16 +++++++++++++++ examples/widgets/touch/pinchzoom/CMakeLists.txt | 22 ++++++++++++++++++++ 5 files changed, 85 insertions(+) create mode 100644 examples/widgets/touch/CMakeLists.txt create mode 100644 examples/widgets/touch/dials/CMakeLists.txt create mode 100644 examples/widgets/touch/fingerpaint/CMakeLists.txt create mode 100644 examples/widgets/touch/knobs/CMakeLists.txt create mode 100644 examples/widgets/touch/pinchzoom/CMakeLists.txt (limited to 'examples/widgets/touch') diff --git a/examples/widgets/touch/CMakeLists.txt b/examples/widgets/touch/CMakeLists.txt new file mode 100644 index 0000000000..06b72cada7 --- /dev/null +++ b/examples/widgets/touch/CMakeLists.txt @@ -0,0 +1,6 @@ +# Generated from touch.pro. + +add_subdirectory(pinchzoom) +add_subdirectory(fingerpaint) +add_subdirectory(knobs) +add_subdirectory(dials) diff --git a/examples/widgets/touch/dials/CMakeLists.txt b/examples/widgets/touch/dials/CMakeLists.txt new file mode 100644 index 0000000000..0266bc4e3b --- /dev/null +++ b/examples/widgets/touch/dials/CMakeLists.txt @@ -0,0 +1,16 @@ +# Generated from dials.pro. + +##################################################################### +## dials Binary: +##################################################################### + +add_qt_executable(dials + GUI + OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/touch/dials" + INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/touch/dials" + SOURCES + dials.ui + main.cpp + LIBRARIES + Qt::Widgets +) diff --git a/examples/widgets/touch/fingerpaint/CMakeLists.txt b/examples/widgets/touch/fingerpaint/CMakeLists.txt new file mode 100644 index 0000000000..82ec8cd91e --- /dev/null +++ b/examples/widgets/touch/fingerpaint/CMakeLists.txt @@ -0,0 +1,25 @@ +# Generated from fingerpaint.pro. + +##################################################################### +## fingerpaint Binary: +##################################################################### + +add_qt_executable(fingerpaint + GUI + OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/touch/fingerpaint" + INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/touch/fingerpaint" + SOURCES + main.cpp + mainwindow.cpp mainwindow.h + scribblearea.cpp scribblearea.h + LIBRARIES + Qt::Widgets +) + +## Scopes: +##################################################################### + +extend_target(fingerpaint CONDITION TARGET Qt::PrintSupport + LIBRARIES + Qt::PrintSupport +) diff --git a/examples/widgets/touch/knobs/CMakeLists.txt b/examples/widgets/touch/knobs/CMakeLists.txt new file mode 100644 index 0000000000..e8976db270 --- /dev/null +++ b/examples/widgets/touch/knobs/CMakeLists.txt @@ -0,0 +1,16 @@ +# Generated from knobs.pro. + +##################################################################### +## knobs Binary: +##################################################################### + +add_qt_executable(knobs + GUI + OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/touch/knobs" + INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/touch/knobs" + SOURCES + knob.cpp knob.h + main.cpp + LIBRARIES + Qt::Widgets +) diff --git a/examples/widgets/touch/pinchzoom/CMakeLists.txt b/examples/widgets/touch/pinchzoom/CMakeLists.txt new file mode 100644 index 0000000000..92d7b4c3b3 --- /dev/null +++ b/examples/widgets/touch/pinchzoom/CMakeLists.txt @@ -0,0 +1,22 @@ +# Generated from pinchzoom.pro. + +##################################################################### +## pinchzoom Binary: +##################################################################### + +add_qt_executable(pinchzoom + GUI + OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/touch/pinchzoom" + INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/touch/pinchzoom" + SOURCES + graphicsview.cpp graphicsview.h + main.cpp + mouse.cpp mouse.h + LIBRARIES + Qt::Widgets +) + +# Resources: +add_qt_resource(pinchzoom "mice" PREFIX "/" FILES + images/cheese.jpg) + -- cgit v1.2.3 From fa21d29b7506e21db8a433e117aebb9f3c724f03 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 22 May 2019 16:23:24 +0200 Subject: Rerun pro2cmake on projects that use .ui files Task-number: QTBUG-75875 Change-Id: I95109b07fc4a6e09fe7911a21fc5f27f2c895d77 Reviewed-by: Simon Hausmann Reviewed-by: Qt CMake Build Bot --- examples/widgets/touch/dials/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'examples/widgets/touch') diff --git a/examples/widgets/touch/dials/CMakeLists.txt b/examples/widgets/touch/dials/CMakeLists.txt index 0266bc4e3b..76920b0f3c 100644 --- a/examples/widgets/touch/dials/CMakeLists.txt +++ b/examples/widgets/touch/dials/CMakeLists.txt @@ -11,6 +11,8 @@ add_qt_executable(dials SOURCES dials.ui main.cpp - LIBRARIES + PUBLIC_LIBRARIES Qt::Widgets + ENABLE_AUTOGEN_TOOLS + uic ) -- cgit v1.2.3 From 99539a289491a2a709c2a63cd91eac155a1699da Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Tue, 4 Jun 2019 17:08:47 +0200 Subject: Allow to build examples as standalone project Create CMake config files which can be used from the very same CMake project. These CMake config files simply do not create any targets, controlled via the QT_NO_CREATE_TARGETS. This patch also allows to build qtbase.git:examples as a standalone project, against an already-built Qt. Ran this: ag -s "QT " examples -l -0 | xargs -0 -n 1 .../util/cmake/pro2cmake.py --is-example Task-number: QTBUG-74713 Change-Id: I44cce5a4048618b30f890c5b789592c227a8b47d Reviewed-by: Alexandru Croitor --- examples/widgets/touch/dials/CMakeLists.txt | 37 +++++++++++------- examples/widgets/touch/fingerpaint/CMakeLists.txt | 47 ++++++++++++++--------- examples/widgets/touch/knobs/CMakeLists.txt | 35 +++++++++++------ examples/widgets/touch/pinchzoom/CMakeLists.txt | 41 ++++++++++++-------- 4 files changed, 98 insertions(+), 62 deletions(-) (limited to 'examples/widgets/touch') diff --git a/examples/widgets/touch/dials/CMakeLists.txt b/examples/widgets/touch/dials/CMakeLists.txt index 76920b0f3c..0589e555f3 100644 --- a/examples/widgets/touch/dials/CMakeLists.txt +++ b/examples/widgets/touch/dials/CMakeLists.txt @@ -1,18 +1,27 @@ # Generated from dials.pro. -##################################################################### -## dials Binary: -##################################################################### +cmake_minimum_required(VERSION 3.14) +project(dials LANGUAGES CXX) -add_qt_executable(dials - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/touch/dials" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/touch/dials" - SOURCES - dials.ui - main.cpp - PUBLIC_LIBRARIES - Qt::Widgets - ENABLE_AUTOGEN_TOOLS - uic +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +set(INSTALL_EXAMPLEDIR "examples") + +find_package(Qt5 COMPONENTS Widgets) + +add_executable(dials WIN32 MACOSX_BUNDLE + dials.ui + main.cpp +) +target_link_libraries(dials PUBLIC + Qt::Widgets +) + +install(TARGETS dials + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" ) diff --git a/examples/widgets/touch/fingerpaint/CMakeLists.txt b/examples/widgets/touch/fingerpaint/CMakeLists.txt index 82ec8cd91e..a419a614be 100644 --- a/examples/widgets/touch/fingerpaint/CMakeLists.txt +++ b/examples/widgets/touch/fingerpaint/CMakeLists.txt @@ -1,25 +1,34 @@ # Generated from fingerpaint.pro. -##################################################################### -## fingerpaint Binary: -##################################################################### +cmake_minimum_required(VERSION 3.14) +project(fingerpaint LANGUAGES CXX) -add_qt_executable(fingerpaint - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/touch/fingerpaint" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/touch/fingerpaint" - SOURCES - main.cpp - mainwindow.cpp mainwindow.h - scribblearea.cpp scribblearea.h - LIBRARIES - Qt::Widgets -) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +set(INSTALL_EXAMPLEDIR "examples") -## Scopes: -##################################################################### +find_package(Qt5 COMPONENTS Widgets) +find_package(Qt5 COMPONENTS PrintSupport) # special case + +add_executable(fingerpaint WIN32 MACOSX_BUNDLE + main.cpp + mainwindow.cpp mainwindow.h + scribblearea.cpp scribblearea.h +) +target_link_libraries(fingerpaint PUBLIC + Qt::Widgets +) +# special case begin +if (TARGET Qt::PrintSupport) + target_link_libraries(fingerpaint PUBLIC Qt::PrintSupport) +endif() +# special case end -extend_target(fingerpaint CONDITION TARGET Qt::PrintSupport - LIBRARIES - Qt::PrintSupport +install(TARGETS fingerpaint + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" ) diff --git a/examples/widgets/touch/knobs/CMakeLists.txt b/examples/widgets/touch/knobs/CMakeLists.txt index e8976db270..4a8f55820a 100644 --- a/examples/widgets/touch/knobs/CMakeLists.txt +++ b/examples/widgets/touch/knobs/CMakeLists.txt @@ -1,16 +1,27 @@ # Generated from knobs.pro. -##################################################################### -## knobs Binary: -##################################################################### +cmake_minimum_required(VERSION 3.14) +project(knobs LANGUAGES CXX) -add_qt_executable(knobs - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/touch/knobs" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/touch/knobs" - SOURCES - knob.cpp knob.h - main.cpp - LIBRARIES - Qt::Widgets +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +set(INSTALL_EXAMPLEDIR "examples") + +find_package(Qt5 COMPONENTS Widgets) + +add_executable(knobs WIN32 MACOSX_BUNDLE + knob.cpp knob.h + main.cpp +) +target_link_libraries(knobs PUBLIC + Qt::Widgets +) + +install(TARGETS knobs + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" ) diff --git a/examples/widgets/touch/pinchzoom/CMakeLists.txt b/examples/widgets/touch/pinchzoom/CMakeLists.txt index 92d7b4c3b3..379dde1e9f 100644 --- a/examples/widgets/touch/pinchzoom/CMakeLists.txt +++ b/examples/widgets/touch/pinchzoom/CMakeLists.txt @@ -1,22 +1,29 @@ # Generated from pinchzoom.pro. -##################################################################### -## pinchzoom Binary: -##################################################################### +cmake_minimum_required(VERSION 3.14) +project(pinchzoom LANGUAGES CXX) -add_qt_executable(pinchzoom - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/touch/pinchzoom" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/touch/pinchzoom" - SOURCES - graphicsview.cpp graphicsview.h - main.cpp - mouse.cpp mouse.h - LIBRARIES - Qt::Widgets -) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) -# Resources: -add_qt_resource(pinchzoom "mice" PREFIX "/" FILES - images/cheese.jpg) +set(INSTALL_EXAMPLEDIR "examples") +find_package(Qt5 COMPONENTS Widgets) + +add_executable(pinchzoom WIN32 MACOSX_BUNDLE + graphicsview.cpp graphicsview.h + main.cpp + mice.qrc + mouse.cpp mouse.h +) +target_link_libraries(pinchzoom PUBLIC + Qt::Widgets +) + +install(TARGETS pinchzoom + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" +) -- cgit v1.2.3 From 6732fa3a291e77acad3ab6ba829d1026462dc139 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 11 Jun 2019 15:46:31 +0200 Subject: Fix linking of examples Provide add_qt_gui_executable() as function in our public API that takes care of automaticWinMain linkage. We can use this in the future to encapsulate similarplatform-specific behavior and adjustments, such as module generation onAndroid. In order for the examples to see the function in Qt5CoreMacros, three more additional fixes were required: * Do the build_repo_end() call _before_ attempting to build the examples, as we need the build_repo_end() to include QtPostProcess and complete the creation of all the target config files. Otherwise the find_package() calls in the examples see something incomplete. * Add more QT_NO_CREATE_TARGET guards * Always call find_dependency on the dependencies, regardless of the target creation mode. This way a find_package(Qt5 COMPONENTS Widgets) will still load Qt5CoreMacros. Change-Id: I03ce856e2f4312a050fe8043b8331cbe8a6c93e6 Reviewed-by: Qt CMake Build Bot Reviewed-by: Leander Beernaert Reviewed-by: Alexandru Croitor --- examples/widgets/touch/dials/CMakeLists.txt | 2 +- examples/widgets/touch/fingerpaint/CMakeLists.txt | 2 +- examples/widgets/touch/knobs/CMakeLists.txt | 2 +- examples/widgets/touch/pinchzoom/CMakeLists.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'examples/widgets/touch') diff --git a/examples/widgets/touch/dials/CMakeLists.txt b/examples/widgets/touch/dials/CMakeLists.txt index 0589e555f3..fa31852b3d 100644 --- a/examples/widgets/touch/dials/CMakeLists.txt +++ b/examples/widgets/touch/dials/CMakeLists.txt @@ -13,7 +13,7 @@ set(INSTALL_EXAMPLEDIR "examples") find_package(Qt5 COMPONENTS Widgets) -add_executable(dials WIN32 MACOSX_BUNDLE +add_qt_gui_executable(dials WIN32 MACOSX_BUNDLE dials.ui main.cpp ) diff --git a/examples/widgets/touch/fingerpaint/CMakeLists.txt b/examples/widgets/touch/fingerpaint/CMakeLists.txt index a419a614be..606e6bbc64 100644 --- a/examples/widgets/touch/fingerpaint/CMakeLists.txt +++ b/examples/widgets/touch/fingerpaint/CMakeLists.txt @@ -14,7 +14,7 @@ set(INSTALL_EXAMPLEDIR "examples") find_package(Qt5 COMPONENTS Widgets) find_package(Qt5 COMPONENTS PrintSupport) # special case -add_executable(fingerpaint WIN32 MACOSX_BUNDLE +add_qt_gui_executable(fingerpaint WIN32 MACOSX_BUNDLE main.cpp mainwindow.cpp mainwindow.h scribblearea.cpp scribblearea.h diff --git a/examples/widgets/touch/knobs/CMakeLists.txt b/examples/widgets/touch/knobs/CMakeLists.txt index 4a8f55820a..c23a11f024 100644 --- a/examples/widgets/touch/knobs/CMakeLists.txt +++ b/examples/widgets/touch/knobs/CMakeLists.txt @@ -13,7 +13,7 @@ set(INSTALL_EXAMPLEDIR "examples") find_package(Qt5 COMPONENTS Widgets) -add_executable(knobs WIN32 MACOSX_BUNDLE +add_qt_gui_executable(knobs WIN32 MACOSX_BUNDLE knob.cpp knob.h main.cpp ) diff --git a/examples/widgets/touch/pinchzoom/CMakeLists.txt b/examples/widgets/touch/pinchzoom/CMakeLists.txt index 379dde1e9f..44951db727 100644 --- a/examples/widgets/touch/pinchzoom/CMakeLists.txt +++ b/examples/widgets/touch/pinchzoom/CMakeLists.txt @@ -13,7 +13,7 @@ set(INSTALL_EXAMPLEDIR "examples") find_package(Qt5 COMPONENTS Widgets) -add_executable(pinchzoom WIN32 MACOSX_BUNDLE +add_qt_gui_executable(pinchzoom WIN32 MACOSX_BUNDLE graphicsview.cpp graphicsview.h main.cpp mice.qrc -- cgit v1.2.3 From efa9998521cb061051fe8b75d0df3206d0b32ec5 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 12 Jun 2019 10:21:40 +0200 Subject: Fix compiling of examples on Android * Simplify add_qt_gui_executable() to not require WIN32/MACOSX_BUNDLE but provide it implicitly. It's redundant :) * When on Android, build a module (shared library), just like qmake. This requires an additional library destination in the install() call, but that's ignored on other platforms. * Fix typos in the android deployment generation settings function * Use the correct cache variable to determine whether we're inside a Qt build or not. Right now this only works inside Qt builds anyway as QtPlatformAndroid.cmake is not publically accessible. Change-Id: If1c763c31a7a83d0e0d854362ba7901657f63eb5 Reviewed-by: Alexandru Croitor Reviewed-by: Qt CMake Build Bot --- examples/widgets/touch/dials/CMakeLists.txt | 3 ++- examples/widgets/touch/fingerpaint/CMakeLists.txt | 3 ++- examples/widgets/touch/knobs/CMakeLists.txt | 3 ++- examples/widgets/touch/pinchzoom/CMakeLists.txt | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) (limited to 'examples/widgets/touch') diff --git a/examples/widgets/touch/dials/CMakeLists.txt b/examples/widgets/touch/dials/CMakeLists.txt index fa31852b3d..2bfe6b78cf 100644 --- a/examples/widgets/touch/dials/CMakeLists.txt +++ b/examples/widgets/touch/dials/CMakeLists.txt @@ -13,7 +13,7 @@ set(INSTALL_EXAMPLEDIR "examples") find_package(Qt5 COMPONENTS Widgets) -add_qt_gui_executable(dials WIN32 MACOSX_BUNDLE +add_qt_gui_executable(dials dials.ui main.cpp ) @@ -24,4 +24,5 @@ target_link_libraries(dials PUBLIC install(TARGETS dials RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" ) diff --git a/examples/widgets/touch/fingerpaint/CMakeLists.txt b/examples/widgets/touch/fingerpaint/CMakeLists.txt index 606e6bbc64..4ba2710e67 100644 --- a/examples/widgets/touch/fingerpaint/CMakeLists.txt +++ b/examples/widgets/touch/fingerpaint/CMakeLists.txt @@ -14,7 +14,7 @@ set(INSTALL_EXAMPLEDIR "examples") find_package(Qt5 COMPONENTS Widgets) find_package(Qt5 COMPONENTS PrintSupport) # special case -add_qt_gui_executable(fingerpaint WIN32 MACOSX_BUNDLE +add_qt_gui_executable(fingerpaint main.cpp mainwindow.cpp mainwindow.h scribblearea.cpp scribblearea.h @@ -31,4 +31,5 @@ endif() install(TARGETS fingerpaint RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" ) diff --git a/examples/widgets/touch/knobs/CMakeLists.txt b/examples/widgets/touch/knobs/CMakeLists.txt index c23a11f024..55f9820f68 100644 --- a/examples/widgets/touch/knobs/CMakeLists.txt +++ b/examples/widgets/touch/knobs/CMakeLists.txt @@ -13,7 +13,7 @@ set(INSTALL_EXAMPLEDIR "examples") find_package(Qt5 COMPONENTS Widgets) -add_qt_gui_executable(knobs WIN32 MACOSX_BUNDLE +add_qt_gui_executable(knobs knob.cpp knob.h main.cpp ) @@ -24,4 +24,5 @@ target_link_libraries(knobs PUBLIC install(TARGETS knobs RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" ) diff --git a/examples/widgets/touch/pinchzoom/CMakeLists.txt b/examples/widgets/touch/pinchzoom/CMakeLists.txt index 44951db727..f0cece0acd 100644 --- a/examples/widgets/touch/pinchzoom/CMakeLists.txt +++ b/examples/widgets/touch/pinchzoom/CMakeLists.txt @@ -13,7 +13,7 @@ set(INSTALL_EXAMPLEDIR "examples") find_package(Qt5 COMPONENTS Widgets) -add_qt_gui_executable(pinchzoom WIN32 MACOSX_BUNDLE +add_qt_gui_executable(pinchzoom graphicsview.cpp graphicsview.h main.cpp mice.qrc @@ -26,4 +26,5 @@ target_link_libraries(pinchzoom PUBLIC install(TARGETS pinchzoom RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" ) -- cgit v1.2.3