summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorTarget.cxx
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 /Source/cmGeneratorTarget.cxx
parent61c02decce0c1b5aa78acd58d987a5d260079ca4 (diff)
downloadCMake-bf2d061ad37088be9ea6f135a980d14c4e76064b.zip
CMake-bf2d061ad37088be9ea6f135a980d14c4e76064b.tar.gz
CMake-bf2d061ad37088be9ea6f135a980d14c4e76064b.tar.bz2
cmGeneratorTarget: Move FindTargetToLink from cmTarget.
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r--Source/cmGeneratorTarget.cxx42
1 files changed, 39 insertions, 3 deletions
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
{