qt_import_qml_plugins
此命令在 Qt 6.0 中引入。
简介
qt_import_qml_plugins(target)
如果禁用了无版本命令,请使用qt6_import_qml_plugins()
。它支持与此命令相同的参数集。
说明
注意: 此命令只有在静态构建 Qt 时才有效。如果使用非静态 Qt 调用该命令,它将什么也不做并立即返回。
qt_import_qml_plugins()
作为调用的一部分,它将立即在 上运行 (除非在定义 QML 模块时将 选项传给了target
qmlimportscanner
NO_IMPORT_SCAN
qt_add_qml_module())。它查找 使用的静态 QML 插件,并链接到这些插件,使它们成为 所代表的可执行文件或共享库的一部分。搜索是按照 QML 模块的导入递归进行的。target
target
由于对qmlimportscanner
的调用是在配置时而不是生成或构建时进行的,因此qt_import_qml_plugins()
只知道在调用qt_import_qml_plugins()
时记录在target
(或它链接或导入的其他目标)上的信息。调用后添加的任何链接或导入关系都不会被考虑。因此,应在target
的目录范围内尽可能晚地调用该命令,以便知道所有链接和导入关系。
如果target
是使用qt_add_executable() 创建的,项目通常不需要直接调用qt_import_qml_plugins()
。在静态构建 Qt 时,如果target
链接到 Qt Qml 库,作为目标最终确定的一部分,该命令会被自动调用。默认情况下,目标最终确定发生在创建target
的同一目录范围的末尾。如果target
是使用标准 CMakeadd_executable()
命令创建的,则项目需要自行调用qt_import_qml_plugins()
。
另请参见 Q_IMPORT_QML_PLUGIN 。
© 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.