diff options
author | Kai Köhne <kai.koehne@qt.io> | 2022-02-14 19:25:00 +0100 |
---|---|---|
committer | Kai Köhne <kai.koehne@qt.io> | 2022-02-17 15:08:02 +0100 |
commit | 8429fc2d637faadadca63e1496a98ae03e62fc05 (patch) | |
tree | 21e390c3714cfcec332a849c8aada009fe143744 | |
parent | b752dcb14fba329bb43d3fb204fda1898b719122 (diff) |
Improve examples CMakeLists.txt
- Remove "# generated from xyz.pro" comment from pro2cmake
- Remove automatic use of CMAKE_AUTORCC
- Only opt into CMAKE_AUTOUIC if .ui files are involved
- Remove explicit setting of CMAKE_INCLUDE_CURRENT_DIR where
not necessary
- 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: I66b7edaf699db528ed91f738a009aaa2423e3d80
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
-rw-r--r-- | examples/serialbus/can/CMakeLists.txt | 12 | ||||
-rw-r--r-- | examples/serialbus/modbus/client/CMakeLists.txt | 14 | ||||
-rw-r--r-- | examples/serialbus/modbus/custom/CMakeLists.txt | 11 | ||||
-rw-r--r-- | examples/serialbus/modbus/server/CMakeLists.txt | 14 |
4 files changed, 14 insertions, 37 deletions
diff --git a/examples/serialbus/can/CMakeLists.txt b/examples/serialbus/can/CMakeLists.txt index b8a01af..34ec667 100644 --- a/examples/serialbus/can/CMakeLists.txt +++ b/examples/serialbus/can/CMakeLists.txt @@ -4,20 +4,15 @@ project(can 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}/serialbus/can") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Network) -find_package(Qt6 COMPONENTS SerialBus) -find_package(Qt6 COMPONENTS Widgets) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Network SerialBus Widgets) qt_add_executable(can bitratebox.cpp bitratebox.h @@ -30,10 +25,12 @@ qt_add_executable(can receivedframesmodel.cpp receivedframesmodel.h receivedframesview.cpp receivedframesview.h ) + set_target_properties(can PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) + target_link_libraries(can PUBLIC Qt::Core Qt::Gui @@ -42,7 +39,6 @@ target_link_libraries(can PUBLIC Qt::Widgets ) - # Resources: set(can_resource_files "images/application-exit.png" diff --git a/examples/serialbus/modbus/client/CMakeLists.txt b/examples/serialbus/modbus/client/CMakeLists.txt index 8f41540..7b025d6 100644 --- a/examples/serialbus/modbus/client/CMakeLists.txt +++ b/examples/serialbus/modbus/client/CMakeLists.txt @@ -1,23 +1,16 @@ cmake_minimum_required(VERSION 3.16) project(modbusclient 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}/serialbus/modbus/client") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Network) -find_package(Qt6 COMPONENTS SerialBus) -find_package(Qt6 COMPONENTS Widgets) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Network SerialBus Widgets) qt_add_executable(modbusclient main.cpp @@ -25,10 +18,12 @@ qt_add_executable(modbusclient settingsdialog.cpp settingsdialog.h settingsdialog.ui writeregistermodel.cpp writeregistermodel.h ) + set_target_properties(modbusclient PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) + target_link_libraries(modbusclient PUBLIC Qt::Core Qt::Gui @@ -37,7 +32,6 @@ target_link_libraries(modbusclient PUBLIC Qt::Widgets ) - # Resources: set(client_resource_files "images/application-exit.png" diff --git a/examples/serialbus/modbus/custom/CMakeLists.txt b/examples/serialbus/modbus/custom/CMakeLists.txt index 21c50ad..e9e676a 100644 --- a/examples/serialbus/modbus/custom/CMakeLists.txt +++ b/examples/serialbus/modbus/custom/CMakeLists.txt @@ -1,23 +1,16 @@ cmake_minimum_required(VERSION 3.16) project(customcommand 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}/serialbus/modbus/custom") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Network) -find_package(Qt6 COMPONENTS SerialBus) -find_package(Qt6 COMPONENTS Widgets) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Network SerialBus Widgets) qt_add_executable(customcommand main.cpp diff --git a/examples/serialbus/modbus/server/CMakeLists.txt b/examples/serialbus/modbus/server/CMakeLists.txt index e8dc5eb..9bffef3 100644 --- a/examples/serialbus/modbus/server/CMakeLists.txt +++ b/examples/serialbus/modbus/server/CMakeLists.txt @@ -1,33 +1,28 @@ cmake_minimum_required(VERSION 3.16) project(modbusserver 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}/serialbus/modbus/server") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Network) -find_package(Qt6 COMPONENTS SerialBus) -find_package(Qt6 COMPONENTS Widgets) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Network SerialBus Widgets) qt_add_executable(modbusserver main.cpp mainwindow.cpp mainwindow.h mainwindow.ui settingsdialog.cpp settingsdialog.h settingsdialog.ui ) + set_target_properties(modbusserver PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) + target_link_libraries(modbusserver PUBLIC Qt::Core Qt::Gui @@ -36,7 +31,6 @@ target_link_libraries(modbusserver PUBLIC Qt::Widgets ) - # Resources: set(server_resource_files "images/application-exit.png" |