diff options
author | Kai Köhne <kai.koehne@qt.io> | 2022-02-14 19:44:06 +0100 |
---|---|---|
committer | Kai Köhne <kai.koehne@qt.io> | 2022-02-17 15:16:57 +0100 |
commit | 62387ed3c3e169b42d4a07b673fdea2888769de6 (patch) | |
tree | 72f4724d47887c34041603bf388150647c3d5c4e /examples | |
parent | 24eb2adb43f89f59d6d58ad3cf2ed6110e539ad0 (diff) |
Improve examples CMakeLists.txt
- Remove "# generated from xyz.pro" comment from pro2cmake
- Remove "# special case" comments
- Remove automatic use of CMAKE_AUTORCC
- Only opt into CMAKE_AUTOUIC if .ui files are involved
- Remove explicit setting of CMAKE_INCLUDE_CURRENT_DIR
- Combine multiple find_package(Qt6 ... calls)
- use REQUIRED COMPONENTS
- sort components alphabetically
- Fix wrong indentations
- Use (only) one empty line after multi-line commands
Pick-to: 6.3
Change-Id: I213a18f08c12e5b2354f02be0ec64bc022bfb23c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/CMakeLists.txt | 2 | ||||
-rw-r--r-- | examples/webchannel/CMakeLists.txt | 9 | ||||
-rw-r--r-- | examples/webchannel/chatserver-cpp/CMakeLists.txt | 14 | ||||
-rw-r--r-- | examples/webchannel/standalone/CMakeLists.txt | 18 |
4 files changed, 12 insertions, 31 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index d6f839a..788aae4 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,5 +1,3 @@ -# Generated from examples.pro. - qt_examples_build_begin(EXTERNAL_BUILD) add_subdirectory(webchannel) diff --git a/examples/webchannel/CMakeLists.txt b/examples/webchannel/CMakeLists.txt index 5a6eb04..5ff8492 100644 --- a/examples/webchannel/CMakeLists.txt +++ b/examples/webchannel/CMakeLists.txt @@ -1,17 +1,14 @@ -# Generated from webchannel.pro. - -# special case begin # These are all TEMPLATE = aux #qt_internal_add_example(nodejs) #qt_internal_add_example(qwclient) #qt_internal_add_example(chatclient-html) -# special case end + if(TARGET Qt::WebSockets) qt_internal_add_example(chatserver-cpp) - # special case begin + # This one is TEMPLATE = aux too #qt_internal_add_example(chatclient-qml) - # special case end + endif() if(TARGET Qt::WebSockets AND TARGET Qt::Widgets) qt_internal_add_example(standalone) diff --git a/examples/webchannel/chatserver-cpp/CMakeLists.txt b/examples/webchannel/chatserver-cpp/CMakeLists.txt index 501f10f..dfbd8dc 100644 --- a/examples/webchannel/chatserver-cpp/CMakeLists.txt +++ b/examples/webchannel/chatserver-cpp/CMakeLists.txt @@ -1,23 +1,15 @@ -# Generated from chatserver-cpp.pro. - cmake_minimum_required(VERSION 3.16) project(chatserver LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) - set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") + set(INSTALL_EXAMPLESDIR "examples") endif() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webchannel/chatserver-cpp") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS WebSockets) -find_package(Qt6 COMPONENTS WebChannel) +find_package(Qt6 REQUIRED COMPONENTS Core WebChannel WebSockets) qt_add_executable(chatserver ../shared/websocketclientwrapper.cpp ../shared/websocketclientwrapper.h @@ -25,10 +17,12 @@ qt_add_executable(chatserver chatserver.cpp chatserver.h main.cpp ) + set_target_properties(chatserver PROPERTIES WIN32_EXECUTABLE FALSE MACOSX_BUNDLE TRUE ) + target_link_libraries(chatserver PUBLIC Qt::Core Qt::WebChannel diff --git a/examples/webchannel/standalone/CMakeLists.txt b/examples/webchannel/standalone/CMakeLists.txt index 420f06e..213c97b 100644 --- a/examples/webchannel/standalone/CMakeLists.txt +++ b/examples/webchannel/standalone/CMakeLists.txt @@ -1,25 +1,16 @@ -# Generated from standalone.pro. - cmake_minimum_required(VERSION 3.16) project(standalone LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) - set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") + set(INSTALL_EXAMPLESDIR "examples") endif() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webchannel/standalone") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS WebChannel) -find_package(Qt6 COMPONENTS Widgets) -find_package(Qt6 COMPONENTS WebSockets) +find_package(Qt6 REQUIRED COMPONENTS Core Gui WebChannel WebSockets Widgets) qt_add_executable(standalone ../shared/websocketclientwrapper.cpp ../shared/websocketclientwrapper.h @@ -28,16 +19,17 @@ qt_add_executable(standalone dialog.cpp dialog.h dialog.ui main.cpp ) + set_target_properties(standalone PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -# special case begin + # pro2cmake generates invalid cmake syntax here target_compile_definitions(standalone PUBLIC "BUILD_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\"" ) -# special case end + target_link_libraries(standalone PUBLIC Qt::Core Qt::Gui |