Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
20qt_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
32This command simplifies the task of setting up a typical Qt application.
33It would usually be called immediately after the first \c{find_package(Qt6)}
34call, normally in the top level \c{CMakeLists.txt} file and before any targets
35have been defined. It does the following things:
36
37\list
38\li The standard CMake variables \c{CMAKE_AUTOMOC} and \c{CMAKE_AUTOUIC}
39 are set to true if they are not already defined.
40 This enables all Qt-related autogen features by default for subsequently
41 created targets in the current directory scope and below.
42\li CMake's \l{GNUInstallDirs} module is automatically included. This defines
43 appropriate defaults for variables like \c{CMAKE_INSTALL_BINDIR},
44 \c{CMAKE_INSTALL_LIBDIR}, and so on.
45\li When targeting Windows, if the \c{CMAKE_RUNTIME_OUTPUT_DIRECTORY} variable
46 is not already set, it will be set to
47 \c{${CMAKE_CURRENT_BINARY_DIR}}.
48\li When target platforms other than Apple or Windows, \c{CMAKE_INSTALL_RPATH}
49 will be augmented as described below.
50\li CMake's \l USE_FOLDERS property is set to \c{ON}, and \l QT_TARGETS_FOLDER is
51 set to \c{QtInternalTargets}. IDEs that support folders will display
52 Qt-internal targets in this folder.
53\endlist
54
55Since Qt 6.5, it is possible to change the default behavior of Qt's CMake
56API by opting in to changes from newer Qt versions. If \c{REQUIRES} is
57specified, all suggested changes introduced in Qt up to \c{REQUIRES} are enabled,
58and using an older Qt version will result in an error.
59If additionally \c{SUPPORTS_UP_TO} has been specified, any new changes introduced
60in versions up to \c{SUPPORTS_UP_TO} are also enabled (but using an older Qt
61version is not an error). This is similar to CMake's policy concept
62(compare \l{cmake_policy}).
63
64On platforms that support \c{RPATH} (other than Apple platforms), two values
65are appended to the \c{CMAKE_INSTALL_RPATH} variable by this command.
66\c{$ORIGIN} is appended so that libraries will find other libraries they depend
67on in the same directory as themselves. \c{$ORIGIN/<reldir>} is also appended,
68where \c{<reldir>} is the relative path from \c{CMAKE_INSTALL_BINDIR} to
69\c{CMAKE_INSTALL_LIBDIR}. This allows executables installed to
70\c{CMAKE_INSTALL_BINDIR} to find any libraries they may depend on installed to
71\c{CMAKE_INSTALL_LIBDIR}. Any duplicates in \c{CMAKE_INSTALL_RPATH} are
72removed. In practice, these two values ensure that executables and libraries
73will find their link-time dependencies, assuming projects install them to the
74default locations the \l{install(TARGETS)} command uses when no destination is
75explicitly provided.
76
77To disable folder support for IDEs, set \l USE_FOLDERS to \c OFF before or after
78the call to \c{qt_standard_project_setup}.
79
80The \c{qt_standard_project_setup()} command can effectively be disabled by
81setting the \l{QT_NO_STANDARD_PROJECT_SETUP} variable to true.
82
83\sa {qt6_generate_deploy_app_script}{qt_generate_deploy_app_script()}
84\sa qt_policy
85
86\section1 Internationalization
87
88Since Qt 6.7, it is possible to specify the languages that are used for project
89internationalization with the \c I18N_TRANSLATED_LANGUAGES argument. See \l
90QT_I18N_TRANSLATED_LANGUAGES for details.
91
92Use I18N_SOURCE_LANGUAGE to specify the language that translatable strings are
93written in. By default, \c en is used. See \l QT_I18N_SOURCE_LANGUAGE for
94details.
95
96\section1 Example
97
98\include cmake-generate-deploy-app-script.qdocinc
99
100\sa {Automatic Determination of .ts File Paths}{qt_add_translations()}
101*/