• Software
    • CMake Graphviz Output Cleaner
    • FlickrExifTagger
    • copyiptcandxmp
  • Vita
  • Contact
Semipol

CMake Graphviz Output Cleaner

CMake has the ability to produce a Graphviz dot file for a project that displays the dependencies of each target in the project. Unfortunately the generated output file cannot be customized in any way. For bigger projects this normally results in a really huge graph that doesn’t help very much because of the many links. Especially the fact that external libraries are displayed in the graph can be very annoying.

To solve this problem I wrote a simple post-processor script in Python that takes the dot fileĀ  generated by CMake and filters it by simple text matching on the nodes.

Usage

First you must tell CMake to generate a dot file with the project dependencies. This is done with the –graphviz=[file] option. The cleaner script then works on this dot file as described in the program help:

1
2
3
4
5
6
7
8
Usage: graphviz-cleaner.py [options] <input dot source>
 
Options:
-h, --help            show this help message and exit
-f FILE, --file=FILE  write processed dot graph source to FILE (default = cleaned.dot)
-u, --removeusrlib    remove targets located in /usr/lib
-p PATTERNS, --pattern=PATTERNS
                       adds an additional pattern to remove nodes with

Example

Here is a short example of what can be done with this simple tool: The original dependency graph for digiKam looks like this:

digiKam CMake dependencies without cleaning

digiKam CMake dependencies without cleaning

As you can easily see, this is pretty useless.

This graph can be cleaned to:

digiKam dependencies after cleaning the generated graph

digiKam dependencies after cleaning the generated graph

This is much more useful to analyze the dependencies of the various project parts. This graph was generated with:

1
2
$ ./graphviz-cleaner.py -u -p KDE -p pthread -p imageplugin -f digiKam_cleaned.dot dependencies.dot
$ dot digiKam_cleaned.dot -Tpng -o digiKam_cleaned.png

Getting the Code

The source code is available in my svn:
https://ssl.semipol.de/svn/projects/cmake-graphviz-cleaner/
Log in with user name anonymous and password anonymous.

License

The source code is released under the terms of the GNU General Public License (GPL), version 2.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Related Sites

  • Photography portfolio
  • Profile at CoR-Lab

Tags

amd64 API assembler bash BGL book boost boost.test browser bug c++ C/C++ c64 CD CDT CMake Computer Vision continuous integration Design Patterns Documentation Doxygen Eclipse enigmail Fahrrad firefox flickr Fotos freedesktop geocaching google image processing Java jenkins linux Mensa OpenCV Panorama Python Schild Speiseplan spelling error thunderbird ubuntu Unit Testing work-planet

Categories

  • internet
  • music
  • photography
  • programming
  • system administration
  • Uncategorized
  • university

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
© Copyright 2013 - Semipol
Infinity Theme by DesignCoral / WordPress