moved function into cmTarget

This commit is contained in:
Ken Martin 2003-06-24 15:10:47 -04:00
parent 45e508f530
commit 117f961a5a
2 changed files with 110 additions and 1 deletions

View File

@ -20,6 +20,7 @@
#include <map>
#include <set>
#include <queue>
#include <stdlib.h> // required for atof
@ -35,6 +36,109 @@ void cmTarget::SetType(TargetType type)
}
void cmTarget::TraceVSDependencies(std::string projFile,
cmMakefile *makefile)
{
// get the classes from the source lists then add them to the groups
std::vector<cmSourceFile*> & classes = this->GetSourceFiles();
// use a deck to keep track of processed source files
std::queue<std::string> srcFilesToProcess;
std::set<std::string> srcFilesQueued;
std::string name;
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); ++i)
{
std::string name = (*i)->GetSourceName();
if ((*i)->GetSourceExtension() != "rule")
{
name += ".";
name += (*i)->GetSourceExtension();
}
srcFilesToProcess.push(name);
srcFilesQueued.insert(name);
}
// add in the project file itself
srcFilesToProcess.push(projFile);
srcFilesQueued.insert(projFile);
// add in the library depends for cusotm targets
if (this->GetType() == cmTarget::UTILITY)
{
for (std::vector<cmCustomCommand>::iterator ic =
this->GetPostBuildCommands().begin();
ic != this->GetPostBuildCommands().end(); ++ic)
{
cmCustomCommand &c = *ic;
for (std::vector<std::string>::iterator i = c.GetDepends().begin();
i != c.GetDepends().end(); ++i)
{
srcFilesToProcess.push(*i);
srcFilesQueued.insert(name);
}
}
}
while (!srcFilesToProcess.empty())
{
// is this source the output of a custom command
cmSourceFile* outsf =
makefile->GetSourceFileWithOutput(srcFilesToProcess.front().c_str());
if (outsf)
{
// is it not already in the target?
if (std::find(classes.begin(),classes.end(),outsf) == classes.end())
{
// then add the source to this target and add it to the queue
classes.push_back(outsf);
std::string name = outsf->GetSourceName();
if (outsf->GetSourceExtension() != "rule")
{
name += ".";
name += outsf->GetSourceExtension();
}
std::string temp =
cmSystemTools::GetFilenamePath(outsf->GetFullPath());
temp += "/";
temp += name;
// if it hasn't been processed
if (srcFilesQueued.find(temp) == srcFilesQueued.end())
{
srcFilesToProcess.push(temp);
srcFilesQueued.insert(temp);
}
}
// add its dependencies to the list to check
unsigned int i;
for (i = 0; i < outsf->GetCustomCommand()->GetDepends().size(); ++i)
{
std::string dep = cmSystemTools::GetFilenameName(
outsf->GetCustomCommand()->GetDepends()[i]);
if (cmSystemTools::GetFilenameLastExtension(dep) == ".exe")
{
dep = cmSystemTools::GetFilenameWithoutLastExtension(dep);
}
// watch for target dependencies,
std::string libPath = dep + "_CMAKE_PATH";
const char* cacheValue = makefile->GetDefinition(libPath.c_str());
if (cacheValue)
{
// add the depend as a utility on the target
this->AddUtility(dep.c_str());
}
else
{
if (srcFilesQueued.find(outsf->GetCustomCommand()->GetDepends()[i])
== srcFilesQueued.end())
{
srcFilesToProcess.push(outsf->GetCustomCommand()->GetDepends()[i]);
srcFilesQueued.insert(outsf->GetCustomCommand()->GetDepends()[i]);
}
}
}
}
// finished with this SF move to the next
srcFilesToProcess.pop();
}
}
void cmTarget::GenerateSourceFilesFromSourceLists( cmMakefile &mf)
{
// this is only done for non install targets

View File

@ -142,6 +142,12 @@ public:
const char *GetProperty(const char *prop) const;
bool GetPropertyAsBool(const char *prop) const;
/**
* Trace through the source files in this target and add al source files
* that they depend on, used by the visual studio generators
*/
void TraceVSDependencies(std::string projName, cmMakefile *mf);
private:
/**
* A list of direct dependencies. Use in conjunction with DependencyMap.
@ -196,7 +202,6 @@ private:
void GatherDependencies( const cmMakefile& mf, const std::string& lib,
DependencyMap& dep_map );
private:
std::vector<cmCustomCommand> m_PreBuildCommands;
std::vector<cmCustomCommand> m_PreLinkCommands;