summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Funk <kevin.funk@kdab.com>2017-07-27 13:02:52 +0200
committerKevin Funk <kevin.funk@kdab.com>2018-03-23 13:00:17 +0000
commit84a25f9ba4c74271f7d40d7684a1657db22c954b (patch)
tree5e7c3eaca63f8ecb26ffab1317612c82f9d69b66
parent78992b83012eb36644a1da4affdede8baac9d2b5 (diff)
CMake: Improve CMake template in manual
Include notes about how to work with .ui files using CMake's AUTOUIC feature. Use CMake 3.1 as minimum required CMake version as this is required since 5.10 anyway. Also note that CMAKE_AUTOUIC requires CMake >= v3.0.0. Task-number: QTBUG-59202 Task-number: QTBUG-63519 Change-Id: I0a0814c6dda6746f399b1c883932751e44993ebc Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
-rw-r--r--doc/src/snippets/cmake/CMakeLists.pro19
1 files changed, 13 insertions, 6 deletions
diff --git a/doc/src/snippets/cmake/CMakeLists.pro b/doc/src/snippets/cmake/CMakeLists.pro
index 5883924c4..b20183421 100644
--- a/doc/src/snippets/cmake/CMakeLists.pro
+++ b/doc/src/snippets/cmake/CMakeLists.pro
@@ -5,16 +5,23 @@ project(testproject)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
-# Instruct CMake to run moc automatically when needed.
+# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)
+# Create code from a list of Qt designer ui files
+set(CMAKE_AUTOUIC ON)
# Find the QtWidgets library
-find_package(Qt5Widgets)
-
+find_package(Qt5Widgets CONFIG REQUIRED)
+
+# Populate a CMake variable with the sources
+set(helloworld_SRCS
+ mainwindow.ui
+ mainwindow.cpp
+ main.cpp
+)
# Tell CMake to create the helloworld executable
-add_executable(helloworld WIN32 main.cpp)
-
-# Use the Widgets module from Qt 5.
+add_executable(helloworld WIN32 ${helloworld_SRCS})
+# Use the Widgets module from Qt 5
target_link_libraries(helloworld Qt5::Widgets)
#! [0]