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
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. If you call it later, it does not apply to any targets
36defined 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
56Since Qt 6.5, it is possible to change the default behavior of Qt's CMake
57API by opting in to behavior changes from newer Qt versions via
58\l{Qt CMake policies}. This is similar to CMake's own policy concept
59(compare \l{cmake_policy}). If \c{REQUIRES} is specified, all policies
60introduced in Qt versions up to and including \c{REQUIRES} are automatically
61set to \c{NEW}, and using an older Qt version will result in an error.
62For example, specifying \c{REQUIRES 6.8} enables policies QTP0001 through
63QTP0005. If \c{SUPPORTS_UP_TO} is also specified, policies up to that version
64are enabled as well, but without requiring that particular Qt version to be
65present.
66
67The following policies are available:
68
69\annotatedlist qt-cmake-policies
70
71See \l{qt_policy} for details on manually setting individual policies.
72
73On platforms that support \c{RPATH} (other than Apple platforms), two values
74are appended to the \c{CMAKE_INSTALL_RPATH} variable by this command.
75\c{$ORIGIN} is appended so that libraries will find other libraries they depend
76on in the same directory as themselves. \c{$ORIGIN/<reldir>} is also appended,
77where \c{<reldir>} is the relative path from \c{CMAKE_INSTALL_BINDIR} to
78\c{CMAKE_INSTALL_LIBDIR}. This allows executables installed to
79\c{CMAKE_INSTALL_BINDIR} to find any libraries they may depend on installed to
80\c{CMAKE_INSTALL_LIBDIR}. Any duplicates in \c{CMAKE_INSTALL_RPATH} are
81removed. In practice, these two values ensure that executables and libraries
82will find their link-time dependencies, assuming projects install them to the
83default locations the \l{install(TARGETS)} command uses when no destination is
84explicitly provided.
85
86To disable folder support for IDEs, set \l USE_FOLDERS to \c OFF before or after
87the call to \c{qt_standard_project_setup}.
88
89The \c{qt_standard_project_setup()} command can effectively be disabled by
90setting the \l{QT_NO_STANDARD_PROJECT_SETUP} variable to true.
91
92\sa {qt6_generate_deploy_app_script}{qt_generate_deploy_app_script()}
93\sa qt_policy
94
95\section1 Internationalization
96
97Since Qt 6.7, it is possible to specify the languages that are used for project
98internationalization with the \c I18N_TRANSLATED_LANGUAGES argument. See \l
99QT_I18N_TRANSLATED_LANGUAGES for details.
100
101Use I18N_SOURCE_LANGUAGE to specify the language that translatable strings are
102written in. By default, \c en is used. See \l QT_I18N_SOURCE_LANGUAGE for
103details.
104
105\section1 Example
106
107\include cmake-generate-deploy-app-script.qdocinc
108
109\sa {Automatic Determination of .ts File Paths}{qt_add_translations()}
110*/