add_custom_target with BYPRODUCTS works correctly either with ninja or make, but not both
Problematic case:
add_custom_target(filename ALL
COMMAND some_command dep > filename
BYPRODUCTS filename
DEPENDS dep)
If BYPRODUCTS is present, then everything is OK with make, but in ninja there is a warning and error:
ninja: warning: phony target ... names itself as an input; ignoring [-w phonycycle=warn]
ninja: error: build.ninja:6476: multiple rules generate ... [-w dupbuild=err]
If BYPRODUCTS is commented out, then everything is OK with ninja, but 'make clean' does not clean <filename>.
Used cmake version is 3.21.3
How it is supposed to use add_custom_target to avoid this issue?