mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Commit 680fbb112a (Autogen: Enable depfile support for Visual Studio and
Xcode generators) disabled the PRE_BUILD optimization when a depfile is
used, because a PRE_BUILD event cannot carry depfile dependencies. Since
then, every target with AUTOMOC or AUTOUIC enabled gains an
'<ORIGIN>_autogen' and an '<ORIGIN>_autogen_timestamp_deps' target,
which the Visual Studio generators turn into two extra projects per
target in the generated solution.
Attach the autogen custom command to the origin target instead. The
custom command still carries the depfile, and the dependencies of the
origin target provide the ordering that
'<ORIGIN>_autogen_timestamp_deps' provides otherwise, because MSBuild
builds all referenced projects before any step of the referencing
project.
Use the conditions of the PRE_BUILD event, so that the
'<ORIGIN>_autogen' target keeps existing wherever it existed before
depfiles were enabled for the Visual Studio generators. In particular,
projects that name the target in add_dependencies() keep working.
Ninja and the Makefile generators keep the separate targets. Extra
targets have no cost for them, and '<ORIGIN>_autogen' has always existed
there.
The Xcode generator gained the same two targets per origin target in
4.4, but attaching the custom command there needs some more thoughts on
the per-config timestamp file first: Xcode rejects targets whose sources
vary by configuration, and with AUTOGEN_BETTER_GRAPH_MULTI_CONFIG the
timestamp file is per configuration.
Fixes: #28034
Fixes: #28033
24 lines
908 B
ReStructuredText
24 lines
908 B
ReStructuredText
CMAKE_AUTOGEN_ORIGIN_DEPENDS
|
|
----------------------------
|
|
|
|
.. versionadded:: 3.14
|
|
|
|
Switch for forwarding origin target dependencies to the corresponding
|
|
:ref:`<ORIGIN>_autogen <<ORIGIN>_autogen>` targets.
|
|
|
|
.. note::
|
|
|
|
If the
|
|
:ref:`<ORIGIN>_autogen_timestamp_deps <<ORIGIN>_autogen_timestamp_deps>`
|
|
target is created, additional target dependencies are added to it instead
|
|
of the :ref:`<ORIGIN>_autogen <<ORIGIN>_autogen>` target. When using the
|
|
:ref:`Visual Studio Generators`, the ``moc`` and ``uic`` step may be part
|
|
of the ``<ORIGIN>`` target itself, in which case the dependencies are added
|
|
to ``<ORIGIN>``. See the :manual:`cmake-qt(7)` manual for details.
|
|
|
|
This variable is used to initialize the :prop_tgt:`AUTOGEN_ORIGIN_DEPENDS`
|
|
property on all the targets. See that target property for additional
|
|
information.
|
|
|
|
By default ``CMAKE_AUTOGEN_ORIGIN_DEPENDS`` is ``ON``.
|