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/embedded/digiflip/CMakeLists.txt | 34 ++++++++++++------- examples/embedded/flickable/CMakeLists.txt | 34 ++++++++++++------- examples/embedded/flightinfo/CMakeLists.txt | 44 +++++++++++++------------ examples/embedded/lightmaps/CMakeLists.txt | 44 +++++++++++++++---------- examples/embedded/raycasting/CMakeLists.txt | 37 +++++++++++---------- examples/embedded/styleexample/CMakeLists.txt | 47 +++++++++++++-------------- 6 files changed, 135 insertions(+), 105 deletions(-) (limited to 'examples/embedded') diff --git a/examples/embedded/digiflip/CMakeLists.txt b/examples/embedded/digiflip/CMakeLists.txt index 3786ed38a4..bc94d6809a 100644 --- a/examples/embedded/digiflip/CMakeLists.txt +++ b/examples/embedded/digiflip/CMakeLists.txt @@ -1,15 +1,25 @@ # Generated from digiflip.pro. -##################################################################### -## digiflip Binary: -##################################################################### - -add_qt_executable(digiflip - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/embedded/digiflip" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/embedded/digiflip" - SOURCES - digiflip.cpp - LIBRARIES - Qt::Widgets +cmake_minimum_required(VERSION 3.14) +project(digiflip LANGUAGES CXX) + +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(digiflip WIN32 MACOSX_BUNDLE + digiflip.cpp +) +target_link_libraries(digiflip PUBLIC + Qt::Widgets +) +install(TARGETS digiflip + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" ) diff --git a/examples/embedded/flickable/CMakeLists.txt b/examples/embedded/flickable/CMakeLists.txt index 20f8eca9f5..8d5d9878f0 100644 --- a/examples/embedded/flickable/CMakeLists.txt +++ b/examples/embedded/flickable/CMakeLists.txt @@ -1,16 +1,26 @@ # Generated from flickable.pro. -##################################################################### -## flickable Binary: -##################################################################### +cmake_minimum_required(VERSION 3.14) +project(flickable LANGUAGES CXX) -add_qt_executable(flickable - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/embedded/flickable" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/embedded/flickable" - SOURCES - flickable.cpp flickable.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(flickable WIN32 MACOSX_BUNDLE + flickable.cpp flickable.h + main.cpp +) +target_link_libraries(flickable PUBLIC + Qt::Widgets +) +install(TARGETS flickable + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" ) diff --git a/examples/embedded/flightinfo/CMakeLists.txt b/examples/embedded/flightinfo/CMakeLists.txt index a4276bf2d8..9afc98df76 100644 --- a/examples/embedded/flightinfo/CMakeLists.txt +++ b/examples/embedded/flightinfo/CMakeLists.txt @@ -1,27 +1,29 @@ # Generated from flightinfo.pro. -##################################################################### -## flightinfo Binary: -##################################################################### +cmake_minimum_required(VERSION 3.14) +project(flightinfo LANGUAGES CXX) -add_qt_executable(flightinfo - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/embedded/flightinfo" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/embedded/flightinfo" - SOURCES - flightinfo.cpp - form.ui - PUBLIC_LIBRARIES - Qt::Network - 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(flightinfo "flightinfo" PREFIX "/" FILES - aircraft.png) +set(INSTALL_EXAMPLEDIR "examples") +find_package(Qt5 COMPONENTS Network) +find_package(Qt5 COMPONENTS Widgets) -#### Keys ignored in scope 1:.:.:flightinfo.pro:: -# TEMPLATE = "app" +add_executable(flightinfo WIN32 MACOSX_BUNDLE + flightinfo.cpp + form.ui + flightinfo.qrc # special case: add +) +target_link_libraries(flightinfo PUBLIC + Qt::Network + Qt::Widgets +) +install(TARGETS flightinfo + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/embedded/lightmaps/CMakeLists.txt b/examples/embedded/lightmaps/CMakeLists.txt index 4779d07adc..35171451bf 100644 --- a/examples/embedded/lightmaps/CMakeLists.txt +++ b/examples/embedded/lightmaps/CMakeLists.txt @@ -1,22 +1,30 @@ # Generated from lightmaps.pro. -##################################################################### -## lightmaps Binary: -##################################################################### +cmake_minimum_required(VERSION 3.14) +project(lightmaps LANGUAGES CXX) -add_qt_executable(lightmaps - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/embedded/lightmaps" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/embedded/lightmaps" - SOURCES - lightmaps.cpp lightmaps.h - main.cpp - mapzoom.cpp mapzoom.h - slippymap.cpp slippymap.h - LIBRARIES - Qt::Network - 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 Network) +find_package(Qt5 COMPONENTS Widgets) -#### Keys ignored in scope 1:.:lightmaps.pro:: -# TEMPLATE = "app" +add_executable(lightmaps WIN32 MACOSX_BUNDLE + lightmaps.cpp lightmaps.h + main.cpp + mapzoom.cpp mapzoom.h + slippymap.cpp slippymap.h +) +target_link_libraries(lightmaps PUBLIC + Qt::Network + Qt::Widgets +) +install(TARGETS lightmaps + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/embedded/raycasting/CMakeLists.txt b/examples/embedded/raycasting/CMakeLists.txt index 3757bb756a..0578b6e0bd 100644 --- a/examples/embedded/raycasting/CMakeLists.txt +++ b/examples/embedded/raycasting/CMakeLists.txt @@ -1,23 +1,26 @@ # Generated from raycasting.pro. -##################################################################### -## raycasting Binary: -##################################################################### +cmake_minimum_required(VERSION 3.14) +project(raycasting LANGUAGES CXX) -add_qt_executable(raycasting - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/embedded/raycasting" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/embedded/raycasting" - SOURCES - raycasting.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") -# Resources: -add_qt_resource(raycasting "raycasting" PREFIX "/" FILES - textures.png) +find_package(Qt5 COMPONENTS Widgets) +add_executable(raycasting WIN32 MACOSX_BUNDLE + raycasting.cpp raycasting.qrc +) +target_link_libraries(raycasting PUBLIC + Qt::Widgets +) -#### Keys ignored in scope 1:.:raycasting.pro:: -# TEMPLATE = "app" +install(TARGETS raycasting + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/embedded/styleexample/CMakeLists.txt b/examples/embedded/styleexample/CMakeLists.txt index d14acc8b5a..2210d8cf9b 100644 --- a/examples/embedded/styleexample/CMakeLists.txt +++ b/examples/embedded/styleexample/CMakeLists.txt @@ -1,30 +1,27 @@ # Generated from styleexample.pro. -##################################################################### -## styleexample Binary: -##################################################################### +cmake_minimum_required(VERSION 3.14) +project(styleexample LANGUAGES CXX) -add_qt_executable(styleexample - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/embedded/styleexample" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/embedded/styleexample" - SOURCES - main.cpp - stylewidget.cpp stylewidget.h stylewidget.ui - 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") -# Resources: -add_qt_resource(styleexample "styleexample" PREFIX "/" FILES - files/add.png - files/application.qss - files/blue.qss - files/khaki.qss - files/nature_1.jpg - files/nostyle.qss - files/remove.png - files/transparent.qss) +find_package(Qt5 COMPONENTS Widgets) +add_executable(styleexample WIN32 MACOSX_BUNDLE + main.cpp + stylewidget.cpp stylewidget.h stylewidget.ui + styleexample.qrc # special case: add +) +target_link_libraries(styleexample PUBLIC + Qt::Widgets +) +install(TARGETS styleexample + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" +) -- cgit v1.2.3