summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Neundorf <neundorf@kde.org>2010-11-14 18:30:58 (GMT)
committerAlex Neundorf <neundorf@kde.org>2010-11-14 18:30:58 (GMT)
commit7ba2d365858d259572b22ab35ea6c709ba1514ea (patch)
tree774d08787f1263edab5953985819696689784c67
parent84ce612c65520c273aa3b1d2efd2f8f4de7d3867 (diff)
downloadCMake-7ba2d365858d259572b22ab35ea6c709ba1514ea.zip
CMake-7ba2d365858d259572b22ab35ea6c709ba1514ea.tar.gz
CMake-7ba2d365858d259572b22ab35ea6c709ba1514ea.tar.bz2
Enable/disable generating graphs depending on the target type
In CMakeGraphVizOptions.cmake you can now set GRAPHVIZ_EXECUTABLES, GRAPHVIZ_STATIC_LIBS, GRAPHVIZ_SHARED_LIBS and GRAPHVIZ_MODULE_LIBS to TRUE or FALSE depending on whether you want graphs for the targets of the respective types. Alex
-rw-r--r--Source/cmGraphVizWriter.cxx48
-rw-r--r--Source/cmGraphVizWriter.h8
2 files changed, 48 insertions, 8 deletions
diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx
index 749202b..b62badf 100644
--- a/Source/cmGraphVizWriter.cxx
+++ b/Source/cmGraphVizWriter.cxx
@@ -50,6 +50,10 @@ cmGraphVizWriter::cmGraphVizWriter(const std::vector<cmLocalGenerator*>&
,GraphName("GG")
,GraphHeader("node [\n fontsize = \"12\"\n];")
,GraphNodePrefix("node")
+,GenerateForExecutables(true)
+,GenerateForStaticLibs(true)
+,GenerateForSharedLibs(true)
+,GenerateForModuleLibs(true)
,LocalGenerators(localGenerators)
{
int cnt = collectAllTargets();
@@ -100,6 +104,20 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
__set_if_set(this->GraphHeader, "GRAPHVIZ_GRAPH_HEADER");
__set_if_set(this->GraphNodePrefix, "GRAPHVIZ_NODE_PREFIX");
+#define __set_bool_if_set(var, cmakeDefinition) \
+ { \
+ const char* value = mf->GetDefinition(cmakeDefinition); \
+ if ( value ) \
+ { \
+ var = mf->IsOn(cmakeDefinition); \
+ } \
+ }
+
+ __set_bool_if_set(this->GenerateForExecutables, "GRAPHVIZ_EXECUTABLES");
+ __set_bool_if_set(this->GenerateForStaticLibs, "GRAPHVIZ_STATIC_LIBS");
+ __set_bool_if_set(this->GenerateForSharedLibs, "GRAPHVIZ_SHARED_LIBS");
+ __set_bool_if_set(this->GenerateForModuleLibs , "GRAPHVIZ_MODULE_LIBS");
+
this->TargetsToIgnore.clear();
const char* ignoreTargets = mf->GetDefinition("GRAPHVIZ_IGNORE_TARGETS");
if ( ignoreTargets )
@@ -129,10 +147,7 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
continue;
}
- if ((ptrIt->second->GetType() != cmTarget::EXECUTABLE)
- && (ptrIt->second->GetType() != cmTarget::STATIC_LIBRARY)
- && (ptrIt->second->GetType() != cmTarget::SHARED_LIBRARY)
- && (ptrIt->second->GetType() != cmTarget::MODULE_LIBRARY))
+ if (this->GenerateForTargetType(ptrIt->second->GetType()) == false)
{
continue;
}
@@ -183,10 +198,7 @@ void cmGraphVizWriter::WriteGlobalFile(const char* fileName)
continue;
}
- if ((ptrIt->second->GetType() != cmTarget::EXECUTABLE)
- && (ptrIt->second->GetType() != cmTarget::STATIC_LIBRARY)
- && (ptrIt->second->GetType() != cmTarget::SHARED_LIBRARY)
- && (ptrIt->second->GetType() != cmTarget::MODULE_LIBRARY))
+ if (this->GenerateForTargetType(ptrIt->second->GetType()) == false)
{
continue;
}
@@ -368,3 +380,23 @@ bool cmGraphVizWriter::IgnoreThisTarget(const char* name) const
{
return (this->TargetsToIgnore.find(name) != this->TargetsToIgnore.end());
}
+
+
+bool cmGraphVizWriter::GenerateForTargetType(cmTarget::TargetType targetType)
+ const
+{
+ switch (targetType)
+ {
+ case cmTarget::EXECUTABLE:
+ return this->GenerateForExecutables;
+ case cmTarget::STATIC_LIBRARY:
+ return this->GenerateForStaticLibs;
+ case cmTarget::SHARED_LIBRARY:
+ return this->GenerateForSharedLibs;
+ case cmTarget::MODULE_LIBRARY:
+ return this->GenerateForModuleLibs;
+ default:
+ break;
+ }
+ return false;
+}
diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h
index fd3d3e2..af8b716 100644
--- a/Source/cmGraphVizWriter.h
+++ b/Source/cmGraphVizWriter.h
@@ -14,6 +14,7 @@
#include "cmStandardIncludes.h"
#include "cmLocalGenerator.h"
#include "cmGeneratedFileStream.h"
+#include "cmTarget.h"
/** This class implements writing files for graphviz (dot) for graphs
@@ -52,11 +53,18 @@ protected:
bool IgnoreThisTarget(const char* name) const;
+ bool GenerateForTargetType(cmTarget::TargetType targetType) const;
+
cmStdString GraphType;
cmStdString GraphName;
cmStdString GraphHeader;
cmStdString GraphNodePrefix;
+ bool GenerateForExecutables;
+ bool GenerateForStaticLibs;
+ bool GenerateForSharedLibs;
+ bool GenerateForModuleLibs;
+
const std::vector<cmLocalGenerator*>& LocalGenerators;
std::map<cmStdString, const cmTarget*> TargetPtrs;