I'm analyzing a CMake project and I want to get all the header files that a source file depends on. Is there a tool or a command like gcc -M
or g++ -M
to list all the dependencies of one file in the CMake project? It would be better if I could also get which Target each header file belongs to.
Of course I can’t use g++ -M
directly because it can’t find some dependencies organized by CMakeLists.txt
.
Since the cmake
command will generate MakeFile
, a tool or command for Make may may also work for me.