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 qt6_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
15Unlike most other CMake commands provided by Qt, \c{qt_deploy_runtime_dependencies()}
16can only be called from a deployment script. It cannot be called directly by the
17project 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
27qt_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
60When installing an application, it may be desirable to also install the
61libraries and plugins it depends on. When the application is a macOS app bundle
62or a Windows executable, \c{qt_deploy_runtime_dependencies()} can be called
63from an install-time script to deploy those dependencies. It will install
64non-system Qt libraries plus an appropriate set of Qt plugins.
65
66On Linux, the command will deploy additional libraries, beyond just those
67related to Qt, that are included with the project. However, when executed on
68macOS or Windows, the command will use either \c macdeployqt or \c windeployqt,
69which will only deploy libraries that are specific to Qt.
70
71This command only considers runtime dependencies for which linking
72relationships exist in the underlying binaries. It does not deploy QML modules,
73see \l{qt6_deploy_qml_imports}{qt_deploy_qml_imports()} for that.
74
75\section1 Arguments
76
77The \c{EXECUTABLE} option must be provided.
78
79The \c{executable} argument should be the path to the executable file in the
80build directory. For example, \c{${CMAKE_CURRENT_BINARY_DIR}/MyApp.exe}, or more
81dynamically \c{$<TARGET_FILE:MyApp>}. Specifying raw target names not wrapped in
82a generator expression like \c{$<TARGET_FILE:>} is not supported.
83
84For macOS app bundles, the \c{executable} argument should be a path to the
85bundle directory, relative to the base install location.
86For example \c{MyApp.app}, or more dynamically
87\c{$<TARGET_FILE_NAME:MyApp>.app}.
88Specifying raw target names not wrapped in a generator expression like
89\c{$<TARGET_FILE_NAME:>} is not supported.
90
91It may also be desirable to install dependencies for other binaries related to
92the \c{executable}. For example, plugins provided by the project might have
93further dependencies, but because those plugins won't be linked directly to the
94executable, \c{qt_deploy_runtime_dependencies()} won't automatically discover
95them. The \c{ADDITIONAL_EXECUTABLES}, \c{ADDITIONAL_LIBRARIES}, and
96\c{ADDITIONAL_MODULES} options can be used to specify additional binaries
97whose dependencies should also be deployed (installing the named binaries
98themselves is still the project's responsibility). The naming of these keywords
99follows CMake's conventions, so Qt plugins would be specified using
100\c{ADDITIONAL_MODULES}.
101Each value should be a path relative to the base install location. The values
102can use generator expressions, same as with the \c{EXECUTABLE} option.
103Specifying raw target names not wrapped in a generator expression like
104\c{$<TARGET_FILE_NAME:>} is not supported.
105
106When installing a Windows application, it is common to need a
107\l{Using qt.conf}{qt.conf} file when following CMake's default install
108directory structure. If the \c{GENERATE_QT_CONF} option is given, an appropriate
109\c{qt.conf} file will be written to the same directory as the \c{executable}.
110The paths in that \c{qt.conf} file will be based on the \c{CMAKE_INSTALL_xxxDIR}
111variables, whose defaults are provided by CMake's \l{GNUInstallDirs} module.
112
113You can override some of those defaults with the parameters in the following
114table, all of which are expected to be relative to the base install location.
115
116\table
117\header
118 \li parameter
119 \li affected variable
120 \li notes
121\row
122 \li \c BIN_DIR
123 \li \l QT_DEPLOY_BIN_DIR
124 \li
125\row
126 \li \c LIBEXEC_DIR
127 \li \l QT_DEPLOY_LIBEXEC_DIR
128 \li since Qt 6.7
129\row
130 \li \c LIB_DIR
131 \li \l QT_DEPLOY_LIB_DIR
132 \li
133\row
134 \li \c PLUGINS_DIR
135 \li \l QT_DEPLOY_PLUGINS_DIR
136 \li
137\row
138 \li \c QML_DIR
139 \li \l QT_DEPLOY_QML_DIR
140 \li
141\endtable
142
143A \c{qt.conf} file is always written if \c{executable} is a macOS app bundle,
144regardless of whether or not \c{GENERATE_QT_CONF} is provided. The \c{..._DIR}
145options are also ignored in that case, since the directory layout of an app
146bundle is dictated by Apple's requirements.
147
148More verbose output about the deployment steps can be enabled by providing the
149\c{VERBOSE} option. Alternatively, the \l{QT_ENABLE_VERBOSE_DEPLOYMENT}
150variable can be set in the project before the first \c{find_package(Qt6)} call
151to make deployment output verbose by default.
152
153The \c{qt_deploy_runtime_dependencies()} command overwrites existing files by
154default (some warnings may still be issued). Use the \c{NO_OVERWRITE} option
155to prevent overwriting existing files. Note that this option currently only
156affects macOS and Windows deployments.
157
158By default, if \c{executable} is a macOS app bundle, only Qt plugins and Qt
159libraries that comply with Apple's app store requirements are deployed. The
160\c{NO_APP_STORE_COMPLIANCE} option can be given to disable that constraint.
161
162On platforms other than macOS, Qt translations are automatically deployed. To
163inhibit this behavior, specify \c{NO_TRANSLATIONS}. Use
164\l{qt6_deploy_translations}{qt_deploy_translations()} to deploy translations
165in a customized way.
166
167For Windows desktop applications, the required runtime files for the compiler
168are also installed by default. To prevent this, specify \c{NO_COMPILER_RUNTIME}.
169
170Since Qt 6.7, you can use \c{DEPLOY_TOOL_OPTIONS} to pass additional options to
171the underlying deployment tool. This only has an effect if the underlying
172deployment tool is either macdeployqt or windeployqt.
173
174On Linux, deploying runtime dependencies is based on CMake's
175\c{file(GET_RUNTIME_DEPENDENCIES)} command. The options \c{PRE_INCLUDE_REGEXES},
176\c{PRE_EXCLUDE_REGEXES}, \c{POST_INCLUDE_REGEXES}, \c{POST_EXCLUDE_REGEXES},
177\c{POST_INCLUDE_FILES}, and \c{POST_EXCLUDE_FILES} are only meaningful in this
178context and are forwarded unaltered to \c{file(GET_RUNTIME_DEPENDENCIES)}. See
179the documentation of that command for details.
180
181On Linux, runtime dependencies that are located in system library directories
182are not deployed by default. If \c{POST_EXCLUDE_REGEXES} is specified, this
183automatic exclusion is not performed.
184
185The default value of \c{POST_EXCLUDE_REGEXES} is constructed from the value of
186\l{QT_DEPLOY_IGNORED_LIB_DIRS}.
187
188\sa {qt6_generate_deploy_app_script}{qt_generate_deploy_app_script()},
189 {qt6_deploy_qt_conf}{qt_deploy_qt_conf()},
190 {qt6_deploy_qml_imports}{qt_deploy_qml_imports()}
191
192\section1 Controlling deployment of Qt plugins
193
194Qt plugins are automatically deployed into \l QT_DEPLOY_PLUGINS_DIR.
195
196You can turn off plugin deployment with the \c NO_PLUGINS argument.
197
198You can include all plugins of a specific type with the \c INCLUDE_PLUGIN_TYPES
199argument. You can exclude all plugins of a specific type with the \c
200EXCLUDE_PLUGIN_TYPES argument. Both arguments take plugin types, e.g. \c
201imageformats.
202
203You can include or exclude specific plugins with the arguments \c
204INCLUDE_PLUGINS and \c EXCLUDE_PLUGINS. Both arguments take plugin names, for
205example \c qjpeg.
206
207\note Plugin names must not be confused with plugin targets. For example, the \c
208Qt6::QJpegPlugin target's plugin name is \c qjpeg.
209
210\note The arguments \c EXCLUDE_PLUGINS, \c EXCLUDE_PLUGIN_TYPES, \c
211INCLUDE_PLUGINS, and \c INCLUDE_PLUGIN_TYPES only work on Windows and Linux.
212
213\section1 Example
214
215The following example shows how to deploy an application \c{MyApp}.
216
217\include cmake-deploy-runtime-dependencies.qdocinc
218
219The following example shows how to use the \c{DEPLOY_TOOL_OPTIONS} parameter to
220pass different options to macdeployqt and windeployqt.
221
222\include cmake-deploy-runtime-dependencies-deploy-tool-options.qdocinc
223
224*/