On this page

qt_finalize_target

Handles various common platform-specific tasks associated with Qt targets.

The command is defined in the Core component of the Qt6 package, which can be loaded like so:

find_package(Qt6 REQUIRED COMPONENTS Core)

This command was introduced in Qt 6.2.

Synopsis

qt_finalize_target(target)

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

Description

After a target is created, further processing or finalization steps are sometimes needed. The steps to perform depend on the platform, the type of target, and on various properties of the target. These steps are expected to be performed within the same directory scope as the one in which the target was created, so this command should also be called from that same directory scope.

This command is ordinarily invoked as part of a call to qt_add_executable(), qt_add_library(), or qt_add_plugin(). The timing of when that call takes place and when a project might need to call it explicitly, is discussed in the documentation of those commands.

Executable Targets

For executable targets, qt_finalize_target() implements the logic described in the subsections below, as appropriate for the platform and target provided. Later Qt releases may expand finalization processing further.

All Platforms

Some internal processing is performed to facilitate automatic linking of Qt plugins. This is especially important if using a statically built Qt or a CMake version earlier than 3.21.

Android

  • Generate a deployment settings file for the target.
  • Create a build target for generating an APK.

WASM

Create ${target}.html (a target-specific wasm_shell.html file), qtloader.js, and qtlogo.svg files in the CMAKE_CURRENT_BINARY_DIR.

iOS

Finalization attempts to provide sensible values for the following target properties if they are not already set, and their corresponding CMAKE_... variable is also not set:

  • XCODE_ATTRIBUTE_DEVELOPMENT_TEAM
  • XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER
  • MACOSX_BUNDLE_GUI_IDENTIFIER

If required, the QT_NO_SET_XCODE_DEVELOPMENT_TEAM_ID variable can be used to disable setting XCODE_ATTRIBUTE_DEVELOPMENT_TEAM, and the QT_NO_SET_XCODE_BUNDLE_IDENTIFIER variable can be used to disable setting XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER and MACOSX_BUNDLE_GUI_IDENTIFIER.

Embedding Shared Library Dependencies

An application that depends on shared libraries can only launch if the shared libraries it links against are part of its bundle.

Since Qt 6.12, the build system collects the shared libraries the application links against, and adds them to the application's XCODE_EMBED_FRAMEWORKS build phase, with CODE_SIGN_ON_COPY enabled. Both framework bundles and plain dylib libraries are handled.

Embedding is only done if all of the following apply:

  • Qt was built in a shared library configuration.
  • The Xcode generator is used.
  • Qt was not built with both a debug and a release configuration, because XCODE_EMBED_FRAMEWORKS holds a single path per library and can therefore not describe both configurations.
  • The target is an application bundle, and not a child bundle like an app extension. Child bundles are expected to use the frameworks of their parent application.
  • The XCODE_EMBED_FRAMEWORKS property is not already set on the target, which is taken as a sign that the project handles embedding itself.

To deploy the shared libraries yourself, set the QT_NO_XCODE_EMBED_FRAMEWORKS property on the application target.

To leave out individual libraries, set the QT_NO_XCODE_EMBED_FRAMEWORK_IN_CONSUMERS property on those libraries.

Library Targets

As of this Qt version, finalization for library targets does not perform any processing. Future Qt versions may add finalization processing for libraries, so you should ensure finalization is still invoked in the expected way.

See also qt_set_finalizer_mode().

© 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.