# dependency file(\*.d) file generation in cmake

**URL:** https://discourse.cmake.org/t/dependency-file-d-file-generation-in-cmake/2680
**Category:** Usage
**Tags:** os:windows, gen:makefiles
**Created:** [February 3, 2021, 10:46am UTC](https://discourse.cmake.org/t/dependency-file-d-file-generation-in-cmake/2680 "2021-02-03T10:46:31Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![deepan](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@deepan](https://discourse.cmake.org/u/deepan)
#### Post date: [February 3, 2021, 10:46am UTC](https://discourse.cmake.org/t/dependency-file-d-file-generation-in-cmake/2680/1 "2021-02-03T10:46:31Z")

</div>

I am using cmake version 3.18.5. I have a C project for embedded system in cmake. I want the build system to generate .d files while building. my project compilation is successful but i don’t see the .d files anywhere. How to enable this?

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [February 3, 2021, 11:10am UTC](https://discourse.cmake.org/t/dependency-file-d-file-generation-in-cmake/2680/2 "2021-02-03T11:10:54Z")

</div>

I assume you are using `Unix Makefiles` generator.  
In this case, `CMake 3.18` manage dependencies with his own parser. Dependencies are collected in files `depend.internal` and `depend.make` in each target build directories.

If your compiler is able to generate dependencies files, you have to configure compilation step to enable this.

Nota: starting with `CMake 3.20` with `Makefiles` generators, for some compilers, compiler itself is used to generate dependencies. In this case, `.d` files are now generated by default.

---

<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: [February 3, 2021, 2:04pm UTC](https://discourse.cmake.org/t/dependency-file-d-file-generation-in-cmake/2680/3 "2021-02-03T14:04:22Z")

</div>

And just for completion’s sake, the the ninja tool (via the Ninja generator) will delete `.d` files that it collects into its `.ninja_deps` log file. You can prevent this with `ninja -d keepdepfile` (though it is considered a debugging facility, hence the `-d` flag).

---

<div class="post-metadata">

### Author: ![deepan](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@deepan](https://discourse.cmake.org/u/deepan)
#### Post date: [February 3, 2021, 2:09pm UTC](https://discourse.cmake.org/t/dependency-file-d-file-generation-in-cmake/2680/4 "2021-02-03T14:09:57Z")

</div>

I am using MinGW Makefile.  
compiler : windriver diab  
As you mentioned i saw depend.internal file which contains the dependency for each source file.  
apart from that i passed a compiler option(-Xmake-dependency=4) which generates individual .d file for each source file.  
Thank you for the support @marc.chevrier

---

<div class="post-metadata">

### Author: ![deepan](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@deepan](https://discourse.cmake.org/u/deepan)
#### Post date: [February 3, 2021, 2:11pm UTC](https://discourse.cmake.org/t/dependency-file-d-file-generation-in-cmake/2680/5 "2021-02-03T14:11:29Z")

</div>

got it… thanks for the support @ben.boeckel

---

<div class="post-metadata">

### Author: ![Jay1](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/9d8465/32.png) [@Jay1](https://discourse.cmake.org/u/Jay1)
#### Post date: [January 24, 2025, 5:37am UTC](https://discourse.cmake.org/t/dependency-file-d-file-generation-in-cmake/2680/6 "2025-01-24T05:37:50Z")

</div>

Hi @deepan currently I am also facing the same issue for generating the. d file  
I have tried with this (-Xmake-dependency) but didn’t worked out  
Here i am also using the windriver diab compiler , but the only difference is that I am using **Omake** and not Cmake  
Can you please help me out with this if possible

Hi @marc.chevrier your inputs are appreciated as well.

---

<div class="post-metadata">

### Author: ![jtxa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jtxa/32/1535_2.png) [@jtxa](https://discourse.cmake.org/u/jtxa)
#### Post date: [January 31, 2025, 10:33pm UTC](https://discourse.cmake.org/t/dependency-file-d-file-generation-in-cmake/2680/7 "2025-01-31T22:33:38Z")

</div>

> [@Jay1](#):
>
> the only difference

**The only difference** is, that omake and CMake have absolutely nothing in common. omake is a make tool, like gnumake or more like nmake. CMake is a build tool generator.

If you have a plain omake makefile, you have to do everything yourself. Essentially it’s calling the compiler with the right options and including the .d files on the next make call.

---

<div class="post-metadata">

### Author: ![Jay1](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/9d8465/32.png) [@Jay1](https://discourse.cmake.org/u/Jay1)
#### Post date: [February 3, 2025, 9:23am UTC](https://discourse.cmake.org/t/dependency-file-d-file-generation-in-cmake/2680/8 "2025-02-03T09:23:02Z")

</div>

Hi @jtxa as of now we are not able to generate .d files Currently we are using omake makefile from clear case is there any particular flag or something, which we can generate.d files in project. In some cpp file it is generating but we are not able to figure it out.

---

<div class="post-metadata">

### Author: ![leakec](https://discourse.cmake.org/user_avatar/discourse.cmake.org/leakec/32/5216_2.png) [@leakec](https://discourse.cmake.org/u/leakec)
#### Post date: [March 27, 2025, 4:08pm UTC](https://discourse.cmake.org/t/dependency-file-d-file-generation-in-cmake/2680/9 "2025-03-27T16:08:57Z")

</div>

Making a note that if you just need the contents of the `.d` files (but don’t need the `.d` files to exist themselves), you can also just run `ninja -t deps` in the build directory and it will print the contents of what would be in the `.d` files to `stdout`.
