summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorKai Köhne <kai.koehne@qt.io>2022-02-17 13:32:39 +0100
committerKai Köhne <kai.koehne@qt.io>2022-02-17 15:08:18 +0100
commit3e1042310ed6e4f6c9fb81eb902f216c098cc26d (patch)
treec54c91294ca39528856e7f8784d04995941ea67b /examples
parent0f2c0a08f813ac1bbf3291f4eaf4938d195cb487 (diff)
Improve examples CMakeLists.txt
- Remove "# Generated from xyz.pro" 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: I3762fc4a17e5b8047ebdc721d0a9efffa163ba2d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/CMakeLists.txt2
-rw-r--r--examples/opcua/CMakeLists.txt2
-rw-r--r--examples/opcua/opcuaviewer/CMakeLists.txt14
-rw-r--r--examples/opcua/waterpump/CMakeLists.txt2
-rw-r--r--examples/opcua/waterpump/simulationserver/CMakeLists.txt26
-rw-r--r--examples/opcua/waterpump/waterpump-qml/CMakeLists.txt17
-rw-r--r--examples/opcua/waterpump/waterpump-qmlcpp/CMakeLists.txt18
-rw-r--r--examples/opcua/x509/CMakeLists.txt13
8 files changed, 24 insertions, 70 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 88d628b..5ddaa13 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(opcua)
diff --git a/examples/opcua/CMakeLists.txt b/examples/opcua/CMakeLists.txt
index cb8c012..0087e32 100644
--- a/examples/opcua/CMakeLists.txt
+++ b/examples/opcua/CMakeLists.txt
@@ -1,5 +1,3 @@
-# Generated from opcua.pro.
-
if(TARGET Qt::Widgets)
qt_internal_add_example(opcuaviewer)
endif()
diff --git a/examples/opcua/opcuaviewer/CMakeLists.txt b/examples/opcua/opcuaviewer/CMakeLists.txt
index 65a4397..509c42d 100644
--- a/examples/opcua/opcuaviewer/CMakeLists.txt
+++ b/examples/opcua/opcuaviewer/CMakeLists.txt
@@ -1,24 +1,16 @@
-# Generated from opcuaviewer.pro.
-
cmake_minimum_required(VERSION 3.16)
project(opcuaviewer 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}/opcua/opcuaviewer")
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS OpcUa)
-find_package(Qt6 COMPONENTS Widgets)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui OpcUa Widgets)
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/pki"
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
@@ -30,10 +22,12 @@ qt_add_executable(opcuaviewer
opcuamodel.cpp opcuamodel.h
treeitem.cpp treeitem.h
)
+
set_target_properties(opcuaviewer PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
+
target_link_libraries(opcuaviewer PUBLIC
Qt::Core
Qt::Gui
diff --git a/examples/opcua/waterpump/CMakeLists.txt b/examples/opcua/waterpump/CMakeLists.txt
index de9deff..0b765bb 100644
--- a/examples/opcua/waterpump/CMakeLists.txt
+++ b/examples/opcua/waterpump/CMakeLists.txt
@@ -1,5 +1,3 @@
-# Generated from waterpump.pro.
-
qt_internal_add_example(simulationserver)
qt_internal_add_example(waterpump-qmlcpp)
qt_internal_add_example(waterpump-qml)
diff --git a/examples/opcua/waterpump/simulationserver/CMakeLists.txt b/examples/opcua/waterpump/simulationserver/CMakeLists.txt
index 9e39033..25021aa 100644
--- a/examples/opcua/waterpump/simulationserver/CMakeLists.txt
+++ b/examples/opcua/waterpump/simulationserver/CMakeLists.txt
@@ -1,44 +1,36 @@
-# Generated from simulationserver.pro.
-
cmake_minimum_required(VERSION 3.16)
-project(simulationserver LANGUAGES CXX C) # special case
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+project(simulationserver LANGUAGES CXX C)
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}/opcua/waterpump/simulationserver")
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS OpcUa)
+find_package(Qt6 REQUIRED COMPONENTS Core OpcUa)
-# special case begin
if (EXISTS ../../../../../../../${QT_REPO_MODULE_VERSION}/Automation/sources/qtopcua/)
set(MODULE_SOURCE ../../../../../../../${QT_REPO_MODULE_VERSION}/Automation/sources/qtopcua/)
else()
set(MODULE_SOURCE ../../../../)
endif()
-# special case end
qt_add_executable(simulationserver
- ${MODULE_SOURCE}/src/plugins/opcua/open62541/qopen62541utils.cpp # special case
- ${MODULE_SOURCE}/src/plugins/opcua/open62541/qopen62541valueconverter.cpp # special case
+ ${MODULE_SOURCE}/src/plugins/opcua/open62541/qopen62541utils.cpp
+ ${MODULE_SOURCE}/src/plugins/opcua/open62541/qopen62541valueconverter.cpp
main.cpp
simulationserver.cpp simulationserver.h
)
+
set_target_properties(simulationserver PROPERTIES
WIN32_EXECUTABLE FALSE
MACOSX_BUNDLE TRUE
)
target_include_directories(simulationserver PUBLIC
- ${MODULE_SOURCE}/src/plugins/opcua/open62541 # special case
+ ${MODULE_SOURCE}/src/plugins/opcua/open62541
)
target_link_libraries(simulationserver PUBLIC
@@ -47,7 +39,6 @@ target_link_libraries(simulationserver PUBLIC
Qt::OpcUaPrivate
)
-# special case begin
if (QT_FEATURE_open62541 AND NOT QT_FEATURE_system_open62541)
target_sources(simulationserver PRIVATE
${MODULE_SOURCE}/src/3rdparty/open62541/open62541.h
@@ -65,7 +56,7 @@ endif()
qt_opcua_disable_optimizations_in_current_dir()
if (QT_FEATURE_open62541 AND NOT QT_FEATURE_system_open62541)
- if (NOT (WINRT OR WIN32 AND MSVC)) # special case
+ if (NOT (WINRT OR WIN32 AND MSVC))
set_source_files_properties(${MODULE_SOURCE}/src/3rdparty/open62541/open62541.c
PROPERTIES COMPILE_OPTIONS
"-Wno-unused-parameter;-Wno-unused-function;-Wno-format;-Wno-format-security;-Wno-strict-aliasing;-Wno-unused-result;-std=c99")
@@ -78,7 +69,6 @@ if (QT_FEATURE_open62541 AND NOT QT_FEATURE_system_open62541)
"/Zc:strictStrings-;/permissive;/wd2362")
endif()
endif()
-# special case end
if(QT_FEATURE_system_open62541 OR NOT QT_FEATURE_open62541)
target_link_libraries(simulationserver PRIVATE
diff --git a/examples/opcua/waterpump/waterpump-qml/CMakeLists.txt b/examples/opcua/waterpump/waterpump-qml/CMakeLists.txt
index 6f2500f..66531bc 100644
--- a/examples/opcua/waterpump/waterpump-qml/CMakeLists.txt
+++ b/examples/opcua/waterpump/waterpump-qml/CMakeLists.txt
@@ -1,38 +1,31 @@
-# Generated from waterpump-qml.pro.
-
cmake_minimum_required(VERSION 3.16)
project(waterpump-qml 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}/opcua/waterpump/waterpump-qml")
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Quick)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick)
qt_add_executable(waterpump-qml
main.cpp
)
+
set_target_properties(waterpump-qml PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
+
target_link_libraries(waterpump-qml PUBLIC
Qt::Core
Qt::Gui
Qt::Quick
)
-
# Resources:
set(qml_resource_files
"MachineDisplay.qml"
@@ -60,8 +53,6 @@ install(TARGETS waterpump-qml
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-# special case begin
if (WIN32)
target_compile_definitions(waterpump-qml PRIVATE EXAMPLES_CMAKE_SPECIFIC_PATH)
endif()
-# special case end
diff --git a/examples/opcua/waterpump/waterpump-qmlcpp/CMakeLists.txt b/examples/opcua/waterpump/waterpump-qmlcpp/CMakeLists.txt
index 670bc11..22f1140 100644
--- a/examples/opcua/waterpump/waterpump-qmlcpp/CMakeLists.txt
+++ b/examples/opcua/waterpump/waterpump-qmlcpp/CMakeLists.txt
@@ -1,33 +1,26 @@
-# Generated from waterpump-qmlcpp.pro.
-
cmake_minimum_required(VERSION 3.16)
project(waterpump-qmlcpp 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}/opcua/waterpump/waterpump-qmlcpp")
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Quick)
-find_package(Qt6 COMPONENTS OpcUa)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui OpcUa Quick)
qt_add_executable(waterpump-qmlcpp
main.cpp
opcuamachinebackend.cpp opcuamachinebackend.h
)
+
set_target_properties(waterpump-qmlcpp PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
+
target_link_libraries(waterpump-qmlcpp PUBLIC
Qt::Core
Qt::Gui
@@ -35,7 +28,6 @@ target_link_libraries(waterpump-qmlcpp PUBLIC
Qt::Quick
)
-
# Resources:
set(qml_resource_files
"Pump.qml"
@@ -61,8 +53,6 @@ install(TARGETS waterpump-qmlcpp
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-# special case begin
if (WIN32)
target_compile_definitions(waterpump-qmlcpp PRIVATE EXAMPLES_CMAKE_SPECIFIC_PATH)
endif()
-# special case end
diff --git a/examples/opcua/x509/CMakeLists.txt b/examples/opcua/x509/CMakeLists.txt
index 18799ec..f5645df 100644
--- a/examples/opcua/x509/CMakeLists.txt
+++ b/examples/opcua/x509/CMakeLists.txt
@@ -1,30 +1,25 @@
-# Generated from x509.pro.
-
cmake_minimum_required(VERSION 3.16)
project(x509 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}/opcua/x509")
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS OpcUa)
+find_package(Qt6 REQUIRED COMPONENTS Core OpcUa)
qt_add_executable(x509
main.cpp
)
+
set_target_properties(x509 PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
+
target_link_libraries(x509 PUBLIC
Qt::Core
Qt::OpcUa