Whilst looking at build systems, a lot of them (SCons, bjam, cmake, Tundra, etc) have a built-in #include scanner. Yet gcc & icc offer a -MMD
(or -MD
) option which outputs the names of the header files that the C++ file depends upon.
The -MMD
dependency option seems to be reliable. If you add a #include
to a C file, its timestamp would change so the build system would recompile it. If you add a #include
to a header file, its timestamp would change and it would recompile all affected C files.
Include scanning systems break, but -MMD
would seem to me to be robust. Which is best, and why?