When you add --graphviz=graph/X.dot
to the cmake command, it will generate some .dot files based on the dependencies you have.
For unix based systems, you can use the following python code to generate svg for each dot file:
import os
# read all .dot files in a path
def get_dot_files(path):
dot_files = []
for file in os.listdir(path):
if 'dot' in file:
dot_files.append(file)
return dot_files
path_2_dot_files = '/cmake-build-debug/graph'
dot_files = get_dot_files(path_2_dot_files)
# generate svg files from dot files
os.chdir(path_2_dot_files)
for dot_file in dot_files:
os.system('dot -Tsvg ' + dot_file + ' -o ' + dot_file + '.svg')
For more info refer to this link
When running CMake with the --graphviz=foo.dot option, it produces:
- a foo.dot file, showing all dependencies in the project
- a foo.dot. file for each target, showing on which other targets it depends
- a foo.dot..dependers file for each target, showing which other targets depend on it