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
LinkLibraryDependencies and link to .sln dependencies. */
virtual bool NeedLinkLibraryDependencies(cmTarget&) { return false; }
virtual bool NeedLinkLibraryDependencies(cmGeneratorTarget*)
{ return false; }
const char* GetIntelProjectVersion();

View File

@ -460,14 +460,15 @@ void cmGlobalVisualStudio8Generator::WriteProjectDepends(
//----------------------------------------------------------------------------
bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies(
cmTarget& target)
cmGeneratorTarget *target)
{
// Look for utility dependencies that magically link.
for(std::set<std::string>::const_iterator ui =
target.GetUtilities().begin();
ui != target.GetUtilities().end(); ++ui)
target->Target->GetUtilities().begin();
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
&& depTarget->GetProperty("EXTERNAL_MSPROJECT"))

View File

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

View File

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

View File

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

View File

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

View File

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