diff options
author | Brad King <brad.king@kitware.com> | 2018-09-10 14:11:57 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-09-12 16:46:51 (GMT) |
commit | 18441a626901ec559d3ebaed7fd99f09360c5b39 (patch) | |
tree | 0d43aceafbc7efad4c374cbc6559d7abe78d4e5c /Source/cmGeneratorTarget.cxx | |
parent | 2f708f5d65557ecbfe4ebe7c14b02dbba6bf0ffe (diff) | |
download | CMake-18441a626901ec559d3ebaed7fd99f09360c5b39.zip CMake-18441a626901ec559d3ebaed7fd99f09360c5b39.tar.gz CMake-18441a626901ec559d3ebaed7fd99f09360c5b39.tar.bz2 |
cmGeneratorTarget: Factor target name resolution out of link item resolution
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 40ee01e..1bd98e2 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -5645,24 +5645,38 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( } } +cmGeneratorTarget::TargetOrString cmGeneratorTarget::ResolveTargetReference( + std::string const& name) const +{ + TargetOrString resolved; + + if (cmGeneratorTarget* tgt = + this->LocalGenerator->FindGeneratorTargetToUse(name)) { + resolved.Target = tgt; + } else { + resolved.String = name; + } + + return resolved; +} + cmLinkItem cmGeneratorTarget::ResolveLinkItem(std::string const& name) const { - cmGeneratorTarget* tgt = - this->LocalGenerator->FindGeneratorTargetToUse(name); + TargetOrString resolved = this->ResolveTargetReference(name); + + if (!resolved.Target) { + return cmLinkItem(resolved.String); + } // 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() == cmStateEnums::EXECUTABLE && - !tgt->IsExecutableWithExports()) { - tgt = nullptr; - } - - if (tgt) { - return cmLinkItem(tgt); + if (resolved.Target->GetType() == cmStateEnums::EXECUTABLE && + !resolved.Target->IsExecutableWithExports()) { + return cmLinkItem(resolved.Target->GetName()); } - return cmLinkItem(name); + return cmLinkItem(resolved.Target); } std::string cmGeneratorTarget::GetPDBDirectory(const std::string& config) const |