CMake does not diagnose multiple targets having the same output path
Consider the following example:
cmake_minimum_required(VERSION 3.5)
project(test C)
file(TOUCH ${CMAKE_BINARY_DIR}/main.c)
add_executable(exe1 ${CMAKE_BINARY_DIR}/main.c)
add_executable(exe2 ${CMAKE_BINARY_DIR}/main.c)
set_property(TARGET exe1 exe2 PROPERTY OUTPUT_NAME exe)
This will happily generate build rules for exe1
and exe2
without failing. However, attempting to build them will fail at Ninja time because of a duplicate rule error.
We should also attempt to diagnose targets that produce the same output for different configurations.
This was discovered in discussion of #20161.