이 페이지에서

qt_deploy_qml_imports

실행 파일에 필요한 QML 모듈의 런타임 구성 요소를 배포합니다.

이 명령은 Qt6 패키지의 Qml 구성 요소에 정의되어 있으며, 다음과 같이 불러올 수 있습니다:

find_package(Qt6 REQUIRED COMPONENTS Qml)

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

경고: CMake 3.19보다 낮은 버전을 사용하는경우 , qt_add_executable()에 MANUAL_FINALIZATION 옵션을 전달하고, 이 함수를 호출하기 전에 qt_finalize_target()을 호출해야 합니다.

개요

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

설명

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

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

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

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

이 명령어는 PLUGINS_FOUND 옵션이 지정된 경우, 배포하는 모든 QML 플러그인의 목록을 해당 옵션으로 지정한 변수에 저장합니다. 이 목록은 종종 이후 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도 참조하십시오 .

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