diff options
author | Brad King <brad.king@kitware.com> | 2019-03-07 13:52:18 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-03-07 14:00:56 (GMT) |
commit | 47389c5641b821813f3f236bfbc179f52a2c95d7 (patch) | |
tree | 0c5d54b310509435badeb287b7b1e1bcb328d595 /Source/cmInstallCommand.cxx | |
parent | 20a41aa589d4418f9ac46fc8c0402162d1d82873 (diff) | |
download | CMake-47389c5641b821813f3f236bfbc179f52a2c95d7.zip CMake-47389c5641b821813f3f236bfbc179f52a2c95d7.tar.gz CMake-47389c5641b821813f3f236bfbc179f52a2c95d7.tar.bz2 |
install: Do not crash on imported global target
Since commit e89ad0f94e (install: Allow installing targets created in
another directory, 2018-06-18, v3.13.0-rc1~407^2) the `install(TARGETS)`
command may find a global-scoped target outside the calling directory.
Ignore an `IMPORTED GLOBAL` target if it is found in this way. Imported
targets cannot be installed, and trying to do so violates internal
invariants.
Fixes: #19022
Diffstat (limited to 'Source/cmInstallCommand.cxx')
-rw-r--r-- | Source/cmInstallCommand.cxx | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 8ef6441..20d1a31 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -402,7 +402,11 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) 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); + cmTarget* const global_target = + this->Makefile->GetGlobalGenerator()->FindTarget(tgt, true); + if (global_target && !global_target->IsImported()) { + target = global_target; + } } if (target) { // Found the target. Check its type. |