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/dbus/chat/CMakeLists.txt | 59 ++++++++++++++-------- examples/dbus/complexpingpong/CMakeLists.txt | 34 ++++++++----- examples/dbus/listnames/CMakeLists.txt | 38 +++++++------- examples/dbus/pingpong/CMakeLists.txt | 54 +++++++++----------- .../dbus/remotecontrolledcar/car/CMakeLists.txt | 49 ++++++++++++------ .../remotecontrolledcar/controller/CMakeLists.txt | 49 +++++++++++------- 6 files changed, 171 insertions(+), 112 deletions(-) (limited to 'examples/dbus') diff --git a/examples/dbus/chat/CMakeLists.txt b/examples/dbus/chat/CMakeLists.txt index 9f321bbce3..26388c51eb 100644 --- a/examples/dbus/chat/CMakeLists.txt +++ b/examples/dbus/chat/CMakeLists.txt @@ -1,24 +1,43 @@ # Generated from chat.pro. -##################################################################### -## chat Binary: -##################################################################### +cmake_minimum_required(VERSION 3.14) +project(chat LANGUAGES CXX) -add_qt_executable(chat - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/dbus/chat" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/dbus/chat" - SOURCES - chat.cpp chat.h - chatmainwindow.ui - chatsetnickname.ui - DBUS_ADAPTOR_SOURCES - org.example.chat.xml - DBUS_INTERFACE_SOURCES - org.example.chat.xml - PUBLIC_LIBRARIES - Qt::DBus - 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 DBus) +find_package(Qt5 COMPONENTS Widgets) + +# special case begin +set(chat_SRCS) +qt5_add_dbus_interface(chat_SRCS + org.example.chat.xml + chat_interface +) +qt5_add_dbus_adaptor(chat_SRCS + org.example.chat.xml + qobject.h + QObject + chat_adaptor +) +# special case end +add_executable(chat WIN32 MACOSX_BUNDLE + chat.cpp chat.h + chatmainwindow.ui + chatsetnickname.ui + ${chat_SRCS} # special case +) +target_link_libraries(chat PUBLIC + Qt::DBus + Qt::Widgets +) +install(TARGETS chat + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" ) diff --git a/examples/dbus/complexpingpong/CMakeLists.txt b/examples/dbus/complexpingpong/CMakeLists.txt index cccb9584af..543af8491b 100644 --- a/examples/dbus/complexpingpong/CMakeLists.txt +++ b/examples/dbus/complexpingpong/CMakeLists.txt @@ -1,16 +1,26 @@ # Generated from complexpong.pro. -##################################################################### -## complexpong Binary: -##################################################################### +cmake_minimum_required(VERSION 3.14) +project(complexpong LANGUAGES CXX) -add_qt_executable(complexpong - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/dbus/complexpingpong" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/dbus/complexpingpong" - SOURCES - complexpong.cpp complexpong.h - LIBRARIES - # Remove: gui - Qt::DBus +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 DBus) + +add_executable(complexpong WIN32 MACOSX_BUNDLE + complexpong.cpp complexpong.h +) +target_link_libraries(complexpong PUBLIC + # Remove: gui + Qt::DBus +) +install(TARGETS complexpong + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" ) diff --git a/examples/dbus/listnames/CMakeLists.txt b/examples/dbus/listnames/CMakeLists.txt index eb622b0ef6..5fe935f24a 100644 --- a/examples/dbus/listnames/CMakeLists.txt +++ b/examples/dbus/listnames/CMakeLists.txt @@ -1,22 +1,26 @@ # Generated from listnames.pro. -##################################################################### -## listnames Binary: -##################################################################### +cmake_minimum_required(VERSION 3.14) +project(listnames LANGUAGES CXX) -add_qt_executable(listnames - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/dbus/listnames" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/dbus/listnames" - SOURCES - listnames.cpp - LIBRARIES - # Remove: gui - Qt::DBus -) +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 DBus) -#### Keys ignored in scope 2:.:listnames.pro:WIN32: -# CONFIG = "console" +add_executable(listnames WIN32 MACOSX_BUNDLE + listnames.cpp +) +target_link_libraries(listnames PUBLIC + # Remove: gui + Qt::DBus +) +install(TARGETS listnames + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/dbus/pingpong/CMakeLists.txt b/examples/dbus/pingpong/CMakeLists.txt index 0979c8d487..e82fe78c51 100644 --- a/examples/dbus/pingpong/CMakeLists.txt +++ b/examples/dbus/pingpong/CMakeLists.txt @@ -1,35 +1,27 @@ -# Generated from pingpong.pro. +# Generated from pong.pro. -##################################################################### -## ping Binary: -##################################################################### +cmake_minimum_required(VERSION 3.14) +project(pong LANGUAGES CXX) -add_qt_executable(ping - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/dbus/pingpong" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/dbus/pingpong" - SOURCES - ping.cpp - ping-common.h - LIBRARIES - # Remove: gui - Qt::DBus -) -##################################################################### -## pong Binary: -##################################################################### +set(CMAKE_INCLUDE_CURRENT_DIR ON) -add_qt_executable(pong - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/dbus/pingpong" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/dbus/pingpong" - SOURCES - ping-common.h - pong.cpp pong.h - LIBRARIES - # Remove: gui - Qt::DBus -) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +set(INSTALL_EXAMPLEDIR "examples") + +find_package(Qt5 COMPONENTS DBus) -if(WIN32) -endif() +add_executable(pong WIN32 MACOSX_BUNDLE + ping-common.h + pong.cpp pong.h +) +target_link_libraries(pong PUBLIC + # Remove: gui + Qt::DBus +) +install(TARGETS pong + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/dbus/remotecontrolledcar/car/CMakeLists.txt b/examples/dbus/remotecontrolledcar/car/CMakeLists.txt index a8aed5413a..9532d0ccee 100644 --- a/examples/dbus/remotecontrolledcar/car/CMakeLists.txt +++ b/examples/dbus/remotecontrolledcar/car/CMakeLists.txt @@ -1,19 +1,38 @@ # Generated from car.pro. -##################################################################### -## car Binary: -##################################################################### +cmake_minimum_required(VERSION 3.14) +project(car LANGUAGES CXX) -add_qt_executable(car - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/dbus/remotecontrolledcar/car" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/dbus/remotecontrolledcar/car" - SOURCES - car.cpp car.h - main.cpp - DBUS_ADAPTOR_SOURCES - car.xml - LIBRARIES - Qt::DBus - 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 DBus) +find_package(Qt5 COMPONENTS Widgets) + +# special case begin +set(car_SRCS) +qt5_add_dbus_adaptor(car_SRCS + car.xml + car.h + Car + car_adaptor +) +# special case end +add_executable(car WIN32 MACOSX_BUNDLE + car.cpp car.h + main.cpp + ${car_SRCS} # special case +) +target_link_libraries(car PUBLIC + Qt::DBus + Qt::Widgets +) +install(TARGETS car + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" ) diff --git a/examples/dbus/remotecontrolledcar/controller/CMakeLists.txt b/examples/dbus/remotecontrolledcar/controller/CMakeLists.txt index 3f360fa51b..00bf809392 100644 --- a/examples/dbus/remotecontrolledcar/controller/CMakeLists.txt +++ b/examples/dbus/remotecontrolledcar/controller/CMakeLists.txt @@ -1,21 +1,36 @@ # Generated from controller.pro. -##################################################################### -## controller Binary: -##################################################################### +cmake_minimum_required(VERSION 3.14) +project(controller LANGUAGES CXX) -add_qt_executable(controller - GUI - OUTPUT_DIRECTORY "${INSTALL_EXAMPLESDIR}/dbus/remotecontrolledcar/controller" - INSTALL_DIRECTORY "${INSTALL_EXAMPLESDIR}/dbus/remotecontrolledcar/controller" - SOURCES - controller.cpp controller.h controller.ui - main.cpp - DBUS_INTERFACE_SOURCES - car.xml - PUBLIC_LIBRARIES - Qt::DBus - 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 DBus) +find_package(Qt5 COMPONENTS Widgets) + +# special case begin +set(controller_SRCS) +qt5_add_dbus_interface(controller_SRCS + car.xml + car_interface +) +# special case end +add_executable(controller WIN32 MACOSX_BUNDLE + controller.cpp controller.h controller.ui + main.cpp + ${controller_SRCS} # special case +) +target_link_libraries(controller PUBLIC + Qt::DBus + Qt::Widgets +) +install(TARGETS controller + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" ) -- cgit v1.2.3