summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-10-10 10:23:19 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-10-12 16:39:58 (GMT)
commitbf2d061ad37088be9ea6f135a980d14c4e76064b (patch)
treee6fef8ac1bb79be8e127a3572da799b2b70b3eea
parent61c02decce0c1b5aa78acd58d987a5d260079ca4 (diff)
downloadCMake-bf2d061ad37088be9ea6f135a980d14c4e76064b.zip
CMake-bf2d061ad37088be9ea6f135a980d14c4e76064b.tar.gz
CMake-bf2d061ad37088be9ea6f135a980d14c4e76064b.tar.bz2
cmGeneratorTarget: Move FindTargetToLink from cmTarget.
-rw-r--r--Source/cmComputeLinkDepends.cxx7
-rw-r--r--Source/cmComputeLinkDepends.h4
-rw-r--r--Source/cmGeneratorTarget.cxx42
-rw-r--r--Source/cmGeneratorTarget.h2
-rw-r--r--Source/cmTarget.cxx31
-rw-r--r--Source/cmTarget.h2
6 files changed, 47 insertions, 41 deletions
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 4d7b01e..5604c53 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -634,8 +634,9 @@ cmComputeLinkDepends::AddLinkEntries(
}
//----------------------------------------------------------------------------
-cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index,
- const std::string& name)
+cmGeneratorTarget const*
+cmComputeLinkDepends::FindTargetToLink(int depender_index,
+ const std::string& name)
{
// Look for a target in the scope of the depender.
cmGeneratorTarget const* from = this->Target;
@@ -647,7 +648,7 @@ cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index,
from = depender;
}
}
- return from->Target->FindTargetToLink(name);
+ return from->FindTargetToLink(name);
}
//----------------------------------------------------------------------------
diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h
index 33ba0b8..d9760aa 100644
--- a/Source/cmComputeLinkDepends.h
+++ b/Source/cmComputeLinkDepends.h
@@ -73,8 +73,8 @@ private:
void AddDirectLinkEntries();
template <typename T>
void AddLinkEntries(int depender_index, std::vector<T> const& libs);
- cmTarget const* FindTargetToLink(int depender_index,
- const std::string& name);
+ cmGeneratorTarget const* FindTargetToLink(int depender_index,
+ const std::string& name);
// One entry for each unique item.
std::vector<LinkEntry> EntryList;
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index ef79d74..d472c6c 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -4427,7 +4427,7 @@ void cmGeneratorTarget::LookupLinkItems(std::vector<std::string> const& names,
{
continue;
}
- items.push_back(cmLinkItem(name, this->Target->FindTargetToLink(name)));
+ items.push_back(cmLinkItem(name, this->FindTargetToLink(name)));
}
}
@@ -5398,7 +5398,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
// The entry is meant for this configuration.
impl.Libraries.push_back(
- cmLinkImplItem(name, this->Target->FindTargetToLink(name),
+ cmLinkImplItem(name, this->FindTargetToLink(name),
*btIt, evaluated != *le));
}
@@ -5430,12 +5430,48 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
}
// Support OLD behavior for CMP0003.
impl.WrongConfigLibraries.push_back(
- cmLinkItem(name, this->Target->FindTargetToLink(name)));
+ cmLinkItem(name, this->FindTargetToLink(name)));
}
}
}
//----------------------------------------------------------------------------
+cmGeneratorTarget*
+cmGeneratorTarget::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)
+ {
+ std::ostringstream 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->Target->GetBacktrace());
+ tgt = 0;
+ }
+
+ if (!tgt)
+ {
+ return 0;
+ }
+ return this->GlobalGenerator->GetGeneratorTarget(tgt);
+}
+
+//----------------------------------------------------------------------------
std::string
cmGeneratorTarget::GetPDBDirectory(const std::string& config) const
{
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 70612f2..cd994c0 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -216,6 +216,8 @@ public:
cmOptionalLinkImplementation& impl,
const cmGeneratorTarget* head) const;
+ cmGeneratorTarget* FindTargetToLink(std::string const& name) const;
+
// Compute the set of languages compiled by the target. This is
// computed every time it is called because the languages can change
// when source file properties are changed and we do not have enough
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 31a9aa7..bebdd77 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -2670,37 +2670,6 @@ void cmTarget::ComputeImportInfo(std::string const& desired_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)
- {
- std::ostringstream 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 0c1bbd2..3bb1ccd 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -223,8 +223,6 @@ public:
void GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) 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;