Last active
October 25, 2024 20:59
-
-
Save LukasWoodtli/343d08a087eccb806a6489e291c09320 to your computer and use it in GitHub Desktop.
How to produce dependency graphs from cmake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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