qt_finalize_project
处理与 Qt 项目相关的各种常见平台特定任务。
该命令定义在Qt6 包的Core 组件中,可按如下方式加载:
find_package(Qt6 REQUIRED COMPONENTS Core)该命令于 Qt 6.3 版本中引入。
语法
qt_finalize_project()如果禁用了无版本命令,请改用qt6_finalize_project() 。它支持与本命令相同的参数集。
描述
某些使用 Qt 命令创建的目标需要在 CMake 配置阶段结束时执行额外操作。根据平台的不同,该函数通常:
- 遍历构建树。
- 解析依赖关系。
- 应用任何额外的部署步骤。
在 CMake 3.19 及更高版本中,您无需调用此命令,因为它包含的子命令通常会在CMAKE_SOURCE_DIR 目录作用域处理结束时自动调用。
警告:如果 您的Android项目使用低于 3.19 版本的 CMake 进行构建,请确保在顶级 CMakeLists.txt 的末尾调用qt_finalize_project()。
示例
对于使用低于 3.19 版本的 CMake 的项目,您需要手动调用qt_finalize_project 。以下示例展示了该函数的典型用法:
cmake_minimum_required(VERSIONS 3.16)
project(MyProject LANGUAGES CXX)
find_package(Qt6 REQUIRED COMPONENTS Core)
qt_add_executable(MyApp main.cpp)
add_subdirectory(mylib)
qt_finalize_project()另请参阅 QT_NO_COLLECT_BUILD_TREE_APK_DEPS和QT_NO_COLLECT_IMPORTED_TARGET_APK_DEPS。
© 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.