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 the MANUAL_FINALIZATION keyword was passed to qt_add_executable() when the target 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 the target was defined, and deferred finalization has been completed at the end of the target'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:

ModeDefaultFinalization behavior
static_pluginsEnabledWhen 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().

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