diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2020-05-28 11:51:22 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2020-06-02 15:11:47 (GMT) |
commit | 056489d567b657bd1ebeae8bf78f4937f900b2e0 (patch) | |
tree | d3800c8fdf726c1e04cf73e463b68861efe6abd3 /Source/cmMakefile.cxx | |
parent | 254f2b9058f814e952ef0178e13b3f98e8d216a1 (diff) | |
download | CMake-056489d567b657bd1ebeae8bf78f4937f900b2e0.zip CMake-056489d567b657bd1ebeae8bf78f4937f900b2e0.tar.gz CMake-056489d567b657bd1ebeae8bf78f4937f900b2e0.tar.bz2 |
add_library/add_executable: allow local alias to imported targets
Fixes: #20641
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c527a49..c78b751 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2035,10 +2035,13 @@ void cmMakefile::AddGlobalLinkInformation(cmTarget& target) } } -void cmMakefile::AddAlias(const std::string& lname, std::string const& tgtName) +void cmMakefile::AddAlias(const std::string& lname, std::string const& tgtName, + bool globallyVisible) { this->AliasTargets[lname] = tgtName; - this->GetGlobalGenerator()->AddAlias(lname, tgtName); + if (globallyVisible) { + this->GetGlobalGenerator()->AddAlias(lname, tgtName); + } } cmTarget* cmMakefile::AddLibrary(const std::string& lname, @@ -4286,7 +4289,15 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name, { // Look for an imported target. These take priority because they // are more local in scope and do not have to be globally unique. - auto imported = this->ImportedTargets.find(name); + auto targetName = name; + if (!excludeAliases) { + // Look for local alias targets. + auto alias = this->AliasTargets.find(name); + if (alias != this->AliasTargets.end()) { + targetName = alias->second; + } + } + auto imported = this->ImportedTargets.find(targetName); if (imported != this->ImportedTargets.end()) { return imported->second; } |