Different behaviour of `make clean` and `ninja clean` on `GENERATED` source files

I am using configure_file to generate a source file containing version information for my project:

CMakeLists.txt
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(dummy VERSION 0.1 LANGUAGES C)
configure_file(version.c.in version.c)
set_source_files_properties(version.c PROPERTIES GENERATED TRUE)
add_executable(dummy-version ${CMAKE_CURRENT_BINARY_DIR}/version.c)
version.c.in
#include <stdio.h>

const char *dummy_version(void) {
    return "@dummy_VERSION@";
}

int main(int argc, char **argv) {
    printf("%s\n", dummy_version());
    return 0;
}

If I do the following using the default Makefile generator:

$ cd build-make
$ cmake ..
$ make clean
$ make

everything builds fine, but if I do the same with Ninja:

$ cd build-ninja
$ cmake -G Ninja ..
$ ninja clean
$ ninja

I get a compiler error because the file version.c is missing.

I have seen this issue, that seems to point to the fact that the GENERATED property is not needed, but I was wondering why the file is kept when using make clean and deleted when using ninja clean. Is there a reason behind this difference?

I think this is a long-standing issue in the Ninja generator. I think it has to do with these not being declared as BYPRODUCTS of the cmake generate step as far as ninja is concerned. I don’t have a link handy to the issue though.