1 #ifndef CMGRAPHVIZWRITER_H
2 #define CMGRAPHVIZWRITER_H
3 /*============================================================================
4 CMake - Cross Platform Makefile Generator
5 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
7 Distributed under the OSI-approved BSD License (the "License");
8 see accompanying file Copyright.txt for details.
10 This software is distributed WITHOUT ANY WARRANTY; without even the
11 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 See the License for more information.
13 ============================================================================*/
14 #include "cmStandardIncludes.h"
15 #include "cmLocalGenerator.h"
16 #include "cmGeneratedFileStream.h"
18 #include <cmsys/RegularExpression.hxx>
21 /** This class implements writing files for graphviz (dot) for graphs
22 * representing the dependencies between the targets in the project. */
23 class cmGraphVizWriter
27 cmGraphVizWriter(const std::vector<cmLocalGenerator*>& localGenerators);
29 void ReadSettings(const char* settingsFileName,
30 const char* fallbackSettingsFileName);
32 void WritePerTargetFiles(const char* fileName);
33 void WriteTargetDependersFiles(const char* fileName);
35 void WriteGlobalFile(const char* fileName);
39 void CollectTargetsAndLibs();
41 int CollectAllTargets();
43 int CollectAllExternalLibs(int cnt);
45 void WriteHeader(cmGeneratedFileStream& str) const;
47 void WriteConnections(const char* targetName,
48 std::set<std::string>& insertedNodes,
49 std::set<std::string>& insertedConnections,
50 cmGeneratedFileStream& str) const;
52 void WriteDependerConnections(const char* targetName,
53 std::set<std::string>& insertedNodes,
54 std::set<std::string>& insertedConnections,
55 cmGeneratedFileStream& str) const;
57 void WriteNode(const char* targetName, const cmTarget* target,
58 std::set<std::string>& insertedNodes,
59 cmGeneratedFileStream& str) const;
61 void WriteFooter(cmGeneratedFileStream& str) const;
63 bool IgnoreThisTarget(const char* name);
65 bool GenerateForTargetType(cmTarget::TargetType targetType) const;
67 cmStdString GraphType;
68 cmStdString GraphName;
69 cmStdString GraphHeader;
70 cmStdString GraphNodePrefix;
72 bool GenerateForExecutables;
73 bool GenerateForStaticLibs;
74 bool GenerateForSharedLibs;
75 bool GenerateForModuleLibs;
76 bool GenerateForExternals;
78 std::vector<cmsys::RegularExpression> TargetsToIgnoreRegex;
80 const std::vector<cmLocalGenerator*>& LocalGenerators;
82 std::map<cmStdString, const cmTarget*> TargetPtrs;
83 // maps from the actual target names to node names in dot:
84 std::map<cmStdString, cmStdString> TargetNamesNodes;
86 bool HaveTargetsAndLibs;