qt_set_finalizer_mode
Customizes aspects of a target's finalization.
This command was introduced in Qt 6.2.
Note: This command is in technology preview and may change in future releases.
Synopsis
qt_set_finalizer_mode(target ENABLE | DISABLE MODES modes... )
If versionless commands are disabled, use qt6_set_finalizer_mode()
instead. It supports the same set of arguments as this command.
Description
This command is used to customize some aspects of the finalization of a specific target
. It only has an effect if called before target
is finalized, which occurs in one of the following scenarios:
- The project explicitly calls qt_finalize_target() for the
target
. This usually means theMANUAL_FINALIZATION
keyword was passed to qt_add_executable() when thetarget
was defined. - CMake 3.17 or earlier is being used, in which case finalization always occurs immediately as part of the call to qt_add_executable().
- CMake 3.18 or later is being used, the
MANUAL_FINALIZATION
keyword was not passed to qt_add_executable() when thetarget
was defined, and deferred finalization has been completed at the end of thetarget
's directory scope.
qt_set_finalizer_mode()
is used to enable or disable a list of modes, where a mode corresponds to a specific aspect of finalization. The currently supported finalization modes are:
Mode | Default | Finalization behavior |
---|---|---|
static_plugins | Enabled | When Qt is built statically, it creates initializer object libraries for its static plugins. If target is an executable and this finalization mode is enabled, any plugin initializer object libraries needed by the target will be directly linked to it. This prevents cycles between Qt-provided static libraries and may reduce link time. When this finalizer mode is disabled, each plugin initializer is instead propagated via usage requirements of its associated Qt library, which may cause cycles. If Qt is not built statically, this finalizer mode is not relevant and isn't used. |
Example
The following example assumes you are using CMake 3.19 or later (required for deferred finalization):
qt_add_executable(my_app main.cpp) qt_set_finalizer_mode(my_app ENABLE MODES static_plugins)
The same example using manual finalization might look like this:
qt_add_executable(my_app MANUAL_FINALIZATION main.cpp) qt_set_finalizer_mode(my_app ENABLE MODES static_plugins) qt_finalize_target(my_app)
See also qt_finalize_target().