Skip to content

Instantly share code, notes, and snippets.

@LukasWoodtli
Last active October 21, 2023 00:02
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LukasWoodtli/343d08a087eccb806a6489e291c09320 to your computer and use it in GitHub Desktop.
Save LukasWoodtli/343d08a087eccb806a6489e291c09320 to your computer and use it in GitHub Desktop.
How to produce dependency graphs from cmake
# put this file in the top source dir (CMAKE_SOURCE_DIR)
# see: https://cmake.org/cmake/help/latest/module/CMakeGraphVizOptions.html
set(GRAPHVIZ_EXTERNAL_LIBS FALSE)
# only dependencies between libraries
set(GRAPHVIZ_EXECUTABLES FALSE)
#!/bin/bash
# run from top source dir (CMAKE_SOURCE_DIR)
rm -rf build-dependency-graph
mkdir build-dependency-graph
cd build-dependency-graph
cmake --graphviz=dependencies.dot ..
mkdir -p dependencies
for i in `find . -maxdepth 1 -name "*.dot*"`;do dot -Tsvg $i > dependencies/${i#./dependencies.dot.}.svg;done
# The meaning of the node shapes in the generated graphs (taken from the cmake source):
# EXECUTABLE: house
# STATIC_LIBRARY: diamond
# SHARED_LIBRARY: polygon
# MODULE_LIBRARY: octagon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment