Skip to content

Commit

Permalink
CMake: Clarify documentation for target and project finalization
Browse files Browse the repository at this point in the history
Amends 944c424
Amends 63f79d7

Pick-to: 6.3 6.4
Change-Id: Ic8f3376f49b7aaeaa4bf307aa401c54d48cd5c4d
Reviewed-by: Jörg Bornemann <[email protected]>
Reviewed-by: Assam Boudjelthia <[email protected]>
  • Loading branch information
alcroito committed Aug 30, 2022
1 parent 9540a4e commit b0fef28
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/corelib/doc/src/cmake/qt_add_executable.qdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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
properties of the target.

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()},
Expand Down

0 comments on commit b0fef28

Please sign in to comment.