summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc/src/cmake/qt_standard_project_setup.qdoc
blob: b94d688e4958cd60fe09e278cb4d30ce128b8fea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
\page qt_standard_project_setup.html
\ingroup cmake-commands-qtcore

\title qt_standard_project_setup
\target qt6_standard_project_setup

\summary {Setup project-wide defaults to a standard arrangement.}

\include cmake-find-package-core.qdocinc

\cmakecommandsince 6.3

\section1 Synopsis

\badcode
qt_standard_project_setup()
\endcode

\versionlessCMakeCommandsNote qt6_standard_project_setup()

\section1 Description

This command simplifies the task of setting up a typical Qt application.
It would usually be called immediately after the first \c{find_package(Qt6)}
call, normally in the top level \c{CMakeLists.txt} file and before any targets
have been defined. It does the following things:

\list
\li The standard CMake variables \c{CMAKE_AUTOMOC} and \c{CMAKE_AUTOUIC}
    are set to true if they are not already defined.
    This enables all Qt-related autogen features by default for subsequently
    created targets in the current directory scope and below.
\li CMake's \l{GNUInstallDirs} module is automatically included. This defines
    appropriate defaults for variables like \c{CMAKE_INSTALL_BINDIR},
    \c{CMAKE_INSTALL_LIBDIR}, and so on.
\li When targeting Windows, if the \c{CMAKE_RUNTIME_OUTPUT_DIRECTORY} variable
    is not already set, it will be set to
    \c{${CMAKE_CURRENT_BINARY_DIR}}.
\li When target platforms other than Apple or Windows, \c{CMAKE_INSTALL_RPATH}
    will be augmented as described below.
\endlist

On platforms that support \c{RPATH} (other than Apple platforms), two values
are appended to the \c{CMAKE_INSTALL_RPATH} variable by this command.
\c{$ORIGIN} is appended so that libraries will find other libraries they depend
on in the same directory as themselves. \c{$ORIGIN/<reldir>} is also appended,
where \c{<reldir>} is the relative path from \c{CMAKE_INSTALL_BINDIR} to
\c{CMAKE_INSTALL_LIBDIR}. This allows executables installed to
\c{CMAKE_INSTALL_BINDIR} to find any libraries they may depend on installed to
\c{CMAKE_INSTALL_LIBDIR}. Any duplicates in \c{CMAKE_INSTALL_RPATH} are
removed. In practice, these two values ensure that executables and libraries
will find their link-time dependencies, assuming projects install them to the
default locations the \l{install(TARGETS)} command uses when no destination is
explicitly provided.

The \c{qt_standard_project_setup()} command can effectively be disabled by
setting the \l{QT_NO_STANDARD_PROJECT_SETUP} variable to true.

\sa {qt6_generate_deploy_app_script}{qt_generate_deploy_app_script()}

\section1 Example

\include cmake-deploy-runtime-dependencies.qdocinc
*/