CMake: Clarify documentation for target and project finalization

Amends 944c424ff601fe546a0ac83e0d8b3f781beb68f6
Amends 63f79d7ffb22de89a2c6314caa5b5a1908590063

Change-Id: Ic8f3376f49b7aaeaa4bf307aa401c54d48cd5c4d
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit b0fef2849b97f9a315018efb49ab9d8974e2c19a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2022-08-25 14:00:41 +02:00 committed by Qt Cherry-pick Bot
parent 65a04c3625
commit 3cbb6c1438

View File

@ -60,25 +60,34 @@ for you as a convenience.
After a target is created, further processing or \e{finalization} steps are
commonly needed. The steps to perform depend on the platform and on various
properties of the target. The finalization processing is implemented by the
\l{qt6_finalize_target}{qt_finalize_target()} command. You might need to also
call the \l{qt6_finalize_project}{qt_finalize_project()} command at the end
of top-level CMakeLists.txt to correctly resolve the dependencies between
project targets.
properties of the target.
Finalization can occur either as part of this call or be deferred to sometime
after this command returns (but it should still be in the same directory scope).
When using CMake 3.19 or later, finalization is automatically deferred to the
The finalization processing is implemented by two commands:
\l{qt6_finalize_target}{qt_finalize_target()} and
\l{qt6_finalize_project}{qt_finalize_project()}.
Target finalization can occur either as part of calling \c{qt_add_executable}
or be deferred to sometime after this command returns (but it should still be in
the same directory scope).
When using CMake 3.19 or later, target finalization is automatically deferred to the
end of the current directory scope. This gives the caller an opportunity to
modify properties of the created target before it is finalized. When using
CMake versions earlier than 3.19, automatic deferral isn't supported. In that
case, finalization is performed immediately before this command returns.
case, target finalization is performed immediately before this command returns.
Regardless of the CMake version, the \c{MANUAL_FINALIZATION} keyword can be given to
indicate that you will explicitly call \l{qt6_finalize_target}{qt_finalize_target()}
yourself instead at some later time. In general, \c MANUAL_FINALIZATION should
not be needed unless the project has to support CMake 3.18 or earlier.
Project finalization occurs automatically when using CMake 3.19 or later.
When using an older CMake version, you should call
\l{qt6_finalize_project}{qt_finalize_project()} manually, at the end
of the root \c CMakeLists.txt file.
This is especially important when targeting Android, to collect dependencies
between project targets for deployment purposes.
\sa {qt6_finalize_target}{qt_finalize_target()},
{qt6_set_finalizer_mode}{qt_set_finalizer_mode()},
{qt6_add_library}{qt_add_library()},