Skip to content

Instantly share code, notes, and snippets.

@agutenkunst
Last active July 7, 2020 13:46
Show Gist options
  • Save agutenkunst/d0ee60a35e76f77e8c938ff88fcf089c to your computer and use it in GitHub Desktop.
Save agutenkunst/d0ee60a35e76f77e8c938ff88fcf089c to your computer and use it in GitHub Desktop.
Show cmake target dependency graph
```
cmake src/<package_name>/ --graphviz=foo.dot
xdot foo.dot
```
Set options for better exclude by adding a file src/<package_name>/CMakeGraphVizOptions.cmake with
```
set(GRAPHVIZ_EXTERNAL_LIBS FALSE)
set(GRAPHVIZ_IGNORE_TARGETS "gtest;gmock;unittest*;integrationtest*")
```
Or Filter:
```
sed -i '/\/usr\/lib/d' foo.dot
sed -i '/\/opt\/ros/d' foo.dot
sed -i '/unittest/d' foo.dot
sed -i '/integrationtest/d' foo.dot
```
## Include Custom Targets (needs CMake 3.18 -> NOT tried yet: https://askubuntu.com/questions/829310/how-to-upgrade-cmake-in-ubuntu)
```
set(GRAPHVIZ_EXTERNAL_LIBS FALSE)
set(GRAPHVIZ_IGNORE_TARGETS "gtest;gmock;unittest*;integrationtest*")
set(GRAPHVIZ_CUSTOM_TARGETS TRUE)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment