views:

39

answers:

1

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.

A: 

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.

Rudi
This is only the transitive closure (i.e. including indirect dependencies), but it's helpful, thanks!
Thomas