qt_android_add_apk_target
定义运行 androiddeployqt 生成 APK 的构建目标。
该命令定义在Qt6
软件包的Core
组件中,可以像这样加载:
find_package(Qt6 REQUIRED COMPONENTS Core)
此命令在 Qt 6.0 中引入。
警告: 自 Qt 6.5 起,该命令已被弃用。请使用qt_add_executable。
注意: 只有在使用 Android 平台时才应调用此命令。
简介
qt_android_add_apk_target(target)
如果禁用了无版本命令,请使用qt6_android_add_apk_target()
代替。它支持与此命令相同的参数集。
说明
该命令创建的<target>_make_apk
和<target>_make_aab
自定义目标会获取 Android 部署设置文件,并通过运行androiddeployqt
分别生成 APK 和 AAB。设置文件的位置取自target
的QT_ANDROID_DEPLOYMENT_SETTINGS_FILE
属性。该文件通常由qt_android_generate_deployment_settings() 创建。相应的 Android 软件包将在target
的 CMake 构建目录下的android-build
子目录中生成。
<target>_make_apk
和<target>_make_aab
目标将自动添加为apk
和aab
构建目标的依赖项,这两个目标也将自动创建。通过将QT_NO_GLOBAL_APK_TARGET
和QT_NO_GLOBAL_AAB_TARGET
变量设置为TRUE
,可以禁止创建apk
和aab
目标。
示例
qt_android_generate_deployment_settings(myapp) qt_android_add_apk_target(myapp)
上述命令定义了myapp_make_apk
、myapp_make_aab
、apk
和aab
构建目标,可分别用于生成myapp
软件包或项目中的所有 APK 和 AAB。
另请参阅 qt_android_generate_deployment_ settings()、qt_finalize_target() 和qt_finalize_project()。
© 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.