diff options
author | Zack Galbreath <zack.galbreath@kitware.com> | 2018-06-18 14:49:44 (GMT) |
---|---|---|
committer | Zack Galbreath <zack.galbreath@kitware.com> | 2018-06-18 17:18:54 (GMT) |
commit | e89ad0f94e6b52cc9f75abe21107c7a2e5d24ca2 (patch) | |
tree | 5a31b0413bac45f1dbd5e013215a44431076542d /Source/cmInstallCommand.cxx | |
parent | b0b99d877e92028a0265ac86d1d6c79276a04811 (diff) | |
download | CMake-e89ad0f94e6b52cc9f75abe21107c7a2e5d24ca2.zip CMake-e89ad0f94e6b52cc9f75abe21107c7a2e5d24ca2.tar.gz CMake-e89ad0f94e6b52cc9f75abe21107c7a2e5d24ca2.tar.bz2 |
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/cmInstallCommand.cxx')
-rw-r--r-- | Source/cmInstallCommand.cxx | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 87dcb18..99409c2 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -362,7 +362,12 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) return false; } // Lookup this target in the current directory. - if (cmTarget* target = this->Makefile->FindLocalNonAliasTarget(tgt)) { + cmTarget* target = this->Makefile->FindLocalNonAliasTarget(tgt); + if (!target) { + // If no local target has been found, find it in the global scope. + target = this->Makefile->GetGlobalGenerator()->FindTarget(tgt, true); + } + if (target) { // Found the target. Check its type. if (target->GetType() != cmStateEnums::EXECUTABLE && target->GetType() != cmStateEnums::STATIC_LIBRARY && @@ -381,8 +386,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) } else { // Did not find the target. std::ostringstream e; - e << "TARGETS given target \"" << tgt - << "\" which does not exist in this directory."; + e << "TARGETS given target \"" << tgt << "\" which does not exist."; this->SetError(e.str()); return false; } |