Why CMake pass '-MD -MT' flags to gcc c++ and clang++ while compiling on Linux?

Regarding the purpose of the generated dependency files, they are used so that generators (e.g. make, ninja) recompile files only when their included headers are modified.

There is a nice answer in stack overflow: gcc - purpose of creating DEPENDENCIES_OUTPUT file while compiling c program