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

**URL:** https://discourse.cmake.org/t/different-behaviour-of-make-clean-and-ninja-clean-on-generated-source-files/3920
**Category:** Usage
**Tags:** gen:makefiles, gen:ninja
**Created:** [August 12, 2021, 5:10pm UTC](https://discourse.cmake.org/t/different-behaviour-of-make-clean-and-ninja-clean-on-generated-source-files/3920 "2021-08-12T17:10:47Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![oiffrig](https://discourse.cmake.org/user_avatar/discourse.cmake.org/oiffrig/32/1705_2.png) [@oiffrig](https://discourse.cmake.org/u/oiffrig)
#### Post date: [August 12, 2021, 5:10pm UTC](https://discourse.cmake.org/t/different-behaviour-of-make-clean-and-ninja-clean-on-generated-source-files/3920/1 "2021-08-12T17:10:47Z")

</div>

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

> **CMakeLists.txt**
>
> ```auto
> 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**
>
> ```auto
> #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:

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

```

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

```auto
$ 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](https://gitlab.kitware.com/cmake/cmake/-/issues/18032), 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?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [August 16, 2021, 3:39pm UTC](https://discourse.cmake.org/t/different-behaviour-of-make-clean-and-ninja-clean-on-generated-source-files/3920/2 "2021-08-16T15:39:41Z")

</div>

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.
