VS: Port interface to cmGeneratorTarget

This commit is contained in:
Stephen Kelly 2015-10-23 18:26:48 +02:00
parent 97b3768898
commit 6cac952b9e
7 changed files with 39 additions and 38 deletions

View File

@ -94,7 +94,8 @@ public:
/** Return true if the target project file should have the option /** Return true if the target project file should have the option
LinkLibraryDependencies and link to .sln dependencies. */ LinkLibraryDependencies and link to .sln dependencies. */
virtual bool NeedLinkLibraryDependencies(cmTarget&) { return false; } virtual bool NeedLinkLibraryDependencies(cmGeneratorTarget*)
{ return false; }
const char* GetIntelProjectVersion(); const char* GetIntelProjectVersion();

View File

@ -460,14 +460,15 @@ void cmGlobalVisualStudio8Generator::WriteProjectDepends(
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies( bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies(
cmTarget& target) cmGeneratorTarget *target)
{ {
// Look for utility dependencies that magically link. // Look for utility dependencies that magically link.
for(std::set<std::string>::const_iterator ui = for(std::set<std::string>::const_iterator ui =
target.GetUtilities().begin(); target->Target->GetUtilities().begin();
ui != target.GetUtilities().end(); ++ui) ui != target->Target->GetUtilities().end(); ++ui)
{ {
if(cmTarget* depTarget = this->FindTarget(ui->c_str())) if(cmGeneratorTarget* depTarget =
target->GetLocalGenerator()->FindGeneratorTargetToUse(ui->c_str()))
{ {
if(depTarget->GetType() != cmState::INTERFACE_LIBRARY if(depTarget->GetType() != cmState::INTERFACE_LIBRARY
&& depTarget->GetProperty("EXTERNAL_MSPROJECT")) && depTarget->GetProperty("EXTERNAL_MSPROJECT"))

View File

@ -60,7 +60,7 @@ public:
/** Return true if the target project file should have the option /** Return true if the target project file should have the option
LinkLibraryDependencies and link to .sln dependencies. */ LinkLibraryDependencies and link to .sln dependencies. */
virtual bool NeedLinkLibraryDependencies(cmTarget& target); virtual bool NeedLinkLibraryDependencies(cmGeneratorTarget* target);
/** Return true if building for Windows CE */ /** Return true if building for Windows CE */
virtual bool TargetsWindowsCE() const { virtual bool TargetsWindowsCE() const {

View File

@ -307,7 +307,7 @@ void cmGlobalVisualStudioGenerator::FillLinkClosure(
const cmGeneratorTarget *target, const cmGeneratorTarget *target,
TargetSet& linked) TargetSet& linked)
{ {
if(linked.insert(target->Target).second) if(linked.insert(target).second)
{ {
TargetDependSet const& depends = TargetDependSet const& depends =
this->GetTargetDirectDepends(target); this->GetTargetDirectDepends(target);
@ -326,10 +326,10 @@ void cmGlobalVisualStudioGenerator::FillLinkClosure(
cmGlobalVisualStudioGenerator::TargetSet const& cmGlobalVisualStudioGenerator::TargetSet const&
cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmGeneratorTarget* target) cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmGeneratorTarget* target)
{ {
TargetSetMap::iterator i = this->TargetLinkClosure.find(target->Target); TargetSetMap::iterator i = this->TargetLinkClosure.find(target);
if(i == this->TargetLinkClosure.end()) if(i == this->TargetLinkClosure.end())
{ {
TargetSetMap::value_type entry(target->Target, TargetSet()); TargetSetMap::value_type entry(target, TargetSet());
i = this->TargetLinkClosure.insert(entry).first; i = this->TargetLinkClosure.insert(entry).first;
this->FillLinkClosure(target, i->second); this->FillLinkClosure(target, i->second);
} }
@ -338,7 +338,8 @@ cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmGeneratorTarget* target)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudioGenerator::FollowLinkDepends( void cmGlobalVisualStudioGenerator::FollowLinkDepends(
cmTarget const* target, std::set<cmTarget const*>& linked) const cmGeneratorTarget *target,
std::set<const cmGeneratorTarget *> &linked)
{ {
if(target->GetType() == cmState::INTERFACE_LIBRARY) if(target->GetType() == cmState::INTERFACE_LIBRARY)
{ {
@ -349,14 +350,13 @@ void cmGlobalVisualStudioGenerator::FollowLinkDepends(
{ {
// Static library targets do not list their link dependencies so // Static library targets do not list their link dependencies so
// we must follow them transitively now. // we must follow them transitively now.
cmGeneratorTarget* gt = this->GetGeneratorTarget(target); TargetDependSet const& depends = this->GetTargetDirectDepends(target);
TargetDependSet const& depends = this->GetTargetDirectDepends(gt);
for(TargetDependSet::const_iterator di = depends.begin(); for(TargetDependSet::const_iterator di = depends.begin();
di != depends.end(); ++di) di != depends.end(); ++di)
{ {
if(di->IsLink()) if(di->IsLink())
{ {
this->FollowLinkDepends((*di)->Target, linked); this->FollowLinkDepends(*di, linked);
} }
} }
} }
@ -431,7 +431,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(
// Collect implicit link dependencies (target_link_libraries). // Collect implicit link dependencies (target_link_libraries).
// Static libraries cannot depend on their link implementation // Static libraries cannot depend on their link implementation
// due to behavior (2), but they do not really need to. // due to behavior (2), but they do not really need to.
std::set<cmTarget const*> linkDepends; std::set<cmGeneratorTarget const*> linkDepends;
if(target->GetType() != cmState::STATIC_LIBRARY) if(target->GetType() != cmState::STATIC_LIBRARY)
{ {
for(TargetDependSet::const_iterator di = depends.begin(); for(TargetDependSet::const_iterator di = depends.begin();
@ -440,20 +440,20 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(
cmTargetDepend dep = *di; cmTargetDepend dep = *di;
if(dep.IsLink()) if(dep.IsLink())
{ {
this->FollowLinkDepends(dep->Target, linkDepends); this->FollowLinkDepends(*di, linkDepends);
} }
} }
} }
// Collect explicit util dependencies (add_dependencies). // Collect explicit util dependencies (add_dependencies).
std::set<cmTarget const*> utilDepends; std::set<cmGeneratorTarget const*> utilDepends;
for(TargetDependSet::const_iterator di = depends.begin(); for(TargetDependSet::const_iterator di = depends.begin();
di != depends.end(); ++di) di != depends.end(); ++di)
{ {
cmTargetDepend dep = *di; cmTargetDepend dep = *di;
if(dep.IsUtil()) if(dep.IsUtil())
{ {
this->FollowLinkDepends(dep->Target, utilDepends); this->FollowLinkDepends(*di, utilDepends);
} }
} }
@ -466,23 +466,22 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(
} }
// Emit link dependencies. // Emit link dependencies.
for(std::set<cmTarget const*>::iterator di = linkDepends.begin(); for(std::set<cmGeneratorTarget const*>::iterator di = linkDepends.begin();
di != linkDepends.end(); ++di) di != linkDepends.end(); ++di)
{ {
cmTarget const* dep = *di; cmGeneratorTarget const* dep = *di;
vsTargetDepend.insert(dep->GetName()); vsTargetDepend.insert(dep->GetName());
} }
// Emit util dependencies. Possibly use intermediate targets. // Emit util dependencies. Possibly use intermediate targets.
for(std::set<cmTarget const*>::iterator di = utilDepends.begin(); for(std::set<cmGeneratorTarget const*>::iterator di = utilDepends.begin();
di != utilDepends.end(); ++di) di != utilDepends.end(); ++di)
{ {
cmTarget const* dep = *di; cmGeneratorTarget const* dgt = *di;
cmGeneratorTarget* dgt = this->GetGeneratorTarget(dep); if(allowLinkable || !VSLinkable(dgt) || linked.count(dgt))
if(allowLinkable || !VSLinkable(dgt) || linked.count(dep))
{ {
// Direct dependency allowed. // Direct dependency allowed.
vsTargetDepend.insert(dep->GetName()); vsTargetDepend.insert(dgt->GetName());
} }
else else
{ {
@ -892,9 +891,7 @@ cmGlobalVisualStudioGenerator::OrderedTargetDependSet
for (TargetSet::const_iterator it = targets.begin(); for (TargetSet::const_iterator it = targets.begin();
it != targets.end(); ++it) it != targets.end(); ++it)
{ {
cmGeneratorTarget* gt = this->insert(*it);
(*it)->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(*it);
this->insert(gt);
} }
} }

View File

@ -88,7 +88,7 @@ public:
/** Return true if building for Windows CE */ /** Return true if building for Windows CE */
virtual bool TargetsWindowsCE() const { return false; } virtual bool TargetsWindowsCE() const { return false; }
class TargetSet: public std::set<cmTarget const*> {}; class TargetSet: public std::set<cmGeneratorTarget const*> {};
class TargetCompare class TargetCompare
{ {
std::string First; std::string First;
@ -126,8 +126,9 @@ protected:
VSDependMap VSTargetDepends; VSDependMap VSTargetDepends;
void ComputeVSTargetDepends(cmGeneratorTarget *); void ComputeVSTargetDepends(cmGeneratorTarget *);
bool CheckTargetLinks(cmTarget& target, const std::string& name); bool CheckTargetLinks(cmGeneratorTarget& target, const std::string& name);
std::string GetUtilityForTarget(cmTarget& target, const std::string&); std::string GetUtilityForTarget(cmGeneratorTarget& target,
const std::string&);
virtual std::string WriteUtilityDepend(cmGeneratorTarget const*) = 0; virtual std::string WriteUtilityDepend(cmGeneratorTarget const*) = 0;
std::string GetUtilityDepend(const cmGeneratorTarget *target); std::string GetUtilityDepend(const cmGeneratorTarget *target);
typedef std::map<cmGeneratorTarget const*, std::string> UtilityDependsMap; typedef std::map<cmGeneratorTarget const*, std::string> UtilityDependsMap;
@ -141,13 +142,14 @@ private:
void PrintCompilerAdvice(std::ostream&, std::string const&, void PrintCompilerAdvice(std::ostream&, std::string const&,
const char*) const {} const char*) const {}
void FollowLinkDepends(cmTarget const* target, void FollowLinkDepends(cmGeneratorTarget const* target,
std::set<cmTarget const*>& linked); std::set<cmGeneratorTarget const*>& linked);
class TargetSetMap: public std::map<cmTarget*, TargetSet> {}; class TargetSetMap: public std::map<cmGeneratorTarget*, TargetSet> {};
TargetSetMap TargetLinkClosure; TargetSetMap TargetLinkClosure;
void FillLinkClosure(cmGeneratorTarget const* target, TargetSet& linked); void FillLinkClosure(const cmGeneratorTarget *target,
TargetSet const& GetTargetLinkClosure(cmGeneratorTarget *target); TargetSet& linked);
TargetSet const& GetTargetLinkClosure(cmGeneratorTarget* target);
}; };
class cmGlobalVisualStudioGenerator::OrderedTargetDependSet: class cmGlobalVisualStudioGenerator::OrderedTargetDependSet:

View File

@ -1186,7 +1186,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
} }
fout << "\t\t\t<Tool\n" fout << "\t\t\t<Tool\n"
<< "\t\t\t\tName=\"" << tool << "\"\n"; << "\t\t\t\tName=\"" << tool << "\"\n";
if(!gg->NeedLinkLibraryDependencies(*target->Target)) if(!gg->NeedLinkLibraryDependencies(target))
{ {
fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n"; fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n";
} }
@ -1285,7 +1285,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
} }
fout << "\t\t\t<Tool\n" fout << "\t\t\t<Tool\n"
<< "\t\t\t\tName=\"" << tool << "\"\n"; << "\t\t\t\tName=\"" << tool << "\"\n";
if(!gg->NeedLinkLibraryDependencies(*target->Target)) if(!gg->NeedLinkLibraryDependencies(target))
{ {
fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n"; fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n";
} }

View File

@ -2677,7 +2677,7 @@ cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& config)
this->WriteString("</Link>\n", 2); this->WriteString("</Link>\n", 2);
if(!this->GlobalGenerator->NeedLinkLibraryDependencies( if(!this->GlobalGenerator->NeedLinkLibraryDependencies(
*this->GeneratorTarget->Target)) this->GeneratorTarget))
{ {
this->WriteString("<ProjectReference>\n", 2); this->WriteString("<ProjectReference>\n", 2);
this->WriteString( this->WriteString(