Revision control

Copy as Markdown

// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page qt-finalize-target.html
\ingroup cmake-commands-qtcore
\title qt_finalize_target
\keyword qt_finalize_target()
\summary {Handles various common platform-specific tasks associated with Qt targets.}
\include cmake-find-package-core.qdocinc
\cmakecommandsince 6.2
\section1 Synopsis
\badcode
qt_finalize_target(target)
\endcode
\versionlessCMakeCommandsNote qt6_finalize_target()
\section1 Description
After a target is created, further processing or \e{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 \c{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
\l qt_add_executable(),
\l qt_add_library(), or \l 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.
\sa qt_set_finalizer_mode()
\section1 Executable Targets
For executable targets, \c{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.
\section2 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.
\section2 Android
\list
\li Generate a deployment settings file for the \c target.
\li Create a build target for generating an APK.
\endlist
\section2 WASM
Create \c{${target}.html} (a target-specific \c{wasm_shell.html} file),
\c{qtloader.js}, and \c{qtlogo.svg} files in the \c{CMAKE_CURRENT_BINARY_DIR}.
\section2 iOS
Finalization attempts to provide sensible values for the following target
properties if they are not already set, and their corresponding \c{CMAKE_...}
variable is also not set:
\list
\li \c XCODE_ATTRIBUTE_DEVELOPMENT_TEAM
\li \c XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER
\li \c MACOSX_BUNDLE_GUI_IDENTIFIER
\endlist
If required, the \l QT_NO_SET_XCODE_DEVELOPMENT_TEAM_ID variable can be used to
disable setting \c XCODE_ATTRIBUTE_DEVELOPMENT_TEAM, and the
\l QT_NO_SET_XCODE_BUNDLE_IDENTIFIER variable can be used to disable setting
\c XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER and \c MACOSX_BUNDLE_GUI_IDENTIFIER.
\section3 Embedding Shared Library Dependencies
\target apple-embed-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
\c XCODE_EMBED_FRAMEWORKS build phase, with \c CODE_SIGN_ON_COPY enabled.
Both framework bundles and plain \c dylib libraries are handled.
Embedding is only done if all of the following apply:
\list
\li Qt was built in a shared library configuration.
\li The Xcode generator is used.
\li Qt was not built with both a debug and a release configuration, because
\c XCODE_EMBED_FRAMEWORKS holds a single path per library and can therefore
not describe both configurations.
\li 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.
\li The \c XCODE_EMBED_FRAMEWORKS property is not already set on the target,
which is taken as a sign that the project handles embedding itself.
\endlist
To deploy the shared libraries yourself, set the
\l{cmake-target-property-QT_NO_XCODE_EMBED_FRAMEWORKS}
{QT_NO_XCODE_EMBED_FRAMEWORKS} property on the application target.
To leave out individual libraries, set the
\l{cmake-target-property-QT_NO_XCODE_EMBED_FRAMEWORK_IN_CONSUMERS}
{QT_NO_XCODE_EMBED_FRAMEWORK_IN_CONSUMERS} property on those libraries.
\section1 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.
*/