Post-build events triggers Ninja error for Multi-Config builds
After updating to CMake 3.20.1 the following simple listfile triggers a Ninja error in multi-config builds. This regressed somewhere between 3.19.1 and 3.20.1. ``` cmake_minimum_required(VERSION 3.19) project(MultiConfigPostBuildBug) add_custom_target(customTarget COMMAND ${CMAKE_COMMAND} -E echo "I am a custom target" COMMENT "I am a comment" ) # Remove post-build event and customTarget will "build" correctly. add_custom_command(TARGET customTarget POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo Post build ) ``` I have configured the project as follows: ``` cmake -G"Ninja Multi-Config" -DCMAKE_CONFIGURATION_TYPES=RelWithDebInfo;Debug -DCMAKE_CROSS_CONFIGS=all -DCMAKE_DEFAULT_CONFIGS=all ``` When running ninja it fails with: ``` ninja: error: CMakeFiles/impl-RelWithDebInfo.ninja:56: multiple rules generate CMakeFiles/RelWithDebInfo/customTarget.util [-w dupbuild=err] ``` It can easily be validated that the impl-RelWithDebInfo contains duplicate entries for customTarget.util, which Ninja complains about. With CMake 3.19 everything works as expected, e.g. nothing happens :)
issue