From 840389b64f54b1b239df4b17c329e1e79dfddd42 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Tue, 24 Jun 2003 15:24:30 -0400 Subject: [PATCH] moved depend code into cmTarget --- Source/cmLocalVisualStudio6Generator.cxx | 95 ++--------------------- Source/cmLocalVisualStudio7Generator.cxx | 96 ++---------------------- 2 files changed, 16 insertions(+), 175 deletions(-) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index c76a62960..0d6a830af 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -20,7 +20,6 @@ #include "cmSystemTools.h" #include "cmSourceFile.h" #include "cmCacheManager.h" -#include #include @@ -225,9 +224,6 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, const char *libName, cmTarget &target) { - // We may be modifying the source groups temporarily, so make a copy. - std::vector sourceGroups = m_Makefile->GetSourceGroups(); - // if we should add regen rule then... const char *suppRegenRule = m_Makefile->GetDefinition("CMAKE_SUPPRESS_REGENERATION"); @@ -235,92 +231,17 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, { this->AddDSPBuildRule(); } + + // trace the visual studio dependencies + std::string name = libName; + name += ".dsp.cmake"; + target.TraceVSDependencies(name, m_Makefile); + // We may be modifying the source groups temporarily, so make a copy. + std::vector sourceGroups = m_Makefile->GetSourceGroups(); + // get the classes from the source lists then add them to the groups std::vector & classes = target.GetSourceFiles(); - // use a deck to keep track of processed source files - std::queue srcFilesToProcess; - std::string name; - for(std::vector::const_iterator i = classes.begin(); - i != classes.end(); ++i) - { - name = (*i)->GetSourceName(); - if ((*i)->GetSourceExtension() != "rule") - { - name += "."; - name += (*i)->GetSourceExtension(); - } - srcFilesToProcess.push(name); - } - name = libName; - name += ".dsp.cmake"; - srcFilesToProcess.push(name); - // add in the library depends for cusotm targets - if (target.GetType() == cmTarget::UTILITY) - { - for (std::vector::iterator ic = - target.GetPostBuildCommands().begin(); - ic != target.GetPostBuildCommands().end(); ++ic) - { - cmCustomCommand &c = *ic; - for (std::vector::iterator i = c.GetDepends().begin(); - i != c.GetDepends().end(); ++i) - { - srcFilesToProcess.push(*i); - } - } - } - while (!srcFilesToProcess.empty()) - { - // is this source the output of a custom command - cmSourceFile* outsf = - m_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; - srcFilesToProcess.push(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 = m_Makefile->GetDefinition(libPath.c_str()); - if (cacheValue) - { - // add the depend as a utility on the target - target.AddUtility(dep.c_str()); - } - else - { - srcFilesToProcess.push(outsf->GetCustomCommand()->GetDepends()[i]); - } - } - } - // finished with this SF move to the next - srcFilesToProcess.pop(); - } // now all of the source files have been properly assigned to the target // now stick them into source groups using the reg expressions diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 8d88d98b6..58621e4e7 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -21,7 +21,6 @@ #include "cmSourceFile.h" #include "cmCacheManager.h" #include "cmake.h" -#include cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator() { @@ -637,6 +636,7 @@ void cmLocalVisualStudio7Generator::OutputDefineFlags(std::ostream& fout) } } + void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, const char *libName, cmTarget &target) @@ -654,97 +654,16 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, this->AddVCProjBuildRule(); } + // trace the visual studio dependencies + std::string name = libName; + name += ".vcproj.cmake"; + target.TraceVSDependencies(name, m_Makefile); + // We may be modifying the source groups temporarily, so make a copy. std::vector sourceGroups = m_Makefile->GetSourceGroups(); // get the classes from the source lists then add them to the groups std::vector & classes = target.GetSourceFiles(); - // use a deck to keep track of processed source files - std::queue srcFilesToProcess; - std::string name; - for(std::vector::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); - } - // add in the project file itself - name = libName; - name += ".vcproj.cmake"; - srcFilesToProcess.push(name); - // add in the library depends for cusotm targets - if (target.GetType() == cmTarget::UTILITY) - { - for (std::vector::iterator ic = - target.GetPostBuildCommands().begin(); - ic != target.GetPostBuildCommands().end(); ++ic) - { - cmCustomCommand &c = *ic; - for (std::vector::iterator i = c.GetDepends().begin(); - i != c.GetDepends().end(); ++i) - { - srcFilesToProcess.push(*i); - } - } - } - while (!srcFilesToProcess.empty()) - { - // is this source the output of a custom command - cmSourceFile* outsf = - m_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; - srcFilesToProcess.push(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 = m_Makefile->GetDefinition(libPath.c_str()); - if (cacheValue) - { - // add the depend as a utility on the target - target.AddUtility(dep.c_str()); - } - else - { - srcFilesToProcess.push(outsf->GetCustomCommand()->GetDepends()[i]); - } - } - } - // finished with this SF move to the next - srcFilesToProcess.pop(); - } - - // get the classes from the source lists then add them to the groups for(std::vector::const_iterator i = classes.begin(); i != classes.end(); i++) { @@ -1089,7 +1008,8 @@ std::string cmLocalVisualStudio7Generator::EscapeForXML(const char* s) std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPath(const char* path) { std::string ret = cmSystemTools::ConvertToOutputPath(path); - return cmLocalVisualStudio7Generator::EscapeForXML(ret.c_str()); + cmSystemTools::ReplaceString(ret, "\"", """); + return ret; } std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPathSingle(const char* path)