dependency file(*.d) file generation in cmake

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?

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.

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).

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

got it… thanks for the support @ben.boeckel

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.

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.

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.