- Qt 6.4
- Qt Core
- CMake Commands in Qt6 Core
- qt_generate_deploy_app_script
- Qt 6.4.3 Reference Documentation

# qt_generate_deploy_app_script

Generate a deployment script for an application.

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.3.

Note: This command is in technology preview and may change in future releases.

Note: This command is currently only supported on Windows and macOS.

## Synopsis

     qt_generate_deploy_app_script(
         TARGET target
         FILENAME_VARIABLE var_name
         [NO_UNSUPPORTED_PLATFORM_ERROR]
     )

If versionless commands are disabled, use `qt6_generate_deploy_app_script()` instead. It supports the same set of arguments as this command.

## Description

Installing an executable target with install(TARGETS) only installs the target's executable (except for macOS app bundles, which will copy the whole bundle). You need to explicitly install any other libraries or plugins the executable depends on yourself. `qt_generate_deploy_app_script()` is a convenience command intended to simplify that process. It expects the application to follow Qt's recommended install directory structure fairly closely. That structure is based on CMake's default install layout, as determined by GNUInstallDirs (except for macOS app bundles, which follow Apple's requirements instead).

The command generates a script whose name will be stored in the variable named by the `FILENAME_VARIABLE` 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 deployment script will call qt_deploy_runtime_dependencies() with a suitable set of options for the standard install layout. Currently, this is only implemented for macOS app bundles built on a macOS host and Windows executables built on a Windows host. Cross-building a Windows executable on a Linux host, as well as similar scenarios, are not currently supported. Calling `qt_generate_deploy_app_script()` in such a case will result in a fatal error, unless the `NO_UNSUPPORTED_PLATFORM_ERROR` option is given.

For deploying a QML application, use qt_generate_deploy_qml_app_script() instead.

## 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_app_script(
         TARGET MyApp
         FILENAME_VARIABLE deploy_script
         NO_UNSUPPORTED_PLATFORM_ERROR
     )
     install(SCRIPT ${deploy_script})

See also qt_standard_project_setup() and qt_generate_deploy_qml_app_script().