“dot” GraphViz program
converts the .dot files to PNG, SVG, etc.
dot is typically available on Linux, Homebrew, Windows MSYS2, Cygwin, WSL, etc.
apt install graphviz
brew install graphviz
pacman -S mingw-w64-x86_64-graphviz
Generating the dependency graph requires CMake configure and generate. Thus, the compiler and generator needed by the CMake project must be working. The project does not need to be compiled before generating the dependency graph.
h5fortran HDF5 object-oriented Fortran dependency graph is below. SVG can be a useful format since it’s vector and can be zoomed arbitrarily large in a web browser, while PNG is viewable by almost anything. The “gfx/” directory is arbitrary and created automatically, to avoid making a mess of files in the top directory.
cmake -B build --graphviz=gfx/block.dot cd gfx dot -Tpng -o block.png block.dot dot -Tsvg -o block.svg block.dot
The “dependers” files show only the nodes depending on a node.
CMakeUtils can convert a whole directory of these DOT diagrams to SVG or PNG like:
python -m cmakeutils.graph ~/myprog/gfx