qt_deploy_qml_imports
実行ファイルが必要とするQMLモジュールのランタイムコンポーネントをデプロイします。
このコマンドはQt6
パッケージのQml
コンポーネントで定義されています:
find_package(Qt6 REQUIRED COMPONENTS Qml)
Qt が提供する他の CMake コマンドとは異なり、qt6_deploy_qml_imports
はデプロイスクリプトからのみ呼び出すことができます。Qt が提供する他のほとんどの CMake コマンドとは異なり、 はデプロイスクリプトからのみ呼び出すことができます。
警告 警告: CMake のバージョンが 3.19 より低い場合は、この関数を呼び出す前に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モジュールのどの部分をインストールする必要があるのかを調べるのは、容易なことではありません。QMLプラグインはアプリケーションの実行ファイルに直接リンクされていないため、qt_deploy_runtime_dependencies()はこれらのQMLモジュールを見つけることができません。qt6_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
ファイルとプラグインがデプロイされます。Qt が提供する QML モジュールのデプロイをスキップするには、NO_QT_IMPORTS
オプションを指定します。
デフォルトでは、インポートされた 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.