QT_DEPLOY_QML_IMPORTS

실행 파일에 필요한 QML 모듈의 런타임 컴포넌트를 배포합니다.

이 명령은 Qt6 패키지의 Qml 컴포넌트에 정의되어 있으며, 다음과 같이 로드할 수 있습니다:

find_package(Qt6 REQUIRED COMPONENTS Qml)

Qt에서 제공하는 대부분의 다른 CMake 명령과 달리 qt6_deploy_qml_imports 은 배포 스크립트에서만 호출할 수 있습니다. 프로젝트에서 직접 호출할 수 없습니다.

경고: 3.19 미만의 CMake 버전을 사용하는 경우, 이 함수를 호출하기 전에 qt6_add_executable()MANUAL_FINALIZATION 옵션을 전달한 다음 qt6_finalize_target()을 호출해야 합니다.

시놉시스

qt_deploy_qml_imports(
    TARGET target
    [QML_DIR qml_dir]
    [PLUGINS_FOUND var_name]
    [NO_QT_IMPORTS]
)

설명

참고: 이 명령은 일반적으로 직접 호출할 필요가 없습니다. 다른 상위 레벨 명령에서 내부적으로 사용되지만, 보다 사용자 정의된 배포 로직을 구현하려는 프로젝트에서는 유용할 수 있습니다.

QML을 사용하는 애플리케이션을 설치할 때 어떤 QML 모듈과 그 모듈의 어떤 부분도 설치해야 하는지 파악하는 것은 그리 간단하지 않을 수 있습니다. QML 플러그인은 애플리케이션의 실행 파일에 직접 링크되지 않기 때문에, qt_deploy_runtime_dependencies()는 이러한 QML 모듈을 찾지 못합니다. qt6_deploy_qml_imports 명령은 응용 프로그램에서 가져온 모든 QML 모듈의 런타임 부분을 배포하는 데 필요한 로직을 제공하여 qt_deploy_runtime_dependencies()를 보완합니다.

TARGET 옵션은 필수이며 실행 파일인 target (macOS의 경우 앱 번들)과 QML 모듈을 지정해야 합니다. qt_add_qml_module() 또는 qt_target_qml_sources()를 통해 target 에 추가된 모든 QML 소스는 재귀적으로 스캔되어 QML 임포트가 검색됩니다. NO_IMPORT_SCAN 옵션은 qt_add_qml_module()에 주어지지 않아야 합니다. 가져온 QML 모듈의 qmldir 파일과 플러그인이 배포됩니다. NO_QT_IMPORTS 옵션을 지정하면 Qt에서 제공하는 모든 QML 모듈의 배포를 건너뛸 수 있습니다.

기본적으로 가져온 QML 모듈의 런타임 부분은 macOS 앱 번들 대상의 경우 Resources/qml 디렉터리에, 다른 플랫폼의 경우 기본 설치 위치 아래의 qml 디렉터리에 배포됩니다. macOS가 아닌 경우 QML_DIR 옵션을 사용하여 이 기본 선택을 재정의할 수 있습니다.

이 명령은 배포하는 모든 QML 플러그인 목록을 PLUGINS_FOUND 옵션으로 지정된 변수에 저장합니다(지정된 경우). 이 변수는 이후 qt_deploy_runtime_dependencies() 호출에서 ADDITIONAL_MODULES 인수로 전달되는 경우가 많습니다.

예제

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

find_package(Qt6 6.3 REQUIRED COMPONENTS Core Qml)
qt_standard_project_setup()

qt_add_executable(MyApp main.cpp)
qt_add_qml_module(MyApp
    URI Application
    VERSION 1.0
    QML_FILES main.qml MyThing.qml
)

# The following script must only be executed at install time
set(deploy_script "${CMAKE_CURRENT_BINARY_DIR}/deploy_MyApp.cmake")

file(GENERATE OUTPUT ${deploy_script} CONTENT "
include(\"${QT_DEPLOY_SUPPORT}\")
qt_deploy_qml_imports(
    # Deploy QML modules used by MyApp
    TARGET MyApp

    # The found QML plugins are stored in the plugins_found variable
    PLUGINS_FOUND plugins_found

    # The QML modules will be deployed into a custom directory
    QML_DIR \"myqmldir\"

    # Qt QML modules will be skipped, only project-created QML modules will be deployed
    NO_QT_IMPORTS
)
# Deploy application runtime dependencies and runtime dependencies
# of the found QML module plugins.
qt_deploy_runtime_dependencies(
    EXECUTABLE $<TARGET_FILE:MyApp>
    ADDITIONAL_MODULES \${plugins_found}
)
")

install(TARGETS MyApp)
install(SCRIPT ${deploy_script})

qt_generate_deploy_qml_app_script(), qt_deploy_runtime_dependencies() 및 QT_DEPLOY_QML_DIR도참조하십시오 .

© 2025 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.