diff options
author | Zack Galbreath <zack.galbreath@kitware.com> | 2018-06-18 10:49:44 -0400 |
---|---|---|
committer | Zack Galbreath <zack.galbreath@kitware.com> | 2018-06-18 13:18:54 -0400 |
commit | e89ad0f94e6b52cc9f75abe21107c7a2e5d24ca2 (patch) | |
tree | 5a31b0413bac45f1dbd5e013215a44431076542d /Source/cmInstallTargetGenerator.cxx | |
parent | b0b99d877e92028a0265ac86d1d6c79276a04811 (diff) | |
download | cmake-e89ad0f94e6b52cc9f75abe21107c7a2e5d24ca2.tar.gz |
install: Allow installing targets created in another directory
Previously, `install(TARGETS)` would only accept targets created in the same
directory scope. Relax this restriction by searching the global scope when
determining whether or not a target exists.
Fixes: #14444
Diffstat (limited to 'Source/cmInstallTargetGenerator.cxx')
-rw-r--r-- | Source/cmInstallTargetGenerator.cxx | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index e0afa2d4d4..8b8f79b98a 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -440,7 +440,13 @@ std::string cmInstallTargetGenerator::GetInstallFilename( void cmInstallTargetGenerator::Compute(cmLocalGenerator* lg) { + // Lookup this target in the current directory. this->Target = lg->FindLocalNonAliasGeneratorTarget(this->TargetName); + if (!this->Target) { + // If no local target has been found, find it in the global scope. + this->Target = + lg->GetGlobalGenerator()->FindGeneratorTarget(this->TargetName); + } } void cmInstallTargetGenerator::AddTweak(std::ostream& os, Indent indent, |