From 64c6c943c7469c60e8d25c3efd630249740ae2f4 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Mon, 18 Mar 2019 19:26:24 +0100 Subject: CMake: Add more examples Change-Id: I7a8a3fd0a844a518592957fe07c6e707dd452d5f Reviewed-by: Alexandru Croitor --- examples/sql/books/CMakeLists.txt | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 examples/sql/books/CMakeLists.txt (limited to 'examples/sql/books/CMakeLists.txt') diff --git a/examples/sql/books/CMakeLists.txt b/examples/sql/books/CMakeLists.txt new file mode 100644 index 0000000000..e01adc1402 --- /dev/null +++ b/examples/sql/books/CMakeLists.txt @@ -0,0 +1,30 @@ +# Generated from books.pro. + +##################################################################### +## books Binary: +##################################################################### + +add_qt_executable(books + GUI + OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/sql/books" + INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/sql/books" + SOURCES + bookdelegate.cpp bookdelegate.h + bookwindow.cpp bookwindow.h bookwindow.ui + initdb.h + main.cpp + INCLUDE_DIRECTORIES + ${CMAKE_CURRENT_SOURCE_DIR} + LIBRARIES + Qt::Sql + Qt::Widgets + Qt::Widgets +) + +# Resources: +add_qt_resource(books "books" PREFIX "/" FILES + images/star.png) + + +#### Keys ignored in scope 1:.:books.pro:: +# TEMPLATE = "app" -- 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/sql/books/CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'examples/sql/books/CMakeLists.txt') diff --git a/examples/sql/books/CMakeLists.txt b/examples/sql/books/CMakeLists.txt index e01adc1402..7a25b95cde 100644 --- a/examples/sql/books/CMakeLists.txt +++ b/examples/sql/books/CMakeLists.txt @@ -14,11 +14,12 @@ add_qt_executable(books initdb.h main.cpp INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_SOURCE_DIR} - LIBRARIES + . + PUBLIC_LIBRARIES Qt::Sql Qt::Widgets - Qt::Widgets + ENABLE_AUTOGEN_TOOLS + uic ) # Resources: @@ -26,5 +27,5 @@ add_qt_resource(books "books" PREFIX "/" FILES images/star.png) -#### Keys ignored in scope 1:.:books.pro:: +#### Keys ignored in scope 1:.:.:books.pro:: # TEMPLATE = "app" -- 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/sql/books/CMakeLists.txt | 54 +++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 25 deletions(-) (limited to 'examples/sql/books/CMakeLists.txt') diff --git a/examples/sql/books/CMakeLists.txt b/examples/sql/books/CMakeLists.txt index 7a25b95cde..294a764a9b 100644 --- a/examples/sql/books/CMakeLists.txt +++ b/examples/sql/books/CMakeLists.txt @@ -1,31 +1,35 @@ # Generated from books.pro. -##################################################################### -## books Binary: -##################################################################### +cmake_minimum_required(VERSION 3.14) +project(books LANGUAGES CXX) -add_qt_executable(books - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/sql/books" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/sql/books" - SOURCES - bookdelegate.cpp bookdelegate.h - bookwindow.cpp bookwindow.h bookwindow.ui - initdb.h - main.cpp - INCLUDE_DIRECTORIES - . - PUBLIC_LIBRARIES - Qt::Sql - 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(books "books" PREFIX "/" FILES - images/star.png) +set(INSTALL_EXAMPLEDIR "examples") +find_package(Qt5 COMPONENTS Sql) +find_package(Qt5 COMPONENTS Widgets) -#### Keys ignored in scope 1:.:.:books.pro:: -# TEMPLATE = "app" +add_executable(books WIN32 MACOSX_BUNDLE + bookdelegate.cpp bookdelegate.h + books.qrc + bookwindow.cpp bookwindow.h bookwindow.ui + initdb.h + main.cpp +) +target_include_directories(books PUBLIC + . +) +target_link_libraries(books PUBLIC + Qt::Sql + Qt::Widgets +) + +install(TARGETS books + 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/sql/books/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/sql/books/CMakeLists.txt') diff --git a/examples/sql/books/CMakeLists.txt b/examples/sql/books/CMakeLists.txt index 294a764a9b..cfee3e237d 100644 --- a/examples/sql/books/CMakeLists.txt +++ b/examples/sql/books/CMakeLists.txt @@ -14,7 +14,7 @@ set(INSTALL_EXAMPLEDIR "examples") find_package(Qt5 COMPONENTS Sql) find_package(Qt5 COMPONENTS Widgets) -add_executable(books WIN32 MACOSX_BUNDLE +add_qt_gui_executable(books WIN32 MACOSX_BUNDLE bookdelegate.cpp bookdelegate.h books.qrc bookwindow.cpp bookwindow.h bookwindow.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/sql/books/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'examples/sql/books/CMakeLists.txt') diff --git a/examples/sql/books/CMakeLists.txt b/examples/sql/books/CMakeLists.txt index cfee3e237d..e9044e34b8 100644 --- a/examples/sql/books/CMakeLists.txt +++ b/examples/sql/books/CMakeLists.txt @@ -14,7 +14,7 @@ set(INSTALL_EXAMPLEDIR "examples") find_package(Qt5 COMPONENTS Sql) find_package(Qt5 COMPONENTS Widgets) -add_qt_gui_executable(books WIN32 MACOSX_BUNDLE +add_qt_gui_executable(books bookdelegate.cpp bookdelegate.h books.qrc bookwindow.cpp bookwindow.h bookwindow.ui @@ -32,4 +32,5 @@ target_link_libraries(books PUBLIC install(TARGETS books RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" ) -- cgit v1.2.3