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 #include
s 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.