1CMP0113
2-------
3
4.. versionadded:: 3.19
5
6:ref:`Makefile Generators` do not repeat custom commands from target
7dependencies.
8
9Consider a chain of custom commands split across two dependent targets:
10
11.. code-block:: cmake
12
13  add_custom_command(OUTPUT output-not-created
14    COMMAND ... DEPENDS ...)
15  set_property(SOURCE output-not-created PROPERTY SYMBOLIC 1)
16  add_custom_command(OUTPUT output-created
17    COMMAND ... DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/output-not-created)
18  add_custom_target(first DEPENDS output-not-created)
19  add_custom_target(second DEPENDS output-created)
20  add_dependencies(second first)
21
22In CMake 3.18 and lower, the Makefile generators put a copy of both custom
23commands in the Makefile for target ``second`` even though its dependency on
24target ``first`` ensures that the first custom command runs before the second.
25Running ``make second`` would cause the first custom command to run once in
26the ``first`` target and then again in the ``second`` target.
27
28CMake 3.19 and above prefer to not duplicate custom commands in a target that
29are already generated in other targets on which the target depends (directly or
30indirectly).  This policy provides compatibility for projects that have not
31been updated to expect the new behavior.  In particular, projects that relied
32on the duplicate execution or that did not properly set the :prop_sf:`SYMBOLIC`
33source file property may be affected.
34
35The ``OLD`` behavior for this policy is to duplicate custom commands in
36dependent targets.  The ``NEW`` behavior of this policy is to not duplicate
37custom commands in dependent targets.
38
39This policy was introduced in CMake version 3.19.  Unlike many policies,
40CMake version |release| does *not* warn when this policy is not set and
41simply uses ``OLD`` behavior.
42
43.. include:: DEPRECATED.txt
44