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.

The command is defined in the 核心 组件对于 Qt6 package, which can be loaded like so:

find_package(Qt6 REQUIRED COMPONENTS Core)
					

This command was introduced in Qt 6.3.

概要

qt_finalize_project()
					

versionless commands are disabled, use qt6_finalize_project() instead. It supports the same set of arguments as this command.

描述

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 .