Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qt_set_finalizer_mode.qdoc
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\page qt-set-finalizer-mode.html
6\ingroup cmake-commands-qtcore
7
8\title qt_set_finalizer_mode
9\keyword qt6_set_finalizer_mode
10
11\summary {Customizes aspects of a target's finalization.}
12
13\include cmake-find-package-core.qdocinc
14
15\cmakecommandsince 6.2
16\preliminarycmakecommand
17
18\section1 Synopsis
19
20\badcode
21qt_set_finalizer_mode(target
22 ENABLE | DISABLE
23 MODES modes...
24)
25\endcode
26
27\versionlessCMakeCommandsNote qt6_set_finalizer_mode()
28
29\section1 Description
30
31This command is used to customize some aspects of the finalization of a
32specific \c target. It only has an effect if called before \c target is
33finalized, which occurs in one of the following scenarios:
34
35\list
36\li The project explicitly calls \l{qt6_finalize_target}{qt_finalize_target()}
37 for the \c target. This usually means the \c MANUAL_FINALIZATION keyword was
38 passed to \l{qt6_add_executable}{qt_add_executable()} when the \c target
39 was defined.
40\li CMake 3.17 or earlier is being used, in which case finalization always
41 occurs immediately as part of the call to
42 \l{qt6_add_executable}{qt_add_executable()}.
43\li CMake 3.18 or later is being used, the \c MANUAL_FINALIZATION keyword was
44 not passed to \l{qt6_add_executable}{qt_add_executable()} when the \c target
45 was defined, and deferred finalization has been completed at the end of the
46 \c target's directory scope.
47\endlist
48
49\c{qt_set_finalizer_mode()} is used to enable or disable a list of \e modes,
50where a mode corresponds to a specific aspect of finalization. The currently
51supported finalization modes are:
52
53\table
54\header
55 \li Mode
56 \li Default
57 \li Finalization behavior
58\row
59 \li \c static_plugins
60 \li Enabled
61 \li When Qt is built statically, it creates initializer object libraries
62 for its static plugins. If \c target is an executable and this
63 finalization mode is enabled, any plugin initializer object libraries
64 needed by the \c target will be directly linked to it. This
65 prevents cycles between Qt-provided static libraries and may reduce
66 link time. When this finalizer mode is disabled, each plugin
67 initializer is instead propagated via usage requirements of its
68 associated Qt library, which may cause cycles. If Qt is not built
69 statically, this finalizer mode is not relevant and isn't used.
70\endtable
71
72\sa {qt6_finalize_target}{qt_finalize_target()}
73
74\section1 Example
75
76The following example assumes you are using CMake 3.19 or later (required for
77deferred finalization):
78
79\badcode
80qt_add_executable(my_app main.cpp)
81qt_set_finalizer_mode(my_app ENABLE MODES static_plugins)
82\endcode
83
84The same example using manual finalization might look like this:
85
86\badcode
87qt_add_executable(my_app MANUAL_FINALIZATION main.cpp)
88qt_set_finalizer_mode(my_app ENABLE MODES static_plugins)
89qt_finalize_target(my_app)
90\endcode
91
92*/