summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/development/cmake-manual.qdoc8
-rw-r--r--doc/src/snippets/cmake/examples.cmake (renamed from doc/src/snippets/cmake/CMakeLists.pro)20
2 files changed, 13 insertions, 15 deletions
diff --git a/doc/src/development/cmake-manual.qdoc b/doc/src/development/cmake-manual.qdoc
index f0511eb80..6075c31cc 100644
--- a/doc/src/development/cmake-manual.qdoc
+++ b/doc/src/development/cmake-manual.qdoc
@@ -54,7 +54,7 @@
To build a helloworld GUI executable, typical usage would be:
- \snippet snippets/cmake/CMakeLists.pro 0
+ \snippet snippets/cmake/examples.cmake 0
In order for \c{find_package} to be successful, Qt 5 must be found below the CMAKE_PREFIX_PATH,
or the \c{Qt5_DIR} must be set in the \c{CMake} cache to the location of the
@@ -70,7 +70,7 @@
using a variable like Qt5<Module>_LIBRARIES in CMake commands such as \c{target_link_libraries}.
The actual path to the library can be obtained using the \l{CMake LOCATION Documentation}{LOCATION property}:
- \snippet snippets/cmake/CMakeLists.pro 1
+ \snippet snippets/cmake/examples.cmake 1
Note however that it is rare to require the full location to the library in \c{CMake} code. Most
\c{CMake} APIs are aware of imported targets and can automatically use them instead of the full path.
@@ -87,14 +87,14 @@
If your project has custom CMake build configurations, it may be necessary to set a mapping from your
custom configuration to either the debug or release Qt configuration.
- \snippet snippets/cmake/CMakeLists.pro 2
+ \snippet snippets/cmake/examples.cmake 2
Plugins are also available as \c IMPORTED targets in CMake. The \l{Qt
Network}, \l{Qt SQL}, \l{Qt GUI}, and \l{Qt Widgets} modules have plugins
associated. They provide a list of plugins in the
\c{Qt5}\e{<Module>}\c{_PLUGINS} variable.
- \snippet snippets/cmake/CMakeLists.pro 5
+ \snippet snippets/cmake/examples.cmake 5
\section1 Variable Reference
diff --git a/doc/src/snippets/cmake/CMakeLists.pro b/doc/src/snippets/cmake/examples.cmake
index 6f66cabf9..264f3c05d 100644
--- a/doc/src/snippets/cmake/CMakeLists.pro
+++ b/doc/src/snippets/cmake/examples.cmake
@@ -1,27 +1,25 @@
#! [0]
cmake_minimum_required(VERSION 3.1.0)
-project(testproject)
+project(helloworld)
-# Find includes in corresponding build directories
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)
-# Create code from a list of Qt designer ui files
+set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
-# Find the QtWidgets library
+if(CMAKE_VERSION VERSION_LESS "3.7.0")
+ set(CMAKE_INCLUDE_CURRENT_DIR ON)
+endif()
+
find_package(Qt5 COMPONENTS Widgets REQUIRED)
-# Populate a CMake variable with the sources
-set(helloworld_SRCS
+add_executable(helloworld
mainwindow.ui
mainwindow.cpp
main.cpp
+ resources.qrc
)
-# Tell CMake to create the helloworld executable
-add_executable(helloworld WIN32 ${helloworld_SRCS})
-# Use the Widgets module from Qt 5
+
target_link_libraries(helloworld Qt5::Widgets)
#! [0]