diff options
author | Leena Miettinen <riitta-leena.miettinen@qt.io> | 2023-04-25 08:50:35 +0200 |
---|---|---|
committer | Leena Miettinen <riitta-leena.miettinen@qt.io> | 2023-04-25 12:58:28 +0200 |
commit | 17d1e2597853aaafc328a512400ed41fde424d14 (patch) | |
tree | 171e50fe0862f2da095d0511d25b5bed02f7e5db | |
parent | 37283ea8cf6d5d78a36a27560f9c06dc1a6469f1 (diff) | |
download | qtdoc-17d1e2597853aaafc328a512400ed41fde424d14.tar.gz |
Doc: Use qt_add_executable() and qt_add_library()
...instead of add_executable() and add_library() in example code.
Task-number: QTBUG-113116
Pick-to: 6.5
Change-Id: Id4f1d75b89f56e56ffe309849f2b61954eb22955
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
4 files changed, 13 insertions, 14 deletions
diff --git a/doc/src/cmake/cmake-manual.qdoc b/doc/src/cmake/cmake-manual.qdoc index 4e7f3bf9..be3d0520 100644 --- a/doc/src/cmake/cmake-manual.qdoc +++ b/doc/src/cmake/cmake-manual.qdoc @@ -165,21 +165,20 @@ \printuntil ) - \c{add_executable()} tells CMake that we want to build an executable (so not - a library) called \c{helloworld} as a target. The target should be built - from the C++ source file \c{main.cpp}. + \l{qt6_add_executable}{qt_add_executable()} tells CMake that we want to + build an executable (so not a library) called \c{helloworld} as a target. + It is a wrapper around the built-in \c add_executable() command, and + provides additional logic to automatically handle things like linking of + Qt plugins in static Qt builds, platform-specific customization of library + names, and so on. - Note that you typically do not list header files here. This is different + The target should be built from the C++ source file \c{main.cpp}. + + Typically, you do not list header files here. This is different from \l{qmake}, where header files need to be explicitly listed so that they are processed by the \l{Using the Meta-Object Compiler (moc)} {Meta-Object Compiler (moc)}. - For less trivial projects, you may want to call - \l{qt6_add_executable}{qt_add_executable()} instead. It is a wrapper around - the built-in \c add_executable() command, providing additional logic to - automatically handle things like linking of Qt plugins in static Qt builds, - platform-specific customization of library names and so on. - For creating libraries, see \l{qt6_add_library}{qt_add_library}. \printuntil @@ -296,7 +295,7 @@ executable target: \code - add_executable(helloworld + qt_add_executable(helloworld mainwindow.ui mainwindow.cpp main.cpp diff --git a/doc/src/cmake/snippets/cmake/helloworld_qtcore.cmake b/doc/src/cmake/snippets/cmake/helloworld_qtcore.cmake index ad16f33d..20412929 100644 --- a/doc/src/cmake/snippets/cmake/helloworld_qtcore.cmake +++ b/doc/src/cmake/snippets/cmake/helloworld_qtcore.cmake @@ -11,7 +11,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt6 REQUIRED COMPONENTS Core) qt_standard_project_setup() -add_executable(helloworld +qt_add_executable(helloworld main.cpp ) diff --git a/doc/src/cmake/snippets/cmake/helloworld_qtwidgets.cmake b/doc/src/cmake/snippets/cmake/helloworld_qtwidgets.cmake index fec5f682..562ff3b2 100644 --- a/doc/src/cmake/snippets/cmake/helloworld_qtwidgets.cmake +++ b/doc/src/cmake/snippets/cmake/helloworld_qtwidgets.cmake @@ -11,7 +11,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt6 REQUIRED COMPONENTS Widgets) qt_standard_project_setup() -add_executable(helloworld +qt_add_executable(helloworld mainwindow.ui mainwindow.cpp main.cpp diff --git a/doc/src/cmake/snippets/cmake/helloworld_src_businesslogic.cmake b/doc/src/cmake/snippets/cmake/helloworld_src_businesslogic.cmake index cd7384ac..f88ab7e5 100644 --- a/doc/src/cmake/snippets/cmake/helloworld_src_businesslogic.cmake +++ b/doc/src/cmake/snippets/cmake/helloworld_src_businesslogic.cmake @@ -1,7 +1,7 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -add_library(businesslogic STATIC +qt_add_library(businesslogic STATIC businesslogic.cpp ) target_link_libraries(businesslogic PRIVATE Qt6::Core) |