1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
5\page qt-standard-project-setup.html
6\ingroup cmake-commands-qtcore
8\title qt_standard_project_setup
9\keyword qt6_standard_project_setup
11\summary {Setup project-wide defaults to a standard arrangement.}
13\include cmake-find-package-core.qdocinc
20qt_standard_project_setup(
22 [SUPPORTS_UP_TO <version>]
26\versionlessCMakeCommandsNote qt6_standard_project_setup()
30This command simplifies the task of setting up a typical Qt application.
31It would usually be called immediately after the first \c{find_package(Qt6)}
32call, normally in the top level \c{CMakeLists.txt} file and before any targets
33have been defined. It does the following things:
36\li The standard CMake variables \c{CMAKE_AUTOMOC} and \c{CMAKE_AUTOUIC}
37 are set to true if they are not already defined.
38 This enables all Qt-related autogen features by default for subsequently
39 created targets in the current directory scope and below.
40\li CMake's \l{GNUInstallDirs} module is automatically included. This defines
41 appropriate defaults for variables like \c{CMAKE_INSTALL_BINDIR},
42 \c{CMAKE_INSTALL_LIBDIR}, and so on.
43\li When targeting Windows, if the \c{CMAKE_RUNTIME_OUTPUT_DIRECTORY} variable
44 is not already set, it will be set to
45 \c{${CMAKE_CURRENT_BINARY_DIR}}.
46\li When target platforms other than Apple or Windows, \c{CMAKE_INSTALL_RPATH}
47 will be augmented as described below.
48\li CMake's \l USE_FOLDERS property is set to \c{ON}, and \l QT_TARGETS_FOLDER is
49 set to \c{QtInternalTargets}. IDEs that support folders will display
50 Qt-internal targets in this folder.
53Since Qt 6.5, it is possible to change the default behavior of Qt's CMake
54API by opting in to changes from newer Qt versions. If \c{REQUIRES} is
55specified, all suggested changes introduced in Qt up to \c{REQUIRES} are enabled,
56and using an older Qt version will result in an error.
57If additionally \c{SUPPORTS_UP_TO} has been specified, any new changes introduced
58in versions up to \c{SUPPORTS_UP_TO} are also enabled (but using an older Qt
59version is not an error). This is similar to CMake's policy concept
60(compare \l{cmake_policy}).
62On platforms that support \c{RPATH} (other than Apple platforms), two values
63are appended to the \c{CMAKE_INSTALL_RPATH} variable by this command.
64\c{$ORIGIN} is appended so that libraries will find other libraries they depend
65on in the same directory as themselves. \c{$ORIGIN/<reldir>} is also appended,
66where \c{<reldir>} is the relative path from \c{CMAKE_INSTALL_BINDIR} to
67\c{CMAKE_INSTALL_LIBDIR}. This allows executables installed to
68\c{CMAKE_INSTALL_BINDIR} to find any libraries they may depend on installed to
69\c{CMAKE_INSTALL_LIBDIR}. Any duplicates in \c{CMAKE_INSTALL_RPATH} are
70removed. In practice, these two values ensure that executables and libraries
71will find their link-time dependencies, assuming projects install them to the
72default locations the \l{install(TARGETS)} command uses when no destination is
75To disable folder support for IDEs, set \l USE_FOLDERS to \c OFF before or after
76the call to \c{qt_standard_project_setup}.
78The \c{qt_standard_project_setup()} command can effectively be disabled by
79setting the \l{QT_NO_STANDARD_PROJECT_SETUP} variable to true.
81\sa {qt6_generate_deploy_app_script}{qt_generate_deploy_app_script()}
86\include cmake-generate-deploy-app-script.qdocinc