Sur cette page

QT_DEPLOY_BIN_DIR

Sous-répertoire relatif au préfixe pour le déploiement des binaires d'exécution sur certaines plates-formes cibles.

Cette variable est définie par le script nommé par QT_DEPLOY_SUPPORT. Elle ne doit être utilisée que dans le cadre du déploiement lors de l'installation ou d'une règle de post-construction.

Note : Il s'agit d'une variable API de déploiement de bas niveau, et ne doit être utilisée que dans des cas d'utilisation avancés qui ne sont pas couverts par les commandes API de plus haut niveau, comme qt_generate_deploy_app_script.

Cette variable a été introduite dans Qt 6.3.

Les projets devraient utiliser QT_DEPLOY_BIN_DIR dans leurs scripts de déploiement pour éviter de coder en dur un répertoire particulier dans lequel déployer les types de binaires suivants :

  • Exécutables sur toutes les plateformes.
  • DLL sous Windows.

QT_DEPLOY_BIN_DIR La valeur par défaut de ${CMAKE_INSTALL_BINDIR} (habituellement bin) est fournie par le module GNUInstallDirs de CMake. Pour modifier la valeur de QT_DEPLOY_BIN_DIR, assurez-vous que le projet définit CMAKE_INSTALL_BINDIR avant que le paquetage Core ne soit trouvé.

Le chemin QT_DEPLOY_BIN_DIR est relatif à QT_DEPLOY_PREFIX.

Cette variable n'est pas significative lors d'un déploiement dans un bundle d'applications macOS et ne doit pas être utilisée pour ce scénario.

Exemple d'utilisation de QT_DELOY_PREFIX

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)

set_target_properties(MyApp PROPERTIES
    WIN32_EXECUTABLE TRUE
    MACOSX_BUNDLE TRUE
)

# App bundles on macOS have an .app suffix
if(APPLE)
    set(executable_path "$<TARGET_FILE_NAME:MyApp>.app")
else()
    set(executable_path "\${QT_DEPLOY_BIN_DIR}/$<TARGET_FILE_NAME:MyApp>")
endif()

# Helper app, not necessarily built as part of this project.
qt_add_executable(HelperApp helper.cpp)
set(helper_app_path "\${QT_DEPLOY_BIN_DIR}/$<TARGET_FILE_NAME:HelperApp>")

# Generate a deployment script to be executed at install time
qt_generate_deploy_script(
    TARGET MyApp
    OUTPUT_SCRIPT deploy_script
    CONTENT "
qt_deploy_runtime_dependencies(
    EXECUTABLE \"${executable_path}\"
    ADDITIONAL_EXECUTABLES \"${helper_app_path}\"
    GENERATE_QT_CONF
    VERBOSE
)")

# Omitting RUNTIME DESTINATION will install a non-bundle target to CMAKE_INSTALL_BINDIR,
# which coincides with the default value of QT_DEPLOY_BIN_DIR used above, './bin'.
# Installing macOS bundles always requires an explicit BUNDLE DESTINATION option.
install(TARGETS MyApp HelperApp    # Install to CMAKE_INSTALL_PREFIX/bin/MyApp.exe
                                   #                           and ./binHelperApp.exe
        BUNDLE  DESTINATION .      # Install to CMAKE_INSTALL_PREFIX/MyApp.app/Contents/MacOS/MyApp
)
install(SCRIPT ${deploy_script})    # Add its runtime dependencies

Voir aussi QT_DEPLOY_SUPPORT, QT_DEPLOY_PREFIX, QT_DEPLOY_LIBEXEC_DIR, QT_DEPLOY_LIB_DIR, QT_DEPLOY_PLUGINS_DIR, QT_DEPLOY_QML_DIR, et QT_DEPLOY_TRANSLATIONS_DIR.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.