In questa pagina

QT_DEPLOY_BIN_DIR

Sottodirectory relativa al prefisso per la distribuzione dei binari di runtime su alcune piattaforme di destinazione.

Questa variabile è definita dallo script indicato da QT_DEPLOY_SUPPORT. Deve essere utilizzata esclusivamente nell'ambito della distribuzione durante l'installazione o in una regola post-build.

Nota: si trattadi una variabile API di distribuzione di basso livello e dovrebbe essere utilizzata solo in casi d'uso avanzati non coperti dai comandi API di livello superiore, come qt_generate_deploy_app_script.

Questa variabile è stata introdotta in Qt 6.3.

I progetti dovrebbero utilizzare ` QT_DEPLOY_BIN_DIR ` nei propri script di distribuzione per evitare di specificare in modo fisso una directory particolare in cui distribuire i seguenti tipi di file binari:

  • Esecutabili su tutte le piattaforme.
  • DLL su Windows.

QT_DEPLOY_BIN_DIR Il valore predefinito è quello di ` ${CMAKE_INSTALL_BINDIR} ` (di solito ` bin`), fornito dal modulo GNUInstallDirs di CMake. Per modificare il valore di ` QT_DEPLOY_BIN_DIR`, assicurarsi che il progetto imposti ` CMAKE_INSTALL_BINDIR ` prima che venga individuato il pacchetto ` Core `.

Il percorso QT_DEPLOY_BIN_DIR è relativo a QT_DEPLOY_PREFIX.

Questa variabile non ha significato in caso di distribuzione in un bundle di app macOS e non dovrebbe essere utilizzata in tale scenario.

Esempio

cmake_minimum_required(VERSION 3.16...3.22)
project(MyThings)

find_package(Qt6 REQUIRED COMPONENTS Core)
qt_standard_project_setup()

# Keep the QT_DEPLOY_* references below for the generated script to expand,
# see \l {QTP0008}.
qt_policy(SET QTP0008 NEW)

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

Vedi anche QT_DEPLOY_SUPPORT, QT_DEPLOY_PREFIX, QT_DEPLOY_LIBEXEC_DIR, QT_DEPLOY_LIB_DIR, QT_DEPLOY_PLUGINS_DIR, QT_DEPLOY_QML_DIR e 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.