Collect targets and libs on demand instead of in the ctor

This is necessary for the next commit which requires that
the targets are collected after the settings have been read.

Alex
This commit is contained in:
Alex Neundorf 2010-11-14 19:37:03 +01:00
parent 2a5790a080
commit 5ea1e4cb36
2 changed files with 26 additions and 6 deletions

View File

@ -55,9 +55,8 @@ cmGraphVizWriter::cmGraphVizWriter(const std::vector<cmLocalGenerator*>&
,GenerateForSharedLibs(true)
,GenerateForModuleLibs(true)
,LocalGenerators(localGenerators)
,HaveTargetsAndLibs(false)
{
int cnt = collectAllTargets();
collectAllExternalLibs(cnt);
}
@ -137,6 +136,8 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
{
this->CollectTargetsAndLibs();
for(std::map<cmStdString, const cmTarget*>::const_iterator ptrIt =
this->TargetPtrs.begin();
ptrIt != this->TargetPtrs.end();
@ -177,6 +178,8 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
void cmGraphVizWriter::WriteGlobalFile(const char* fileName)
{
this->CollectTargetsAndLibs();
cmGeneratedFileStream str(fileName);
if ( !str )
{
@ -295,7 +298,18 @@ void cmGraphVizWriter::WriteNode(const char* targetName,
}
int cmGraphVizWriter::collectAllTargets()
void cmGraphVizWriter::CollectTargetsAndLibs()
{
if (this->HaveTargetsAndLibs == false)
{
this->HaveTargetsAndLibs = true;
int cnt = this->CollectAllTargets();
this->CollectAllExternalLibs(cnt);
}
}
int cmGraphVizWriter::CollectAllTargets()
{
int cnt = 0;
// First pass get the list of all cmake targets
@ -327,7 +341,7 @@ int cmGraphVizWriter::collectAllTargets()
}
int cmGraphVizWriter::collectAllExternalLibs(int cnt)
int cmGraphVizWriter::CollectAllExternalLibs(int cnt)
{
// Ok, now find all the stuff we link to that is not in cmake
for (std::vector<cmLocalGenerator*>::const_iterator lit =

View File

@ -15,6 +15,7 @@
#include "cmLocalGenerator.h"
#include "cmGeneratedFileStream.h"
#include "cmTarget.h"
#include <cmsys/RegularExpression.hxx>
/** This class implements writing files for graphviz (dot) for graphs
@ -34,9 +35,11 @@ public:
protected:
int collectAllTargets();
void CollectTargetsAndLibs();
int collectAllExternalLibs(int cnt);
int CollectAllTargets();
int CollectAllExternalLibs(int cnt);
void WriteHeader(cmGeneratedFileStream& str) const;
@ -65,6 +68,8 @@ protected:
bool GenerateForSharedLibs;
bool GenerateForModuleLibs;
cmsys::RegularExpression TargetIgnoreRegex;
std::set<cmStdString> TargetsToIgnore;
const std::vector<cmLocalGenerator*>& LocalGenerators;
@ -73,6 +78,7 @@ protected:
// maps from the actual target names to node names in dot:
std::map<cmStdString, cmStdString> TargetNamesNodes;
bool HaveTargetsAndLibs;
};
#endif