summaryrefslogtreecommitdiff
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2020-05-28 13:51:22 +0200
committerMarc Chevrier <marc.chevrier@gmail.com>2020-06-02 17:11:47 +0200
commit056489d567b657bd1ebeae8bf78f4937f900b2e0 (patch)
treed3800c8fdf726c1e04cf73e463b68861efe6abd3 /Source/cmMakefile.cxx
parent254f2b9058f814e952ef0178e13b3f98e8d216a1 (diff)
downloadcmake-056489d567b657bd1ebeae8bf78f4937f900b2e0.tar.gz
add_library/add_executable: allow local alias to imported targets
Fixes: #20641
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx17
1 files changed, 14 insertions, 3 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index c527a4917c..c78b7519c2 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;
}