add_custom_command make dependency breaks parallel builds
Consider the following CMakeLists.txt:
cmake_minimum_required(VERSION 3.5)
add_custom_target(Main ALL DEPENDS A.txt B.txt)
add_custom_target(Another ALL DEPENDS A.txt B.txt)
add_custom_command(OUTPUT A.txt B.txt
COMMAND touch A.txt
COMMAND touch B.txt)
Running make -j shows:
build$ make -j
Scanning dependencies of target Main
Scanning dependencies of target Another
[ 50%] Generating A.txt, B.txt
[100%] Generating A.txt, B.txt
[100%] Built target Main
[100%] Built target Another
It should not be generating those files twice. This seems to work fine with the ninja backend.