qt_generate_deploy_script
Generate a custom deployment script.
The command is defined in the Core
component of the Qt6
package, which can be loaded like so:
find_package(Qt6 REQUIRED COMPONENTS Core)
This command was introduced in Qt 6.5.
Synopsis
qt_generate_deploy_script( OUTPUT_SCRIPT <var> [TARGET target] [NAME script_name] [CONTENT content] )
If versionless commands are disabled, use qt6_generate_deploy_script()
instead. It supports the same set of arguments as this command.
Description
The command generates a script whose full file path will be stored in the variable named by the OUTPUT_SCRIPT
option. That script is only written at CMake generation time. It is intended to be used with the install(SCRIPT) command, which should come after the application's target has been installed using install(TARGETS).
The command takes care of generating a file named suitably for multi-config generators. Necessary includes are added such that Qt's CMake deployment functions and variables are accessible.
The TARGET
argument specifies the target that will be deployed by the script. This affects the file name of the generated script, unless NAME
is specified.
The NAME
argument controls an identifiable portion within the deployment script's automatically generated name. The NAME
argument defaults to custom
if neither NAME
nor TARGET
are given.
The CONTENT
argument specifies the code that is written to the deployment script. The content may contain generator expressions.
This command is intended for generating custom deployment scripts that directly call functions of Qt's deployment API. For less complex deployment purposes, it is more convenient to use qt_generate_deploy_app_script() or qt_generate_deploy_qml_app_script().
Example
cmake_minimum_required(VERSION 3.16...3.22) project(MyThings) find_package(Qt6 REQUIRED COMPONENTS Core) qt_standard_project_setup() qt_add_executable(MyApp main.cpp) install(TARGETS MyApp BUNDLE DESTINATION . RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) qt_generate_deploy_script( TARGET MyApp OUTPUT_SCRIPT deploy_script CONTENT " qt_deploy_runtime_dependencies( EXECUTABLE $<TARGET_FILE_NAME:MyApp> ) ") install(SCRIPT ${deploy_script})
See also qt_generate_deploy_app_script() and qt_generate_deploy_qml_app_script().