diff options
author | Ken Martin <ken.martin@kitware.com> | 2003-06-24 19:10:47 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2003-06-24 19:10:47 (GMT) |
commit | 117f961a5adda76ebb87a96b323e66aa3ec0c0b8 (patch) | |
tree | 780d564717c907579d7a2e40fa2eddde6deff2e2 /Source | |
parent | 45e508f5300b8ebcfe3a3aca24bd0906eb749e36 (diff) | |
download | CMake-117f961a5adda76ebb87a96b323e66aa3ec0c0b8.zip CMake-117f961a5adda76ebb87a96b323e66aa3ec0c0b8.tar.gz CMake-117f961a5adda76ebb87a96b323e66aa3ec0c0b8.tar.bz2 |
moved function into cmTarget
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmTarget.cxx | 104 | ||||
-rw-r--r-- | Source/cmTarget.h | 7 |
2 files changed, 110 insertions, 1 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d2b129e..08e2a4f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -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 diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 89dac6a..a222f26 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -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; |