summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-06-16 13:45:46 (GMT)
committerBrad King <brad.king@kitware.com>2014-06-23 13:17:06 (GMT)
commit069d60fe039ae1d797a26786f3cd4c23afc27b07 (patch)
tree10d884a76fed1c3d9a1879d7f0208480e0e79380
parent47ab3ca64105cdfcc7b57ffe037aa93d8226b945 (diff)
downloadCMake-069d60fe039ae1d797a26786f3cd4c23afc27b07.zip
CMake-069d60fe039ae1d797a26786f3cd4c23afc27b07.tar.gz
CMake-069d60fe039ae1d797a26786f3cd4c23afc27b07.tar.bz2
cmTarget: Add method to lookup other targets in a target's scope
Move the main implementation of cmComputeLinkDepends::FindTargetToLink into cmTarget.
-rw-r--r--Source/cmComputeLinkDepends.cxx31
-rw-r--r--Source/cmTarget.cxx31
-rw-r--r--Source/cmTarget.h2
3 files changed, 36 insertions, 28 deletions
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 1b83ee8..1b2d1cb 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -623,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);
}
//----------------------------------------------------------------------------
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 4ef481a..9a6c93c 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -6681,6 +6681,37 @@ cmTarget::ComputeLinkImplementationLanguages(const std::string& config,
}
//----------------------------------------------------------------------------
+cmTarget const* cmTarget::FindTargetToLink(std::string const& name) const
+{
+ cmTarget const* tgt = this->Makefile->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->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.";
+ cmake* cm = this->Makefile->GetCMakeInstance();
+ cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace());
+ tgt = 0;
+ }
+
+ // Return the target found, if any.
+ return tgt;
+}
+
+//----------------------------------------------------------------------------
std::string cmTarget::CheckCMP0004(std::string const& item) const
{
// Strip whitespace off the library names because we used to do this
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index cb68559..049d3ea 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -308,6 +308,8 @@ public:
};
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. */
std::string CheckCMP0004(std::string const& item) const;