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/animation/easing/CMakeLists.txt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 examples/widgets/animation/easing/CMakeLists.txt (limited to 'examples/widgets/animation/easing') diff --git a/examples/widgets/animation/easing/CMakeLists.txt b/examples/widgets/animation/easing/CMakeLists.txt new file mode 100644 index 0000000000..ba391d082b --- /dev/null +++ b/examples/widgets/animation/easing/CMakeLists.txt @@ -0,0 +1,23 @@ +# Generated from easing.pro. + +##################################################################### +## easing Binary: +##################################################################### + +add_qt_executable(easing + GUI + OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/animation/easing" + INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/animation/easing" + SOURCES + animation.h + form.ui + main.cpp + window.cpp window.h + LIBRARIES + Qt::Widgets +) + +# Resources: +add_qt_resource(easing "easing" FILES + images/qt-logo.png) + -- 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/animation/easing/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'examples/widgets/animation/easing') diff --git a/examples/widgets/animation/easing/CMakeLists.txt b/examples/widgets/animation/easing/CMakeLists.txt index ba391d082b..b7444412a6 100644 --- a/examples/widgets/animation/easing/CMakeLists.txt +++ b/examples/widgets/animation/easing/CMakeLists.txt @@ -13,8 +13,10 @@ add_qt_executable(easing form.ui main.cpp window.cpp window.h - LIBRARIES + PUBLIC_LIBRARIES Qt::Widgets + ENABLE_AUTOGEN_TOOLS + uic ) # Resources: -- 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/animation/easing/CMakeLists.txt | 45 +++++++++++++----------- 1 file changed, 25 insertions(+), 20 deletions(-) (limited to 'examples/widgets/animation/easing') diff --git a/examples/widgets/animation/easing/CMakeLists.txt b/examples/widgets/animation/easing/CMakeLists.txt index b7444412a6..1500b11f3b 100644 --- a/examples/widgets/animation/easing/CMakeLists.txt +++ b/examples/widgets/animation/easing/CMakeLists.txt @@ -1,25 +1,30 @@ # Generated from easing.pro. -##################################################################### -## easing Binary: -##################################################################### +cmake_minimum_required(VERSION 3.14) +project(easing LANGUAGES CXX) -add_qt_executable(easing - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/animation/easing" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/widgets/animation/easing" - SOURCES - animation.h - form.ui - main.cpp - window.cpp window.h - 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) -# Resources: -add_qt_resource(easing "easing" FILES - images/qt-logo.png) +set(INSTALL_EXAMPLEDIR "examples") +find_package(Qt5 COMPONENTS Widgets) + +add_executable(easing WIN32 MACOSX_BUNDLE + animation.h + easing.qrc + form.ui + main.cpp + window.cpp window.h +) +target_link_libraries(easing PUBLIC + Qt::Widgets +) + +install(TARGETS easing + 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/animation/easing/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/widgets/animation/easing') diff --git a/examples/widgets/animation/easing/CMakeLists.txt b/examples/widgets/animation/easing/CMakeLists.txt index 1500b11f3b..441b27b0c4 100644 --- a/examples/widgets/animation/easing/CMakeLists.txt +++ b/examples/widgets/animation/easing/CMakeLists.txt @@ -13,7 +13,7 @@ set(INSTALL_EXAMPLEDIR "examples") find_package(Qt5 COMPONENTS Widgets) -add_executable(easing WIN32 MACOSX_BUNDLE +add_qt_gui_executable(easing WIN32 MACOSX_BUNDLE animation.h easing.qrc form.ui -- 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/animation/easing/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'examples/widgets/animation/easing') diff --git a/examples/widgets/animation/easing/CMakeLists.txt b/examples/widgets/animation/easing/CMakeLists.txt index 441b27b0c4..840e4e59ab 100644 --- a/examples/widgets/animation/easing/CMakeLists.txt +++ b/examples/widgets/animation/easing/CMakeLists.txt @@ -13,7 +13,7 @@ set(INSTALL_EXAMPLEDIR "examples") find_package(Qt5 COMPONENTS Widgets) -add_qt_gui_executable(easing WIN32 MACOSX_BUNDLE +add_qt_gui_executable(easing animation.h easing.qrc form.ui @@ -27,4 +27,5 @@ target_link_libraries(easing PUBLIC install(TARGETS easing RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" ) -- cgit v1.2.3