summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmGlobalVisualStudio6Generator.cxx42
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx62
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx66
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx58
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h5
5 files changed, 97 insertions, 136 deletions
diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx
index d053ca2..fa7afc5 100644
--- a/Source/cmGlobalVisualStudio6Generator.cxx
+++ b/Source/cmGlobalVisualStudio6Generator.cxx
@@ -274,42 +274,14 @@ void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout,
fout << "Package=<5>\n{{{\n}}}\n\n";
fout << "Package=<4>\n";
fout << "{{{\n";
-
- // insert Begin Project Dependency Project_Dep_Name project stuff here
- if (target.GetType() != cmTarget::STATIC_LIBRARY)
- {
- cmTarget::LinkLibraryVectorType::const_iterator j, jend;
- j = target.GetLinkLibraries().begin();
- jend = target.GetLinkLibraries().end();
- for(;j!= jend; ++j)
- {
- if(j->first != dspname)
- {
- // is the library part of this DSW ? If so add dependency
- if(this->FindTarget(0, j->first.c_str()))
- {
- fout << "Begin Project Dependency\n";
- fout << "Project_Dep_Name "
- << GetVS6TargetName(j->first.c_str()) << "\n";
- fout << "End Project Dependency\n";
- }
- }
- }
- }
-
- std::set<cmStdString>::const_iterator i, end;
- // write utility dependencies.
- i = target.GetUtilities().begin();
- end = target.GetUtilities().end();
- for(;i!= end; ++i)
+ VSDependSet const& depends = this->VSTargetDepends[&target];
+ for(VSDependSet::const_iterator di = depends.begin();
+ di != depends.end(); ++di)
{
- if(*i != dspname)
- {
- std::string depName = this->GetUtilityForTarget(target, i->c_str());
- fout << "Begin Project Dependency\n";
- fout << "Project_Dep_Name " << GetVS6TargetName(depName) << "\n";
- fout << "End Project Dependency\n";
- }
+ const char* name = di->c_str();
+ fout << "Begin Project Dependency\n";
+ fout << "Project_Dep_Name " << GetVS6TargetName(name) << "\n";
+ fout << "End Project Dependency\n";
}
fout << "}}}\n\n";
}
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index 1191575..ac1bfa5 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -185,59 +185,21 @@ cmGlobalVisualStudio71Generator
const char* dspname,
const char*, cmTarget& target)
{
-#if 0
- // Create inter-target dependencies in the solution file. For VS
- // 7.1 and below we cannot let static libraries depend directly on
- // targets to which they "link" because the librarian tool will copy
- // the targets into the static library. See
- // cmGlobalVisualStudioGenerator::FixUtilityDependsForTarget for a
- // work-around. VS 8 and above do not have this problem.
- if (!this->VSLinksDependencies() ||
- target.GetType() != cmTarget::STATIC_LIBRARY);
-#else
- if (target.GetType() != cmTarget::STATIC_LIBRARY)
-#endif
+ VSDependSet const& depends = this->VSTargetDepends[&target];
+ for(VSDependSet::const_iterator di = depends.begin();
+ di != depends.end(); ++di)
{
- cmTarget::LinkLibraryVectorType::const_iterator j, jend;
- j = target.GetLinkLibraries().begin();
- jend = target.GetLinkLibraries().end();
- for(;j!= jend; ++j)
+ const char* name = di->c_str();
+ std::string guid = this->GetGUID(name);
+ if(guid.size() == 0)
{
- if(j->first != dspname)
- {
- // is the library part of this SLN ? If so add dependency
- // find target anywhere because all depend libraries are
- // brought in as well
- if(this->FindTarget(0, j->first.c_str()))
- {
- fout << "\t\t{" << this->GetGUID(j->first.c_str()) << "} = {"
- << this->GetGUID(j->first.c_str()) << "}\n";
- }
- }
- }
- }
-
- std::set<cmStdString>::const_iterator i, end;
- // write utility dependencies.
- i = target.GetUtilities().begin();
- end = target.GetUtilities().end();
- for(;i!= end; ++i)
- {
- if(*i != dspname)
- {
- std::string name = this->GetUtilityForTarget(target, i->c_str());
- std::string guid = this->GetGUID(name.c_str());
- if(guid.size() == 0)
- {
- std::string m = "Target: ";
- m += target.GetName();
- m += " depends on unknown target: ";
- m += name;
- cmSystemTools::Error(m.c_str());
- }
-
- fout << "\t\t{" << guid << "} = {" << guid << "}\n";
+ std::string m = "Target: ";
+ m += target.GetName();
+ m += " depends on unknown target: ";
+ m += name;
+ cmSystemTools::Error(m.c_str());
}
+ fout << "\t\t{" << guid << "} = {" << guid << "}\n";
}
}
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 9631e9a..de88131 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -422,59 +422,23 @@ cmGlobalVisualStudio7Generator
const char*, cmTarget& target)
{
int depcount = 0;
- // insert Begin Project Dependency Project_Dep_Name project stuff here
- if (target.GetType() != cmTarget::STATIC_LIBRARY)
- {
- cmTarget::LinkLibraryVectorType::const_iterator j, jend;
- j = target.GetLinkLibraries().begin();
- jend = target.GetLinkLibraries().end();
- for(;j!= jend; ++j)
- {
- if(j->first != dspname)
- {
- // is the library part of this SLN ? If so add dependency
- if(this->FindTarget(0, j->first.c_str()))
- {
- std::string guid = this->GetGUID(j->first.c_str());
- if(guid.size() == 0)
- {
- std::string m = "Target: ";
- m += dspname;
- m += " depends on unknown target: ";
- m += j->first.c_str();
- cmSystemTools::Error(m.c_str());
- }
- fout << "\t\t{" << this->GetGUID(dspname) << "}."
- << depcount << " = {" << guid << "}\n";
- depcount++;
- }
- }
- }
- }
-
- std::set<cmStdString>::const_iterator i, end;
- // write utility dependencies.
- i = target.GetUtilities().begin();
- end = target.GetUtilities().end();
- for(;i!= end; ++i)
- {
- if(*i != dspname)
+ std::string dspguid = this->GetGUID(dspname);
+ VSDependSet const& depends = this->VSTargetDepends[&target];
+ for(VSDependSet::const_iterator di = depends.begin();
+ di != depends.end(); ++di)
+ {
+ const char* name = di->c_str();
+ std::string guid = this->GetGUID(name);
+ if(guid.size() == 0)
{
- std::string name = this->GetUtilityForTarget(target, i->c_str());
- std::string guid = this->GetGUID(name.c_str());
- if(guid.size() == 0)
- {
- std::string m = "Target: ";
- m += dspname;
- m += " depends on unknown target: ";
- m += name.c_str();
- cmSystemTools::Error(m.c_str());
- }
-
- fout << "\t\t{" << this->GetGUID(dspname) << "}." << depcount << " = {"
- << guid << "}\n";
- depcount++;
+ std::string m = "Target: ";
+ m += target.GetName();
+ m += " depends on unknown target: ";
+ m += name;
+ cmSystemTools::Error(m.c_str());
}
+ fout << "\t\t{" << dspguid << "}." << depcount << " = {" << guid << "}\n";
+ depcount++;
}
}
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 85b4a71..1007953 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -353,6 +353,64 @@ cmGlobalVisualStudioGenerator::CreateUtilityDependTarget(cmTarget& target)
}
//----------------------------------------------------------------------------
+bool cmGlobalVisualStudioGenerator::ComputeTargetDepends()
+{
+ if(!this->cmGlobalGenerator::ComputeTargetDepends())
+ {
+ return false;
+ }
+ std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
+ for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
+ {
+ std::vector<cmLocalGenerator*>& gen = it->second;
+ for(std::vector<cmLocalGenerator*>::iterator i = gen.begin();
+ i != gen.end(); ++i)
+ {
+ cmTargets& targets = (*i)->GetMakefile()->GetTargets();
+ for(cmTargets::iterator ti = targets.begin();
+ ti != targets.end(); ++ti)
+ {
+ this->ComputeVSTargetDepends(ti->second);
+ }
+ }
+ }
+ return true;
+}
+
+//----------------------------------------------------------------------------
+void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target)
+{
+ if(this->VSTargetDepends.find(&target) != this->VSTargetDepends.end())
+ {
+ return;
+ }
+ VSDependSet& vsTargetDepend = this->VSTargetDepends[&target];
+ if(target.GetType() != cmTarget::STATIC_LIBRARY)
+ {
+ cmTarget::LinkLibraryVectorType const& libs = target.GetLinkLibraries();
+ for(cmTarget::LinkLibraryVectorType::const_iterator j = libs.begin();
+ j != libs.end(); ++j)
+ {
+ if(j->first != target.GetName() &&
+ this->FindTarget(0, j->first.c_str()))
+ {
+ vsTargetDepend.insert(j->first);
+ }
+ }
+ }
+ std::set<cmStdString> const& utils = target.GetUtilities();
+ for(std::set<cmStdString>::const_iterator i = utils.begin();
+ i != utils.end(); ++i)
+ {
+ if(*i != target.GetName())
+ {
+ std::string name = this->GetUtilityForTarget(target, i->c_str());
+ vsTargetDepend.insert(name);
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
bool cmGlobalVisualStudioGenerator::CheckTargetLinks(cmTarget& target,
const char* name)
{
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index b0be087..3d499e3 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -93,6 +93,11 @@ protected:
virtual void GetTargetSets(TargetDependSet& projectTargets,
TargetDependSet& originalTargets,
cmLocalGenerator* root, GeneratorVector const&);
+ virtual bool ComputeTargetDepends();
+ class VSDependSet: public std::set<cmStdString> {};
+ class VSDependMap: public std::map<cmTarget*, VSDependSet> {};
+ VSDependMap VSTargetDepends;
+ void ComputeVSTargetDepends(cmTarget&);
bool CheckTargetLinks(cmTarget& target, const char* name);
private: