Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qt_standard_project_setup.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2021 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\page qt-standard-project-setup.html
6
\ingroup cmake-commands-qtcore
7
8
\title qt_standard_project_setup
9
\keyword qt6_standard_project_setup
10
11
\summary {Setup project-wide defaults to a standard arrangement.}
12
13
\include cmake-find-package-core.qdocinc
14
15
\cmakecommandsince 6.3
16
17
\section1 Synopsis
18
19
\badcode
20
qt_standard_project_setup(
21
[REQUIRES <version>]
22
[SUPPORTS_UP_TO <version>]
23
[I18N_TRANSLATED_LANGUAGES <language...>]
24
[I18N_SOURCE_LANGUAGE <language>]
25
)
26
\endcode
27
28
\versionlessCMakeCommandsNote qt6_standard_project_setup()
29
30
\section1 Description
31
32
This command simplifies the task of setting up a typical Qt application.
33
It would usually be called immediately after the first \c{find_package(Qt6)}
34
call, normally in the top level \c{CMakeLists.txt} file and before any targets
35
have been defined. If you call it later, it does not apply to any targets
36
defined before, with possibly confusing results. It does the following things:
37
38
\list
39
\li The standard CMake variables \c{CMAKE_AUTOMOC} and \c{CMAKE_AUTOUIC}
40
are set to true if they are not already defined.
41
This enables all Qt-related autogen features by default for subsequently
42
created targets in the current directory scope and below.
43
\li CMake's \l{GNUInstallDirs} module is automatically included. This defines
44
appropriate defaults for variables like \c{CMAKE_INSTALL_BINDIR},
45
\c{CMAKE_INSTALL_LIBDIR}, and so on.
46
\li When targeting Windows, if the \c{CMAKE_RUNTIME_OUTPUT_DIRECTORY} variable
47
is not already set, it will be set to
48
\c{${CMAKE_CURRENT_BINARY_DIR}}.
49
\li When target platforms other than Apple or Windows, \c{CMAKE_INSTALL_RPATH}
50
will be augmented as described below.
51
\li CMake's \l USE_FOLDERS property is set to \c{ON}, and \l QT_TARGETS_FOLDER is
52
set to \c{QtInternalTargets}. IDEs that support folders will display
53
Qt-internal targets in this folder.
54
\endlist
55
56
Since Qt 6.5, it is possible to change the default behavior of Qt's CMake
57
API by opting in to changes from newer Qt versions. If \c{REQUIRES} is
58
specified, all suggested changes introduced in Qt up to \c{REQUIRES} are enabled,
59
and using an older Qt version will result in an error.
60
If additionally \c{SUPPORTS_UP_TO} has been specified, any new changes introduced
61
in versions up to \c{SUPPORTS_UP_TO} are also enabled (but using an older Qt
62
version is not an error). This is similar to CMake's policy concept
63
(compare \l{cmake_policy}).
64
65
On platforms that support \c{RPATH} (other than Apple platforms), two values
66
are appended to the \c{CMAKE_INSTALL_RPATH} variable by this command.
67
\c{$ORIGIN} is appended so that libraries will find other libraries they depend
68
on in the same directory as themselves. \c{$ORIGIN/<reldir>} is also appended,
69
where \c{<reldir>} is the relative path from \c{CMAKE_INSTALL_BINDIR} to
70
\c{CMAKE_INSTALL_LIBDIR}. This allows executables installed to
71
\c{CMAKE_INSTALL_BINDIR} to find any libraries they may depend on installed to
72
\c{CMAKE_INSTALL_LIBDIR}. Any duplicates in \c{CMAKE_INSTALL_RPATH} are
73
removed. In practice, these two values ensure that executables and libraries
74
will find their link-time dependencies, assuming projects install them to the
75
default locations the \l{install(TARGETS)} command uses when no destination is
76
explicitly provided.
77
78
To disable folder support for IDEs, set \l USE_FOLDERS to \c OFF before or after
79
the call to \c{qt_standard_project_setup}.
80
81
The \c{qt_standard_project_setup()} command can effectively be disabled by
82
setting the \l{QT_NO_STANDARD_PROJECT_SETUP} variable to true.
83
84
\sa {qt6_generate_deploy_app_script}{qt_generate_deploy_app_script()}
85
\sa qt_policy
86
87
\section1 Internationalization
88
89
Since Qt 6.7, it is possible to specify the languages that are used for project
90
internationalization with the \c I18N_TRANSLATED_LANGUAGES argument. See \l
91
QT_I18N_TRANSLATED_LANGUAGES for details.
92
93
Use I18N_SOURCE_LANGUAGE to specify the language that translatable strings are
94
written in. By default, \c en is used. See \l QT_I18N_SOURCE_LANGUAGE for
95
details.
96
97
\section1 Example
98
99
\include cmake-generate-deploy-app-script.qdocinc
100
101
\sa {Automatic Determination of .ts File Paths}{qt_add_translations()}
102
*/
qtbase
src
corelib
doc
src
cmake
qt_standard_project_setup.qdoc
Generated on
for Qt by
1.14.0