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_deploy_runtime_dependencies.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-deploy-runtime-dependencies.html
6
\ingroup cmake-commands-qtcore
7
8
\title qt_deploy_runtime_dependencies
9
\keyword qt_deploy_runtime_dependencies()
10
11
\summary {Deploy Qt plugins, Qt and non-Qt libraries needed by an executable.}
12
13
\include cmake-find-package-core.qdocinc
14
15
Unlike most other CMake commands provided by Qt, \c{qt_deploy_runtime_dependencies()}
16
can only be called from a deployment script. It cannot be called directly by the
17
project during the configure stage.
18
19
\cmakecommandsince 6.3
20
\note This command does not usually need to be called directly. It is used
21
internally by other higher level commands, but projects wishing to
22
implement more customized deployment logic may find it useful.
23
24
\section1 Synopsis
25
26
\badcode
27
qt_deploy_runtime_dependencies(
28
EXECUTABLE executable
29
[ADDITIONAL_EXECUTABLES files...]
30
[ADDITIONAL_LIBRARIES files...]
31
[ADDITIONAL_MODULES files...]
32
[GENERATE_QT_CONF]
33
[BIN_DIR bin_dir]
34
[LIBEXEC_DIR libexec_dir]
35
[LIB_DIR lib_dir]
36
[PLUGINS_DIR plugins_dir]
37
[QML_DIR qml_dir]
38
[VERBOSE]
39
[NO_OVERWRITE]
40
[NO_APP_STORE_COMPLIANCE]
41
[NO_PLUGINS] # since Qt 6.10
42
[EXCLUDE_PLUGIN_TYPES type...] # since Qt 6.10
43
[INCLUDE_PLUGIN_TYPES type...] # since Qt 6.10
44
[EXCLUDE_PLUGINS name...] # since Qt 6.10
45
[INCLUDE_PLUGINS name...] # since Qt 6.10
46
[NO_TRANSLATIONS]
47
[NO_COMPILER_RUNTIME]
48
[DEPLOY_TOOL_OPTIONS]
49
[PRE_INCLUDE_REGEXES regexes...]
50
[PRE_EXCLUDE_REGEXES regexes...]
51
[POST_INCLUDE_REGEXES regexes...]
52
[POST_EXCLUDE_REGEXES regexes...]
53
[POST_INCLUDE_FILES files...]
54
[POST_EXCLUDE_FILES files...]
55
)
56
\endcode
57
58
\section1 Description
59
60
When installing an application, it may be desirable to also install the
61
libraries and plugins it depends on. When the application is a macOS app bundle
62
or a Windows executable, \c{qt_deploy_runtime_dependencies()} can be called
63
from an install-time script to deploy those dependencies. It will install
64
non-system Qt libraries plus an appropriate set of Qt plugins.
65
66
On Linux, the command will deploy additional libraries, beyond just those
67
related to Qt, that are included with the project. However, when executed on
68
macOS or Windows, the command will use either \c macdeployqt or \c windeployqt.
69
\c macdeployqt only deploys libraries that are specific to Qt. \c windeployqt
70
additionally deploys the non-Qt libraries that the deployed binaries link
71
against, if those libraries are located in the Qt binary directory.
72
73
This command only considers runtime dependencies for which linking
74
relationships exist in the underlying binaries. It does not deploy QML modules,
75
see \l qt_deploy_qml_imports() for that.
76
77
\section1 Arguments
78
79
The \c{EXECUTABLE} option must be provided.
80
81
The \c{executable} argument should be the path to the executable file in the
82
build directory. For example, \c{${CMAKE_CURRENT_BINARY_DIR}/MyApp.exe}, or more
83
dynamically \c{$<TARGET_FILE:MyApp>}. Specifying raw target names not wrapped in
84
a generator expression like \c{$<TARGET_FILE:>} is not supported.
85
86
For macOS app bundles, the \c{executable} argument should be a path to the
87
bundle directory, relative to the base install location.
88
For example \c{MyApp.app}, or more dynamically
89
\c{$<TARGET_FILE_NAME:MyApp>.app}.
90
Specifying raw target names not wrapped in a generator expression like
91
\c{$<TARGET_FILE_NAME:>} is not supported.
92
93
It may also be desirable to install dependencies for other binaries related to
94
the \c{executable}. For example, plugins provided by the project might have
95
further dependencies, but because those plugins won't be linked directly to the
96
executable, \c{qt_deploy_runtime_dependencies()} won't automatically discover
97
them. The \c{ADDITIONAL_EXECUTABLES}, \c{ADDITIONAL_LIBRARIES}, and
98
\c{ADDITIONAL_MODULES} options can be used to specify additional binaries
99
whose dependencies should also be deployed (installing the named binaries
100
themselves is still the project's responsibility). The naming of these keywords
101
follows CMake's conventions, so Qt plugins would be specified using
102
\c{ADDITIONAL_MODULES}.
103
Each value should be a path relative to the base install location. The values
104
can use generator expressions, same as with the \c{EXECUTABLE} option.
105
Specifying raw target names not wrapped in a generator expression like
106
\c{$<TARGET_FILE_NAME:>} is not supported.
107
108
When installing a Windows application, it is common to need a
109
\l{Using qt.conf}{qt.conf} file when following CMake's default install
110
directory structure. If the \c{GENERATE_QT_CONF} option is given, an appropriate
111
\c{qt.conf} file will be written to the same directory as the \c{executable}.
112
The paths in that \c{qt.conf} file will be based on the \c{CMAKE_INSTALL_xxxDIR}
113
variables, whose defaults are provided by CMake's \l{GNUInstallDirs} module.
114
115
You can override some of those defaults with the parameters in the following
116
table, all of which are expected to be relative to the base install location.
117
118
\table
119
\header
120
\li parameter
121
\li affected variable
122
\li notes
123
\row
124
\li \c BIN_DIR
125
\li \l QT_DEPLOY_BIN_DIR
126
\li
127
\row
128
\li \c LIBEXEC_DIR
129
\li \l QT_DEPLOY_LIBEXEC_DIR
130
\li since Qt 6.7
131
\row
132
\li \c LIB_DIR
133
\li \l QT_DEPLOY_LIB_DIR
134
\li
135
\row
136
\li \c PLUGINS_DIR
137
\li \l QT_DEPLOY_PLUGINS_DIR
138
\li
139
\row
140
\li \c QML_DIR
141
\li \l QT_DEPLOY_QML_DIR
142
\li
143
\endtable
144
145
No \c{qt.conf} file is written if \c{executable} is a macOS app bundle, and
146
both \c{GENERATE_QT_CONF} and the \c{..._DIR} options are ignored in that
147
case. The directory layout of an app bundle is dictated by Apple's
148
requirements, and Qt finds libraries, plugins and resources at those
149
conventional locations without a \c{qt.conf}.
150
151
More verbose output about the deployment steps can be enabled by providing the
152
\c{VERBOSE} option. Alternatively, the \l{QT_ENABLE_VERBOSE_DEPLOYMENT}
153
variable can be set in the project before the first \c{find_package(Qt6)} call
154
to make deployment output verbose by default.
155
156
The \c{qt_deploy_runtime_dependencies()} command overwrites existing files by
157
default (some warnings may still be issued). Use the \c{NO_OVERWRITE} option
158
to prevent overwriting existing files. Note that this option currently only
159
affects macOS and Windows deployments.
160
161
By default, if \c{executable} is a macOS app bundle, only Qt plugins and Qt
162
libraries that comply with Apple's app store requirements are deployed. The
163
\c{NO_APP_STORE_COMPLIANCE} option can be given to disable that constraint.
164
165
On platforms other than macOS, Qt translations are automatically deployed. To
166
inhibit this behavior, specify \c{NO_TRANSLATIONS}. Use
167
\l qt_deploy_translations() to deploy translations
168
in a customized way.
169
170
For Windows desktop applications, the required runtime files for the compiler
171
are also installed by default. To prevent this, specify \c{NO_COMPILER_RUNTIME}.
172
173
Since Qt 6.7, you can use \c{DEPLOY_TOOL_OPTIONS} to pass additional options to
174
the underlying deployment tool. This only has an effect if the underlying
175
deployment tool is either macdeployqt or windeployqt.
176
177
\note When this command is called from the \c {CONTENT} of
178
\l qt_generate_deploy_script(), the values of \c{DEPLOY_TOOL_OPTIONS} should
179
be wrapped into a single quoted string so that whitespace is preserved in the
180
generated deployment script. Additionally, each value that contains a space,
181
like a code signing identity, should be wrapped in backslash escaped quotes.
182
183
On Linux, deploying runtime dependencies is based on CMake's
184
\c{file(GET_RUNTIME_DEPENDENCIES)} command. The options \c{PRE_INCLUDE_REGEXES},
185
\c{PRE_EXCLUDE_REGEXES}, \c{POST_INCLUDE_REGEXES}, \c{POST_EXCLUDE_REGEXES},
186
\c{POST_INCLUDE_FILES}, and \c{POST_EXCLUDE_FILES} are only meaningful in this
187
context and are forwarded unaltered to \c{file(GET_RUNTIME_DEPENDENCIES)}. See
188
the documentation of that command for details.
189
190
On Linux, runtime dependencies that are located in system library directories
191
are not deployed by default. If \c{POST_EXCLUDE_REGEXES} is specified, this
192
automatic exclusion is not performed.
193
194
The default value of \c{POST_EXCLUDE_REGEXES} is constructed from the value of
195
\l{QT_DEPLOY_IGNORED_LIB_DIRS}.
196
197
\sa qt_generate_deploy_app_script(),
198
qt_deploy_qt_conf(),
199
qt_deploy_qml_imports(),
200
{QTP0007}
201
202
\section1 Controlling deployment of Qt plugins
203
204
Qt plugins are automatically deployed into \l QT_DEPLOY_PLUGINS_DIR.
205
206
You can turn off plugin deployment with the \c NO_PLUGINS argument.
207
208
You can include all plugins of a specific type with the \c INCLUDE_PLUGIN_TYPES
209
argument. You can exclude all plugins of a specific type with the \c
210
EXCLUDE_PLUGIN_TYPES argument. Both arguments take plugin types, e.g. \c
211
imageformats.
212
213
You can include or exclude specific plugins with the arguments \c
214
INCLUDE_PLUGINS and \c EXCLUDE_PLUGINS. Both arguments take plugin names, for
215
example \c qjpeg.
216
217
\note Plugin names must not be confused with plugin targets. For example, the \c
218
Qt6::QJpegPlugin target's plugin name is \c qjpeg.
219
220
\note The arguments \c EXCLUDE_PLUGINS, \c EXCLUDE_PLUGIN_TYPES, \c
221
INCLUDE_PLUGINS, and \c INCLUDE_PLUGIN_TYPES only work on Windows and Linux.
222
223
\section1 Example
224
225
The following example shows how to deploy an application \c{MyApp}.
226
227
\include cmake-deploy-runtime-dependencies.qdocinc
228
229
The following example shows how to use the \c{DEPLOY_TOOL_OPTIONS} parameter to
230
pass different options to macdeployqt and windeployqt.
231
232
\include cmake-deploy-runtime-dependencies-deploy-tool-options.qdocinc
233
234
*/
qtbase
src
corelib
doc
src
cmake
qt_deploy_runtime_dependencies.qdoc
Generated on
for Qt by
1.16.1