qt_finalize_project

Handles various common platform-specific tasks associated with a Qt project.

注意: This command is in technology preview and may change in future releases.

命令的定义在 核心 组件对于 Qt6 包,可以像这样加载:

find_package(Qt6 REQUIRED COMPONENTS Core)
					

This command was introduced in Qt 6.3.

概要

qt_finalize_project()
					

无版本命令 被禁用,使用 qt6_finalize_project() 代替。它支持如此命令的一组相同自变量。

描述

Some targets that are created using Qt commands require additional actions at the end of CMake configuring phase. Depending on the platform, the function typically:

  • Walks the build tree.
  • Resolves dependencies.
  • Applies any extra deployment steps.

With CMake version 3.19 or later, you don't need to call this command since it consists of sub-commands that are ordinarily invoked at the end of CMAKE_SOURCE_DIR directory scope processing.

警告: Android project is built using a CMake version lower than 3.19, make sure that you call qt6_finalize_project() at the end of a top-level CMakeLists.txt.

范例

For projects that use a CMake version lower than 3.19, you need to call qt_finalize_project manually. This example shows the typical use of the function:

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 and QT_NO_COLLECT_IMPORTED_TARGET_APK_DEPS .