Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to output compilation dependencies from CMake or make?

I have a CMake C++ project that is rapidly growing and often changing. I'm trying to reduce compile times to a minimum.

Often, when I rebuild the project, especially after a header change, I'm surprised at how many compilation units need to be recompiled. I'm trying to identify #includes that can possibly be avoided, for example by using pre-declarations or by not inlining trivial functions in headers.

Is there any way to find out, from CMake itself, from the generated Makefile, or directly from the files themselves, which units depend on which headers?

A list would be nice, a visual graph (graphviz?) even nicer. Google turns up nothing for me. CMake has the --graphviz option, but it operates on targets, not individual compilation units.

Something cross-platform (i.e. using just CMake) is preferred, but I'll settle for Linux-only too.

like image 282
Thomas Avatar asked Jul 08 '10 09:07

Thomas


1 Answers

I found the dependency information generated by cmake2.8 (after running make) living in depend.make and depend.internal files, when I'm using a gcc based toolchain. Using VS does not seem to generate such files (but this doesn't seem to be a problem for you). Also these files are cmake internals, so use them at your own risk.

like image 76
Rudi Avatar answered Nov 17 '22 02:11

Rudi