Factor out duplicate VS target dependency code
Compute VS target dependencies in cmGlobalVisualStudioGenerator when the main global dependency analysis is done. Use these results in each of the VS generators instead of duplicating the analysis.
This commit is contained in:
parent
6bea84353c
commit
325bdb2a92
|
@ -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)
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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";
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
std::string dspguid = this->GetGUID(dspname);
|
||||
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
|
||||
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 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++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -352,6 +352,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)
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue