Skip to content

Makefile: Add policy CMP0113 to avoid duplication of custom commands

Brad King requested to merge brad.king/cmake:custom-command-dedup into master

Do not attach a custom command to a target if it is already attached to one of the target's dependencies. The command's output will be available by the time the target needs it because the dependency containing the command will have already been built.

This may break existing projects that do not properly mark non-created outputs with the SYMBOLIC property. Previously a chain of two custom commands whose intermediate dependency is not created would put both commands in a dependent project's Makefile even if the first command is also in its dependency's Makefile. The first command would run twice but the build would work. Now the second command needs an explicit SYMBOLIC mark on its input to tell CMake that it is not expected to exist. To maintain compatibility with projects that left out the mark, add a policy activating the behavior.

Issue: #18663 (closed)

Edited by Brad King

Merge request reports