Merge topic 'refactor-link-internals'
f5c18c9c
cmTarget: Drop GetDirectLinkLibraries methods281eb3d8
cmTarget: Improve HaveBuildTreeRPATH implementationd912220e
cmTarget: Lookup targets in LinkInterface and LinkImplementationedce4351
cmExportFileGenerator: Make SetImportLinkProperty a template097be413
cmTarget: Add GetUtilityItems to get target ordering dependencies4dad5fd2
cmTarget: Add cmLinkItem to refer to a target by name and pointera2723442
Fix scope of transitive target name lookups069d60fe
cmTarget: Add method to lookup other targets in a target's scope47ab3ca6
cmTarget: Constify GetLinkImplementationClosure results9f3ed029
cmTarget: Constify GetTransitivePropertyTargets results6f0951af
cmTarget: Drop 'head' target from GetImportInfo0dc9e88d
cmTarget: Remove 'head' argument from GetLinkImplementation4ac72455
cmTarget: Drop 'head' argument from GetLinkClosurebcdb7ff9
cmTarget: Remove 'head' argument from GetLinkerLanguagebd9b667b
cmComputeLinkInformation: Remove 'head' argument06328dd5
cmTarget: Remove 'head' argument from GetLinkInformation ...
This commit is contained in:
commit
cbf0107977
|
@ -172,12 +172,10 @@ satisfy dependencies.
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
cmComputeLinkDepends
|
||||
::cmComputeLinkDepends(cmTarget const* target, const std::string& config,
|
||||
cmTarget const* head)
|
||||
::cmComputeLinkDepends(cmTarget const* target, const std::string& config)
|
||||
{
|
||||
// Store context information.
|
||||
this->Target = target;
|
||||
this->HeadTarget = head;
|
||||
this->Makefile = this->Target->GetMakefile();
|
||||
this->LocalGenerator = this->Makefile->GetLocalGenerator();
|
||||
this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator();
|
||||
|
@ -294,8 +292,7 @@ cmComputeLinkDepends::AllocateLinkEntry(std::string const& item)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int cmComputeLinkDepends::AddLinkEntry(int depender_index,
|
||||
std::string const& item)
|
||||
int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item)
|
||||
{
|
||||
// Check if the item entry has already been added.
|
||||
std::map<std::string, int>::iterator lei = this->LinkEntryIndex.find(item);
|
||||
|
@ -312,7 +309,7 @@ int cmComputeLinkDepends::AddLinkEntry(int depender_index,
|
|||
int index = lei->second;
|
||||
LinkEntry& entry = this->EntryList[index];
|
||||
entry.Item = item;
|
||||
entry.Target = this->FindTargetToLink(depender_index, entry.Item);
|
||||
entry.Target = item.Target;
|
||||
entry.IsFlag = (!entry.Target && item[0] == '-' && item[1] != 'l' &&
|
||||
item.substr(0, 10) != "-framework");
|
||||
|
||||
|
@ -356,7 +353,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe)
|
|||
{
|
||||
// Follow the target dependencies.
|
||||
if(cmTarget::LinkInterface const* iface =
|
||||
entry.Target->GetLinkInterface(this->Config, this->HeadTarget))
|
||||
entry.Target->GetLinkInterface(this->Config, this->Target))
|
||||
{
|
||||
const bool isIface =
|
||||
entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY;
|
||||
|
@ -372,11 +369,11 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe)
|
|||
this->FollowSharedDeps(depender_index, iface);
|
||||
|
||||
// Support for CMP0003.
|
||||
for(std::vector<std::string>::const_iterator
|
||||
for(std::vector<cmLinkItem>::const_iterator
|
||||
oi = iface->WrongConfigLibraries.begin();
|
||||
oi != iface->WrongConfigLibraries.end(); ++oi)
|
||||
{
|
||||
this->CheckWrongConfigItem(depender_index, *oi);
|
||||
this->CheckWrongConfigItem(*oi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -408,9 +405,9 @@ cmComputeLinkDepends
|
|||
void
|
||||
cmComputeLinkDepends
|
||||
::QueueSharedDependencies(int depender_index,
|
||||
std::vector<std::string> const& deps)
|
||||
std::vector<cmLinkItem> const& deps)
|
||||
{
|
||||
for(std::vector<std::string>::const_iterator li = deps.begin();
|
||||
for(std::vector<cmLinkItem>::const_iterator li = deps.begin();
|
||||
li != deps.end(); ++li)
|
||||
{
|
||||
SharedDepEntry qe;
|
||||
|
@ -434,8 +431,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
|
|||
// Initialize the item entry.
|
||||
LinkEntry& entry = this->EntryList[lei->second];
|
||||
entry.Item = dep.Item;
|
||||
entry.Target = this->FindTargetToLink(dep.DependerIndex,
|
||||
dep.Item);
|
||||
entry.Target = dep.Item.Target;
|
||||
|
||||
// This item was added specifically because it is a dependent
|
||||
// shared library. It may get special treatment
|
||||
|
@ -455,7 +451,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
|
|||
if(entry.Target)
|
||||
{
|
||||
if(cmTarget::LinkInterface const* iface =
|
||||
entry.Target->GetLinkInterface(this->Config, this->HeadTarget))
|
||||
entry.Target->GetLinkInterface(this->Config, this->Target))
|
||||
{
|
||||
// Follow public and private dependencies transitively.
|
||||
this->FollowSharedDeps(index, iface, true);
|
||||
|
@ -474,7 +470,7 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
|
|||
cmSystemTools::ExpandListArgument(value, deplist);
|
||||
|
||||
// Look for entries meant for this configuration.
|
||||
std::vector<std::string> actual_libs;
|
||||
std::vector<cmLinkItem> actual_libs;
|
||||
cmTarget::LinkLibraryType llt = cmTarget::GENERAL;
|
||||
bool haveLLT = false;
|
||||
for(std::vector<std::string>::const_iterator di = deplist.begin();
|
||||
|
@ -522,11 +518,13 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
|
|||
// If the library is meant for this link type then use it.
|
||||
if(llt == cmTarget::GENERAL || llt == this->LinkType)
|
||||
{
|
||||
actual_libs.push_back(*di);
|
||||
cmLinkItem item(*di, this->FindTargetToLink(depender_index, *di));
|
||||
actual_libs.push_back(item);
|
||||
}
|
||||
else if(this->OldLinkDirMode)
|
||||
{
|
||||
this->CheckWrongConfigItem(depender_index, *di);
|
||||
cmLinkItem item(*di, this->FindTargetToLink(depender_index, *di));
|
||||
this->CheckWrongConfigItem(item);
|
||||
}
|
||||
|
||||
// Reset the link type until another explicit type is given.
|
||||
|
@ -544,38 +542,38 @@ void cmComputeLinkDepends::AddDirectLinkEntries()
|
|||
{
|
||||
// Add direct link dependencies in this configuration.
|
||||
cmTarget::LinkImplementation const* impl =
|
||||
this->Target->GetLinkImplementation(this->Config, this->HeadTarget);
|
||||
this->Target->GetLinkImplementation(this->Config);
|
||||
this->AddLinkEntries(-1, impl->Libraries);
|
||||
for(std::vector<std::string>::const_iterator
|
||||
for(std::vector<cmLinkItem>::const_iterator
|
||||
wi = impl->WrongConfigLibraries.begin();
|
||||
wi != impl->WrongConfigLibraries.end(); ++wi)
|
||||
{
|
||||
this->CheckWrongConfigItem(-1, *wi);
|
||||
this->CheckWrongConfigItem(*wi);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
cmComputeLinkDepends::AddLinkEntries(int depender_index,
|
||||
std::vector<std::string> const& libs)
|
||||
cmComputeLinkDepends::AddLinkEntries(
|
||||
int depender_index, std::vector<cmLinkItem> const& libs)
|
||||
{
|
||||
// Track inferred dependency sets implied by this list.
|
||||
std::map<int, DependSet> dependSets;
|
||||
|
||||
// Loop over the libraries linked directly by the depender.
|
||||
for(std::vector<std::string>::const_iterator li = libs.begin();
|
||||
for(std::vector<cmLinkItem>::const_iterator li = libs.begin();
|
||||
li != libs.end(); ++li)
|
||||
{
|
||||
// Skip entries that will resolve to the target getting linked or
|
||||
// are empty.
|
||||
std::string item = this->Target->CheckCMP0004(*li);
|
||||
cmLinkItem const& item = *li;
|
||||
if(item == this->Target->GetName() || item.empty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add a link entry for this item.
|
||||
int dependee_index = this->AddLinkEntry(depender_index, item);
|
||||
int dependee_index = this->AddLinkEntry(*li);
|
||||
|
||||
// The dependee must come after the depender.
|
||||
if(depender_index >= 0)
|
||||
|
@ -625,40 +623,15 @@ cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index,
|
|||
const std::string& name)
|
||||
{
|
||||
// Look for a target in the scope of the depender.
|
||||
cmMakefile* mf = this->Makefile;
|
||||
cmTarget const* from = this->Target;
|
||||
if(depender_index >= 0)
|
||||
{
|
||||
if(cmTarget const* depender = this->EntryList[depender_index].Target)
|
||||
{
|
||||
mf = depender->GetMakefile();
|
||||
from = depender;
|
||||
}
|
||||
}
|
||||
cmTarget const* tgt = mf->FindTargetToUse(name);
|
||||
|
||||
// Skip targets that will not really be linked. This is probably a
|
||||
// name conflict between an external library and an executable
|
||||
// within the project.
|
||||
if(tgt && tgt->GetType() == cmTarget::EXECUTABLE &&
|
||||
!tgt->IsExecutableWithExports())
|
||||
{
|
||||
tgt = 0;
|
||||
}
|
||||
|
||||
if(tgt && tgt->GetType() == cmTarget::OBJECT_LIBRARY)
|
||||
{
|
||||
cmOStringStream e;
|
||||
e << "Target \"" << this->Target->GetName() << "\" links to "
|
||||
"OBJECT library \"" << tgt->GetName() << "\" but this is not "
|
||||
"allowed. "
|
||||
"One may link only to STATIC or SHARED libraries, or to executables "
|
||||
"with the ENABLE_EXPORTS property set.";
|
||||
this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
|
||||
this->Target->GetBacktrace());
|
||||
tgt = 0;
|
||||
}
|
||||
|
||||
// Return the target found, if any.
|
||||
return tgt;
|
||||
return from->FindTargetToLink(name);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -955,7 +928,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl)
|
|||
if(cmTarget const* target = this->EntryList[*ni].Target)
|
||||
{
|
||||
if(cmTarget::LinkInterface const* iface =
|
||||
target->GetLinkInterface(this->Config, this->HeadTarget))
|
||||
target->GetLinkInterface(this->Config, this->Target))
|
||||
{
|
||||
if(iface->Multiplicity > count)
|
||||
{
|
||||
|
@ -988,8 +961,7 @@ void cmComputeLinkDepends::DisplayFinalEntries()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmComputeLinkDepends::CheckWrongConfigItem(int depender_index,
|
||||
std::string const& item)
|
||||
void cmComputeLinkDepends::CheckWrongConfigItem(cmLinkItem const& item)
|
||||
{
|
||||
if(!this->OldLinkDirMode)
|
||||
{
|
||||
|
@ -999,12 +971,8 @@ void cmComputeLinkDepends::CheckWrongConfigItem(int depender_index,
|
|||
// For CMake 2.4 bug-compatibility we need to consider the output
|
||||
// directories of targets linked in another configuration as link
|
||||
// directories.
|
||||
if(cmTarget const* tgt
|
||||
= this->FindTargetToLink(depender_index, item))
|
||||
if(item.Target && !item.Target->IsImported())
|
||||
{
|
||||
if(!tgt->IsImported())
|
||||
{
|
||||
this->OldWrongConfigItems.insert(tgt);
|
||||
}
|
||||
this->OldWrongConfigItems.insert(item.Target);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,8 +32,7 @@ class cmake;
|
|||
class cmComputeLinkDepends
|
||||
{
|
||||
public:
|
||||
cmComputeLinkDepends(cmTarget const* target, const std::string& config,
|
||||
cmTarget const* head);
|
||||
cmComputeLinkDepends(cmTarget const* target, const std::string& config);
|
||||
~cmComputeLinkDepends();
|
||||
|
||||
// Basic information about each link item.
|
||||
|
@ -60,7 +59,6 @@ private:
|
|||
|
||||
// Context information.
|
||||
cmTarget const* Target;
|
||||
cmTarget const* HeadTarget;
|
||||
cmMakefile* Makefile;
|
||||
cmLocalGenerator* LocalGenerator;
|
||||
cmGlobalGenerator const* GlobalGenerator;
|
||||
|
@ -79,11 +77,11 @@ private:
|
|||
|
||||
std::map<std::string, int>::iterator
|
||||
AllocateLinkEntry(std::string const& item);
|
||||
int AddLinkEntry(int depender_index, std::string const& item);
|
||||
int AddLinkEntry(cmLinkItem const& item);
|
||||
void AddVarLinkEntries(int depender_index, const char* value);
|
||||
void AddDirectLinkEntries();
|
||||
void AddLinkEntries(int depender_index,
|
||||
std::vector<std::string> const& libs);
|
||||
std::vector<cmLinkItem> const& libs);
|
||||
cmTarget const* FindTargetToLink(int depender_index,
|
||||
const std::string& name);
|
||||
|
||||
|
@ -105,7 +103,7 @@ private:
|
|||
// of the interface.
|
||||
struct SharedDepEntry
|
||||
{
|
||||
std::string Item;
|
||||
cmLinkItem Item;
|
||||
int DependerIndex;
|
||||
};
|
||||
std::queue<SharedDepEntry> SharedDepQueue;
|
||||
|
@ -114,7 +112,7 @@ private:
|
|||
cmTarget::LinkInterface const* iface,
|
||||
bool follow_interface = false);
|
||||
void QueueSharedDependencies(int depender_index,
|
||||
std::vector<std::string> const& deps);
|
||||
std::vector<cmLinkItem> const& deps);
|
||||
void HandleSharedDependency(SharedDepEntry const& dep);
|
||||
|
||||
// Dependency inferral for each link item.
|
||||
|
@ -165,7 +163,7 @@ private:
|
|||
|
||||
// Compatibility help.
|
||||
bool OldLinkDirMode;
|
||||
void CheckWrongConfigItem(int depender_index, std::string const& item);
|
||||
void CheckWrongConfigItem(cmLinkItem const& item);
|
||||
std::set<cmTarget const*> OldWrongConfigItems;
|
||||
};
|
||||
|
||||
|
|
|
@ -239,12 +239,10 @@ because this need be done only for shared libraries without soname-s.
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
cmComputeLinkInformation
|
||||
::cmComputeLinkInformation(cmTarget const* target, const std::string& config,
|
||||
cmTarget const* headTarget)
|
||||
::cmComputeLinkInformation(cmTarget const* target, const std::string& config)
|
||||
{
|
||||
// Store context information.
|
||||
this->Target = target;
|
||||
this->HeadTarget = headTarget;
|
||||
this->Makefile = this->Target->GetMakefile();
|
||||
this->LocalGenerator = this->Makefile->GetLocalGenerator();
|
||||
this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator();
|
||||
|
@ -267,7 +265,7 @@ cmComputeLinkInformation
|
|||
this->OrderDependentRPath = 0;
|
||||
|
||||
// Get the language used for linking this target.
|
||||
this->LinkLanguage = this->Target->GetLinkerLanguage(config, headTarget);
|
||||
this->LinkLanguage = this->Target->GetLinkerLanguage(config);
|
||||
if(this->LinkLanguage.empty())
|
||||
{
|
||||
// The Compute method will do nothing, so skip the rest of the
|
||||
|
@ -505,8 +503,7 @@ bool cmComputeLinkInformation::Compute()
|
|||
}
|
||||
|
||||
// Compute the ordered link line items.
|
||||
cmComputeLinkDepends cld(this->Target, this->Config,
|
||||
this->HeadTarget);
|
||||
cmComputeLinkDepends cld(this->Target, this->Config);
|
||||
cld.SetOldLinkDirMode(this->OldLinkDirMode);
|
||||
cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute();
|
||||
|
||||
|
@ -572,8 +569,7 @@ bool cmComputeLinkInformation::Compute()
|
|||
void cmComputeLinkInformation::AddImplicitLinkInfo()
|
||||
{
|
||||
// The link closure lists all languages whose implicit info is needed.
|
||||
cmTarget::LinkClosure const* lc=this->Target->GetLinkClosure(this->Config,
|
||||
this->HeadTarget);
|
||||
cmTarget::LinkClosure const* lc=this->Target->GetLinkClosure(this->Config);
|
||||
for(std::vector<std::string>::const_iterator li = lc->Languages.begin();
|
||||
li != lc->Languages.end(); ++li)
|
||||
{
|
||||
|
@ -1972,7 +1968,7 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
|
|||
// present. This is done even when skipping rpath support.
|
||||
{
|
||||
cmTarget::LinkClosure const* lc =
|
||||
this->Target->GetLinkClosure(this->Config, this->HeadTarget);
|
||||
this->Target->GetLinkClosure(this->Config);
|
||||
for(std::vector<std::string>::const_iterator li = lc->Languages.begin();
|
||||
li != lc->Languages.end(); ++li)
|
||||
{
|
||||
|
|
|
@ -29,8 +29,7 @@ class cmOrderDirectories;
|
|||
class cmComputeLinkInformation
|
||||
{
|
||||
public:
|
||||
cmComputeLinkInformation(cmTarget const* target, const std::string& config,
|
||||
cmTarget const* headTarget);
|
||||
cmComputeLinkInformation(cmTarget const* target, const std::string& config);
|
||||
~cmComputeLinkInformation();
|
||||
bool Compute();
|
||||
|
||||
|
@ -75,7 +74,6 @@ private:
|
|||
|
||||
// Context information.
|
||||
cmTarget const* Target;
|
||||
cmTarget const* HeadTarget;
|
||||
cmMakefile* Makefile;
|
||||
cmLocalGenerator* LocalGenerator;
|
||||
cmGlobalGenerator* GlobalGenerator;
|
||||
|
|
|
@ -249,20 +249,21 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
|
|||
const_cast<cmTarget*>(depender)->AddUtility(objLib);
|
||||
}
|
||||
}
|
||||
std::vector<std::string> tlibs;
|
||||
depender->GetDirectLinkLibraries(*it, tlibs, depender);
|
||||
|
||||
cmTarget::LinkImplementation const* impl =
|
||||
depender->GetLinkImplementation(*it);
|
||||
|
||||
// A target should not depend on itself.
|
||||
emitted.insert(depender->GetName());
|
||||
for(std::vector<std::string>::const_iterator lib = tlibs.begin();
|
||||
lib != tlibs.end(); ++lib)
|
||||
for(std::vector<cmLinkItem>::const_iterator
|
||||
lib = impl->Libraries.begin();
|
||||
lib != impl->Libraries.end(); ++lib)
|
||||
{
|
||||
// Don't emit the same library twice for this target.
|
||||
if(emitted.insert(*lib).second)
|
||||
{
|
||||
this->AddTargetDepend(depender_index, *lib, true);
|
||||
this->AddInterfaceDepends(depender_index, *lib,
|
||||
true, emitted);
|
||||
this->AddInterfaceDepends(depender_index, *lib, emitted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -270,11 +271,11 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
|
|||
|
||||
// Loop over all utility dependencies.
|
||||
{
|
||||
std::set<std::string> const& tutils = depender->GetUtilities();
|
||||
std::set<cmLinkItem> const& tutils = depender->GetUtilityItems();
|
||||
std::set<std::string> emitted;
|
||||
// A target should not depend on itself.
|
||||
emitted.insert(depender->GetName());
|
||||
for(std::set<std::string>::const_iterator util = tutils.begin();
|
||||
for(std::set<cmLinkItem>::const_iterator util = tutils.begin();
|
||||
util != tutils.end(); ++util)
|
||||
{
|
||||
// Don't emit the same utility twice for this target.
|
||||
|
@ -296,7 +297,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
|
|||
if(cmTarget::LinkInterface const* iface =
|
||||
dependee->GetLinkInterface(config, depender))
|
||||
{
|
||||
for(std::vector<std::string>::const_iterator
|
||||
for(std::vector<cmLinkItem>::const_iterator
|
||||
lib = iface->Libraries.begin();
|
||||
lib != iface->Libraries.end(); ++lib)
|
||||
{
|
||||
|
@ -304,8 +305,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
|
|||
if(emitted.insert(*lib).second)
|
||||
{
|
||||
this->AddTargetDepend(depender_index, *lib, true);
|
||||
this->AddInterfaceDepends(depender_index, *lib,
|
||||
true, emitted);
|
||||
this->AddInterfaceDepends(depender_index, *lib, emitted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -313,17 +313,15 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
|
||||
const std::string& dependee_name,
|
||||
bool linking,
|
||||
cmLinkItem const& dependee_name,
|
||||
std::set<std::string> &emitted)
|
||||
{
|
||||
cmTarget const* depender = this->Targets[depender_index];
|
||||
cmTarget const* dependee =
|
||||
depender->GetMakefile()->FindTargetToUse(dependee_name);
|
||||
cmTarget const* dependee = dependee_name.Target;
|
||||
// Skip targets that will not really be linked. This is probably a
|
||||
// name conflict between an external library and an executable
|
||||
// within the project.
|
||||
if(linking && dependee &&
|
||||
if(dependee &&
|
||||
dependee->GetType() == cmTarget::EXECUTABLE &&
|
||||
!dependee->IsExecutableWithExports())
|
||||
{
|
||||
|
@ -347,16 +345,15 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmComputeTargetDepends::AddTargetDepend(int depender_index,
|
||||
const std::string& dependee_name,
|
||||
bool linking)
|
||||
void cmComputeTargetDepends::AddTargetDepend(
|
||||
int depender_index, cmLinkItem const& dependee_name,
|
||||
bool linking)
|
||||
{
|
||||
// Get the depender.
|
||||
cmTarget const* depender = this->Targets[depender_index];
|
||||
|
||||
// Check the target's makefile first.
|
||||
cmTarget const* dependee =
|
||||
depender->GetMakefile()->FindTargetToUse(dependee_name);
|
||||
cmTarget const* dependee = dependee_name.Target;
|
||||
|
||||
if(!dependee && !linking &&
|
||||
(depender->GetType() != cmTarget::GLOBAL_TARGET))
|
||||
|
@ -424,12 +421,11 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
|
|||
if(dependee->IsImported())
|
||||
{
|
||||
// Skip imported targets but follow their utility dependencies.
|
||||
std::set<std::string> const& utils = dependee->GetUtilities();
|
||||
for(std::set<std::string>::const_iterator i = utils.begin();
|
||||
std::set<cmLinkItem> const& utils = dependee->GetUtilityItems();
|
||||
for(std::set<cmLinkItem>::const_iterator i = utils.begin();
|
||||
i != utils.end(); ++i)
|
||||
{
|
||||
if(cmTarget const* transitive_dependee =
|
||||
dependee->GetMakefile()->FindTargetToUse(*i))
|
||||
if(cmTarget const* transitive_dependee = i->Target)
|
||||
{
|
||||
this->AddTargetDepend(depender_index, transitive_dependee, false);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
class cmComputeComponentGraph;
|
||||
class cmGlobalGenerator;
|
||||
class cmLinkItem;
|
||||
class cmTarget;
|
||||
class cmTargetDependSet;
|
||||
|
||||
|
@ -46,14 +47,14 @@ private:
|
|||
void CollectDepends();
|
||||
void CollectTargetDepends(int depender_index);
|
||||
void AddTargetDepend(int depender_index,
|
||||
const std::string& dependee_name,
|
||||
cmLinkItem const& dependee_name,
|
||||
bool linking);
|
||||
void AddTargetDepend(int depender_index, cmTarget const* dependee,
|
||||
bool linking);
|
||||
bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
|
||||
void AddInterfaceDepends(int depender_index,
|
||||
const std::string& dependee_name,
|
||||
bool linking, std::set<std::string> &emitted);
|
||||
cmLinkItem const& dependee_name,
|
||||
std::set<std::string> &emitted);
|
||||
void AddInterfaceDepends(int depender_index, cmTarget const* dependee,
|
||||
const std::string& config,
|
||||
std::set<std::string> &emitted);
|
||||
|
|
|
@ -865,15 +865,16 @@ cmExportFileGenerator
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void
|
||||
cmExportFileGenerator
|
||||
::SetImportLinkProperty(std::string const& suffix,
|
||||
cmTarget* target,
|
||||
const std::string& propName,
|
||||
std::vector<std::string> const& entries,
|
||||
std::vector<T> const& entries,
|
||||
ImportPropertyMap& properties,
|
||||
std::vector<std::string>& missingTargets
|
||||
)
|
||||
)
|
||||
{
|
||||
// Skip the property if there are no entries.
|
||||
if(entries.empty())
|
||||
|
@ -884,7 +885,7 @@ cmExportFileGenerator
|
|||
// Construct the property value.
|
||||
std::string link_entries;
|
||||
const char* sep = "";
|
||||
for(std::vector<std::string>::const_iterator li = entries.begin();
|
||||
for(typename std::vector<T>::const_iterator li = entries.begin();
|
||||
li != entries.end(); ++li)
|
||||
{
|
||||
// Separate this from the previous entry.
|
||||
|
@ -902,7 +903,6 @@ cmExportFileGenerator
|
|||
properties[prop] = link_entries;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmExportFileGenerator::GenerateImportHeaderCode(std::ostream& os,
|
||||
const std::string& config)
|
||||
|
|
|
@ -95,9 +95,11 @@ protected:
|
|||
std::string const& suffix, cmTarget* target,
|
||||
ImportPropertyMap& properties,
|
||||
std::vector<std::string>& missingTargets);
|
||||
|
||||
template <typename T>
|
||||
void SetImportLinkProperty(std::string const& suffix,
|
||||
cmTarget* target, const std::string& propName,
|
||||
std::vector<std::string> const& entries,
|
||||
std::vector<T> const& entries,
|
||||
ImportPropertyMap& properties,
|
||||
std::vector<std::string>& missingTargets);
|
||||
|
||||
|
|
|
@ -799,7 +799,8 @@ static const char* targetPropertyTransitiveWhitelist[] = {
|
|||
|
||||
#undef TRANSITIVE_PROPERTY_NAME
|
||||
|
||||
std::string getLinkedTargetsContent(const std::vector<cmTarget*> &targets,
|
||||
std::string getLinkedTargetsContent(
|
||||
std::vector<cmTarget const*> &targets,
|
||||
cmTarget const* target,
|
||||
cmTarget const* headTarget,
|
||||
cmGeneratorExpressionContext *context,
|
||||
|
@ -810,7 +811,7 @@ std::string getLinkedTargetsContent(const std::vector<cmTarget*> &targets,
|
|||
|
||||
std::string sep;
|
||||
std::string depString;
|
||||
for (std::vector<cmTarget*>::const_iterator
|
||||
for (std::vector<cmTarget const*>::const_iterator
|
||||
it = targets.begin();
|
||||
it != targets.end(); ++it)
|
||||
{
|
||||
|
@ -827,7 +828,7 @@ std::string getLinkedTargetsContent(const std::vector<cmTarget*> &targets,
|
|||
sep = ";";
|
||||
}
|
||||
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(depString);
|
||||
std::string linkedTargetsContent = cge->Evaluate(context->Makefile,
|
||||
std::string linkedTargetsContent = cge->Evaluate(target->GetMakefile(),
|
||||
context->Config,
|
||||
context->Quiet,
|
||||
headTarget,
|
||||
|
@ -840,21 +841,21 @@ std::string getLinkedTargetsContent(const std::vector<cmTarget*> &targets,
|
|||
return linkedTargetsContent;
|
||||
}
|
||||
|
||||
std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
|
||||
std::string getLinkedTargetsContent(std::vector<cmLinkItem> const &libraries,
|
||||
cmTarget const* target,
|
||||
cmTarget const* headTarget,
|
||||
cmGeneratorExpressionContext *context,
|
||||
cmGeneratorExpressionDAGChecker *dagChecker,
|
||||
const std::string &interfacePropertyName)
|
||||
{
|
||||
std::vector<cmTarget*> tgts;
|
||||
for (std::vector<std::string>::const_iterator
|
||||
std::vector<cmTarget const*> tgts;
|
||||
for (std::vector<cmLinkItem>::const_iterator
|
||||
it = libraries.begin();
|
||||
it != libraries.end(); ++it)
|
||||
{
|
||||
if (cmTarget *tgt = context->Makefile->FindTargetToUse(*it))
|
||||
if (it->Target)
|
||||
{
|
||||
tgts.push_back(tgt);
|
||||
tgts.push_back(it->Target);
|
||||
}
|
||||
}
|
||||
return getLinkedTargetsContent(tgts, target, headTarget, context,
|
||||
|
@ -1082,7 +1083,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
|||
cmStrCmp(propertyName)) != transEnd)
|
||||
{
|
||||
|
||||
std::vector<cmTarget*> tgts;
|
||||
std::vector<cmTarget const*> tgts;
|
||||
target->GetTransitivePropertyTargets(context->Config,
|
||||
headTarget, tgts);
|
||||
if (!tgts.empty())
|
||||
|
@ -1098,8 +1099,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
|||
cmStrCmp(interfacePropertyName)) != transEnd)
|
||||
{
|
||||
const cmTarget::LinkImplementation *impl
|
||||
= target->GetLinkImplementationLibraries(context->Config,
|
||||
headTarget);
|
||||
= target->GetLinkImplementationLibraries(context->Config);
|
||||
if(impl)
|
||||
{
|
||||
linkedTargetsContent =
|
||||
|
|
|
@ -252,7 +252,7 @@ cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt,
|
||||
static void handleSystemIncludesDep(cmMakefile *mf, cmTarget const* depTgt,
|
||||
const std::string& config,
|
||||
cmTarget *headTarget,
|
||||
cmGeneratorExpressionDAGChecker *dagChecker,
|
||||
|
@ -449,7 +449,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir,
|
|||
if (iter == this->SystemIncludesCache.end())
|
||||
{
|
||||
cmTarget::LinkImplementation const* impl
|
||||
= this->Target->GetLinkImplementation(config, this->Target);
|
||||
= this->Target->GetLinkImplementation(config);
|
||||
if(!impl)
|
||||
{
|
||||
return false;
|
||||
|
@ -474,11 +474,11 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir,
|
|||
&dagChecker), result);
|
||||
}
|
||||
|
||||
std::set<cmTarget*> uniqueDeps;
|
||||
for(std::vector<std::string>::const_iterator li = impl->Libraries.begin();
|
||||
std::set<cmTarget const*> uniqueDeps;
|
||||
for(std::vector<cmLinkItem>::const_iterator li = impl->Libraries.begin();
|
||||
li != impl->Libraries.end(); ++li)
|
||||
{
|
||||
cmTarget* tgt = this->Makefile->FindTargetToUse(*li);
|
||||
cmTarget const* tgt = li->Target;
|
||||
if (!tgt)
|
||||
{
|
||||
continue;
|
||||
|
@ -489,10 +489,10 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir,
|
|||
handleSystemIncludesDep(this->Makefile, tgt, config, this->Target,
|
||||
&dagChecker, result, excludeImported);
|
||||
|
||||
std::vector<cmTarget*> deps;
|
||||
std::vector<cmTarget const*> deps;
|
||||
tgt->GetTransitivePropertyTargets(config, this->Target, deps);
|
||||
|
||||
for(std::vector<cmTarget*>::const_iterator di = deps.begin();
|
||||
for(std::vector<cmTarget const*>::const_iterator di = deps.begin();
|
||||
di != deps.end(); ++di)
|
||||
{
|
||||
if (uniqueDeps.insert(*di).second)
|
||||
|
|
|
@ -1255,7 +1255,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget)
|
|||
|
||||
// If the language is compiled as a source trust Xcode to link with it.
|
||||
cmTarget::LinkImplementation const* impl =
|
||||
cmtarget.GetLinkImplementation("NOCONFIG", &cmtarget);
|
||||
cmtarget.GetLinkImplementation("NOCONFIG");
|
||||
for(std::vector<std::string>::const_iterator li = impl->Languages.begin();
|
||||
li != impl->Languages.end(); ++li)
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -43,12 +43,22 @@ class cmTarget;
|
|||
class cmGeneratorTarget;
|
||||
class cmTargetTraceDependencies;
|
||||
|
||||
struct cmTargetLinkInformationMap:
|
||||
public std::map<std::pair<cmTarget const* , std::string>,
|
||||
cmComputeLinkInformation*>
|
||||
// Basic information about each link item.
|
||||
class cmLinkItem: public std::string
|
||||
{
|
||||
typedef std::map<std::pair<cmTarget const* , std::string>,
|
||||
cmComputeLinkInformation*> derived;
|
||||
typedef std::string std_string;
|
||||
public:
|
||||
cmLinkItem(): std_string(), Target(0) {}
|
||||
cmLinkItem(const std_string& n,
|
||||
cmTarget const* t): std_string(n), Target(t) {}
|
||||
cmLinkItem(cmLinkItem const& r): std_string(r), Target(r.Target) {}
|
||||
cmTarget const* Target;
|
||||
};
|
||||
|
||||
struct cmTargetLinkInformationMap:
|
||||
public std::map<std::string, cmComputeLinkInformation*>
|
||||
{
|
||||
typedef std::map<std::string, cmComputeLinkInformation*> derived;
|
||||
cmTargetLinkInformationMap() {}
|
||||
cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r);
|
||||
~cmTargetLinkInformationMap();
|
||||
|
@ -159,12 +169,6 @@ public:
|
|||
return this->LinkLibraries;}
|
||||
const LinkLibraryVectorType &GetOriginalLinkLibraries() const
|
||||
{return this->OriginalLinkLibraries;}
|
||||
void GetDirectLinkLibraries(const std::string& config,
|
||||
std::vector<std::string> &,
|
||||
cmTarget const* head) const;
|
||||
void GetInterfaceLinkLibraries(const std::string& config,
|
||||
std::vector<std::string> &,
|
||||
cmTarget const* head) const;
|
||||
|
||||
/** Compute the link type to use for the given configuration. */
|
||||
LinkLibraryType ComputeLinkType(const std::string& config) const;
|
||||
|
@ -221,6 +225,7 @@ public:
|
|||
void AddUtility(const std::string& u, cmMakefile *makefile = 0);
|
||||
///! Get the utilities used by this target
|
||||
std::set<std::string>const& GetUtilities() const { return this->Utilities; }
|
||||
std::set<cmLinkItem>const& GetUtilityItems() const;
|
||||
cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
|
||||
|
||||
/** Finalize the target at the end of the Configure step. */
|
||||
|
@ -252,10 +257,10 @@ public:
|
|||
std::vector<std::string> Languages;
|
||||
|
||||
// Libraries listed in the interface.
|
||||
std::vector<std::string> Libraries;
|
||||
std::vector<cmLinkItem> Libraries;
|
||||
|
||||
// Shared library dependencies needed for linking on some platforms.
|
||||
std::vector<std::string> SharedDeps;
|
||||
std::vector<cmLinkItem> SharedDeps;
|
||||
|
||||
// Number of repetitions of a strongly connected component of two
|
||||
// or more static libraries.
|
||||
|
@ -263,7 +268,7 @@ public:
|
|||
|
||||
// Libraries listed for other configurations.
|
||||
// Needed only for OLD behavior of CMP0003.
|
||||
std::vector<std::string> WrongConfigLibraries;
|
||||
std::vector<cmLinkItem> WrongConfigLibraries;
|
||||
|
||||
bool ImplementationIsInterface;
|
||||
|
||||
|
@ -277,11 +282,10 @@ public:
|
|||
LinkInterface const* GetLinkInterfaceLibraries(const std::string& config,
|
||||
cmTarget const* headTarget) const;
|
||||
void GetTransitivePropertyTargets(const std::string& config,
|
||||
cmTarget const* headTarget,
|
||||
std::vector<cmTarget*> &libs) const;
|
||||
void GetTransitiveTargetClosure(const std::string& config,
|
||||
cmTarget const* headTarget,
|
||||
std::vector<cmTarget*> &libs) const;
|
||||
cmTarget const* headTarget,
|
||||
std::vector<cmTarget const*> &libs) const;
|
||||
std::vector<cmTarget const*> const&
|
||||
GetLinkImplementationClosure(const std::string& config) const;
|
||||
|
||||
/** The link implementation specifies the direct library
|
||||
dependencies needed by the object files of the target. */
|
||||
|
@ -291,18 +295,17 @@ public:
|
|||
std::vector<std::string> Languages;
|
||||
|
||||
// Libraries linked directly in this configuration.
|
||||
std::vector<std::string> Libraries;
|
||||
std::vector<cmLinkItem> Libraries;
|
||||
|
||||
// Libraries linked directly in other configurations.
|
||||
// Needed only for OLD behavior of CMP0003.
|
||||
std::vector<std::string> WrongConfigLibraries;
|
||||
std::vector<cmLinkItem> WrongConfigLibraries;
|
||||
};
|
||||
LinkImplementation const* GetLinkImplementation(const std::string& config,
|
||||
cmTarget const* head) const;
|
||||
LinkImplementation const*
|
||||
GetLinkImplementation(const std::string& config) const;
|
||||
|
||||
LinkImplementation const* GetLinkImplementationLibraries(
|
||||
const std::string& config,
|
||||
cmTarget const* head) const;
|
||||
LinkImplementation const*
|
||||
GetLinkImplementationLibraries(const std::string& config) const;
|
||||
|
||||
/** Link information from the transitive closure of the link
|
||||
implementation and the interfaces of its dependencies. */
|
||||
|
@ -314,8 +317,9 @@ public:
|
|||
// Languages whose runtime libraries must be linked.
|
||||
std::vector<std::string> Languages;
|
||||
};
|
||||
LinkClosure const* GetLinkClosure(const std::string& config,
|
||||
cmTarget const* head) const;
|
||||
LinkClosure const* GetLinkClosure(const std::string& config) const;
|
||||
|
||||
cmTarget const* FindTargetToLink(std::string const& name) const;
|
||||
|
||||
/** Strip off leading and trailing whitespace from an item named in
|
||||
the link dependencies of this target. */
|
||||
|
@ -361,8 +365,7 @@ public:
|
|||
GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const;
|
||||
|
||||
///! Return the preferred linker language for this target
|
||||
std::string GetLinkerLanguage(const std::string& config = "",
|
||||
cmTarget const* head = 0) const;
|
||||
std::string GetLinkerLanguage(const std::string& config = "") const;
|
||||
|
||||
/** Get the full name of the target according to the settings in its
|
||||
makefile. */
|
||||
|
@ -446,8 +449,8 @@ public:
|
|||
* install tree. For example: "\@rpath/" or "\@loader_path/". */
|
||||
std::string GetInstallNameDirForInstallTree() const;
|
||||
|
||||
cmComputeLinkInformation* GetLinkInformation(const std::string& config,
|
||||
cmTarget const* head = 0) const;
|
||||
cmComputeLinkInformation*
|
||||
GetLinkInformation(const std::string& config) const;
|
||||
|
||||
// Get the properties
|
||||
cmPropertyMap &GetProperties() const { return this->Properties; }
|
||||
|
@ -740,10 +743,9 @@ private:
|
|||
|
||||
// Cache import information from properties for each configuration.
|
||||
struct ImportInfo;
|
||||
ImportInfo const* GetImportInfo(const std::string& config,
|
||||
cmTarget const* workingTarget) const;
|
||||
void ComputeImportInfo(std::string const& desired_config, ImportInfo& info,
|
||||
cmTarget const* head) const;
|
||||
ImportInfo const* GetImportInfo(const std::string& config) const;
|
||||
void ComputeImportInfo(std::string const& desired_config,
|
||||
ImportInfo& info) const;
|
||||
|
||||
// Cache target compile paths for each configuration.
|
||||
struct CompileInfo;
|
||||
|
@ -753,19 +755,31 @@ private:
|
|||
void CheckPropertyCompatibility(cmComputeLinkInformation *info,
|
||||
const std::string& config) const;
|
||||
|
||||
LinkInterface const*
|
||||
GetImportLinkInterface(const std::string& config,
|
||||
cmTarget const* head) const;
|
||||
|
||||
const char* ComputeLinkInterfaceLibraries(const std::string& config,
|
||||
LinkInterface& iface,
|
||||
cmTarget const* head,
|
||||
bool &exists) const;
|
||||
|
||||
LinkImplementation const*
|
||||
GetLinkImplementationLibrariesInternal(const std::string& config,
|
||||
cmTarget const* head) const;
|
||||
void ComputeLinkImplementation(const std::string& config,
|
||||
LinkImplementation& impl,
|
||||
cmTarget const* head) const;
|
||||
void ComputeLinkImplementationLanguages(const std::string& config,
|
||||
LinkImplementation& impl,
|
||||
cmTarget const* head) const;
|
||||
void ComputeLinkClosure(const std::string& config, LinkClosure& lc,
|
||||
cmTarget const* head) const;
|
||||
void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const;
|
||||
|
||||
void ExpandLinkItems(std::string const& prop, std::string const& value,
|
||||
std::string const& config, cmTarget const* headTarget,
|
||||
std::vector<cmLinkItem>& items) const;
|
||||
void LookupLinkItems(std::vector<std::string> const& names,
|
||||
std::vector<cmLinkItem>& items) const;
|
||||
|
||||
std::string ProcessSourceItemCMP0049(const std::string& s);
|
||||
|
||||
|
|
|
@ -8,8 +8,18 @@ target_compile_definitions(iface_nodepends INTERFACE IFACE_DEFINE)
|
|||
|
||||
add_subdirectory(headerdir)
|
||||
|
||||
# Add an interface target in a subdirectory that uses an imported interface.
|
||||
add_subdirectory(ifacedir)
|
||||
|
||||
# Poison an imported interface with the same name as that in the subdir
|
||||
# to ensure that the transitive lookup occurs in the subdir.
|
||||
add_library(imp::iface INTERFACE IMPORTED)
|
||||
set_property(TARGET imp::iface APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SOMEPROP)
|
||||
set_property(TARGET imp::iface PROPERTY INTERFACE_SOMEPROP OFF)
|
||||
set_property(TARGET imp::iface PROPERTY INTERFACE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/does_not_exist.cpp)
|
||||
|
||||
add_executable(InterfaceLibrary definetestexe.cpp)
|
||||
target_link_libraries(InterfaceLibrary iface_nodepends headeriface)
|
||||
target_link_libraries(InterfaceLibrary iface_nodepends headeriface subiface)
|
||||
|
||||
add_subdirectory(libsdir)
|
||||
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
#error Expected IFACE_HEADER_BUILDDIR
|
||||
#endif
|
||||
|
||||
extern int sub();
|
||||
|
||||
int main(int,char**)
|
||||
{
|
||||
return 0;
|
||||
return sub();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
add_library(imp::iface INTERFACE IMPORTED)
|
||||
set_property(TARGET imp::iface APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SOMEPROP)
|
||||
set_property(TARGET imp::iface PROPERTY INTERFACE_SOMEPROP ON)
|
||||
set_property(TARGET imp::iface PROPERTY INTERFACE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sub.cpp)
|
||||
|
||||
add_library(subiface INTERFACE)
|
||||
target_link_libraries(subiface INTERFACE imp::iface)
|
||||
set_property(TARGET subiface PROPERTY INTERFACE_SOMEPROP ON)
|
|
@ -0,0 +1 @@
|
|||
int sub() { return 0; }
|
Loading…
Reference in New Issue