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_generate_deploy_app_script.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-generate-deploy-app-script.html
6\ingroup cmake-commands-qtcore
7
8\title qt_generate_deploy_app_script
9\keyword qt_generate_deploy_app_script()
10
11\summary {Generate a deployment script for an application.}
12
13\include cmake-find-package-core.qdocinc
14
15\cmakecommandsince 6.3
16\note This command is currently only supported on Windows, macOS, and Linux.
17
18\section1 Synopsis
19
20\badcode
21qt_generate_deploy_app_script(
22 TARGET target
23 OUTPUT_SCRIPT <var>
24 [NO_TRANSLATIONS]
25 [NO_COMPILER_RUNTIME]
26 [NO_UNSUPPORTED_PLATFORM_ERROR]
27 [NO_APP_STORE_COMPLIANCE] # since Qt 6.13
28 [NO_PLUGINS] # since Qt 6.10
29 [EXCLUDE_PLUGIN_TYPES type_or_target...] # since Qt 6.10
30 [INCLUDE_PLUGIN_TYPES type_or_target...] # since Qt 6.10
31 [EXCLUDE_PLUGINS name...] # since Qt 6.10
32 [INCLUDE_PLUGINS name...] # since Qt 6.10
33 [DEPLOY_TOOL_OPTIONS ...]
34 [PRE_INCLUDE_REGEXES regexes...]
35 [PRE_EXCLUDE_REGEXES regexes...]
36 [POST_INCLUDE_REGEXES regexes...]
37 [POST_EXCLUDE_REGEXES regexes...]
38 [POST_INCLUDE_FILES files...]
39 [POST_EXCLUDE_FILES files...]
40)
41\endcode
42
43\versionlessCMakeCommandsNote qt6_generate_deploy_app_script()
44
45\section1 Description
46
47Installing an executable target with \l{install(TARGETS)} only installs the
48target's executable (except for macOS app bundles, which will copy the whole
49bundle). You need to explicitly install any other libraries or plugins the
50executable depends on yourself. \c{qt_generate_deploy_app_script()} is a
51convenience command intended to simplify that process. It expects the
52application to follow Qt's recommended install directory structure fairly
53closely. That structure is based on CMake's default install layout, as
54determined by \l{GNUInstallDirs} (except for macOS app bundles, which follow
55Apple's requirements instead).
56
57The command generates a script whose name will be stored in the variable named
58by the \c{OUTPUT_SCRIPT} option. That script is only written at CMake
59generation time. It is intended to be used with the \l{install(SCRIPT)} command,
60which should come after the application's target has been installed using
61\l{install(TARGETS)}.
62
63The deployment script will call \l qt_deploy_runtime_dependencies()
64with a suitable set of options for the standard
65install layout. Currently, this is only implemented for
66\list
67 \li macOS app bundles built on a macOS host,
68 \li Linux executables built on a Linux host,
69 \li and Windows executables built on a Windows host.
70\endlist
71Cross-building a Windows executable on a Linux host, as well as similar
72scenarios, are not currently supported.
73Calling \c{qt_generate_deploy_app_script()} in such a case will result
74in a fatal error, unless the \c{NO_UNSUPPORTED_PLATFORM_ERROR} option is given.
75
76On platforms other than macOS, Qt translations are automatically deployed. To
77inhibit this behavior, specify \c{NO_TRANSLATIONS}. Use
78\l qt_deploy_translations() to deploy translations in a
79customized way.
80
81For Windows desktop applications, the required runtime files for the compiler
82are also installed by default. To prevent this, specify \c{NO_COMPILER_RUNTIME}.
83
84For macOS app bundles, only Qt plugins and Qt libraries that comply with
85Apple's app store requirements are deployed by default. Since Qt 6.13, the
86\c{NO_APP_STORE_COMPLIANCE} option can be given to disable that constraint.
87
88Since Qt 6.7, you can use \c{DEPLOY_TOOL_OPTIONS} to pass additional options to
89the underlying deployment tool. This only has an effect if the underlying
90deployment tool is either macdeployqt or windeployqt.
91
92\note A value that contains whitespace, like a code signing identity, only reaches
93the deployment tool unchanged if \l {QTP0007} is set to \c NEW. With the \c OLD
94behavior, such a value is written to the generated script unquoted and gets split
95at whitespace, which projects used to work around by adding another level of
96quoting. Remove that extra quoting when setting the policy to \c NEW.
97
98\note The version-less \c qt_generate_deploy_app_script() forwards its arguments
99through either a function or a macro depending on the value of \l {QTP0008}.
100With the \c OLD behavior a value that contains a backslash or a \c{${var}}
101reference is evaluated at macro expansion time, so a regex like
102\c{foo\\.dylib} loses a level of escaping.
103This affects \c{DEPLOY_TOOL_OPTIONS} and the regex and file list arguments.
104Calling \c qt6_generate_deploy_app_script() directly avoids this issue.
105
106For deploying a QML application, use
107\l qt_generate_deploy_qml_app_script()
108instead.
109
110For generating a custom deployment script, use
111\l qt_generate_deploy_script().
112
113The options \c{PRE_INCLUDE_REGEXES}, \c{PRE_EXCLUDE_REGEXES},
114\c{POST_INCLUDE_REGEXES}, \c{POST_EXCLUDE_REGEXES}, \c{POST_INCLUDE_FILES}, and
115\c{POST_EXCLUDE_FILES} can be specified to control the deployment of runtime
116dependencies. These options do not apply to all platforms and are forwarded
117unmodified to \l qt_deploy_runtime_dependencies().
118
119The options \c EXCLUDE_PLUGINS, \c EXCLUDE_PLUGIN_TYPES, \c INCLUDE_PLUGINS, and
120\c INCLUDE_PLUGIN_TYPES are used to select Qt plugins. See
121\l qt_deploy_runtime_dependencies() for their
122documentation.
123
124You can turn off plugin deployment altogether with the \c NO_PLUGINS option.
125
126\sa qt_standard_project_setup(),
127 qt_generate_deploy_script(),
128 qt_generate_deploy_qml_app_script(),
129 {QTP0007},
130 {QTP0008}
131
132\section1 Example
133
134The following example shows how to deploy an application \c{MyApp}.
135
136\include cmake-generate-deploy-app-script.qdocinc
137
138The following example shows how to use the \c{DEPLOY_TOOL_OPTIONS} parameter to
139pass different options to macdeployqt and windeployqt.
140
141\include cmake-generate-deploy-app-script-deploy-tool-options.qdocinc
142
143*/