summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-02-04 16:45:54 (GMT)
committerBrad King <brad.king@kitware.com>2016-02-05 14:45:16 (GMT)
commit47460f3e152a59af81edd816cdfe6e0d54e38090 (patch)
tree4db4f048cb75a50ebc2031db57fa834d816c3afc /Source
parente86383e135e4cae9d54575445d945df1f6272b3a (diff)
downloadCMake-47460f3e152a59af81edd816cdfe6e0d54e38090.zip
CMake-47460f3e152a59af81edd816cdfe6e0d54e38090.tar.gz
CMake-47460f3e152a59af81edd816cdfe6e0d54e38090.tar.bz2
install(EXPORT): Fix crash on target in another directory
Refactoring merged by commit v3.5.0-rc1~299 (Merge topic 'use-generator-target', 2015-10-20) in and around commit v3.5.0-rc1~299^2~13 (cmExportSet: Store a cmGeneratorTarget, 2015-10-17) changed export sets to delay looking up actual targets and stores only their names. However, in InstallCommand::HandleExportMode we need to lookup targets immediately to check them for EXPORT_LINK_INTERFACE_LIBRARIES. The check was accidentally made local to the current directory, so if an export set contains a target from another directory the lookup fails and CMake crashes. Fix the check to look up the target name globally, and tolerate when no target is found just in case. Reported-by: Kelly Thompson <kgt@lanl.gov>
Diffstat (limited to 'Source')
-rw-r--r--Source/cmInstallCommand.cxx8
1 files changed, 5 insertions, 3 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 15a83ee..2d78a41 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -1374,10 +1374,12 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
tei != exportSet->GetTargetExports()->end(); ++tei)
{
cmTargetExport const* te = *tei;
- cmTarget* tgt = this->Makefile->FindTarget(te->TargetName);
+ cmTarget* tgt =
+ this->Makefile->GetGlobalGenerator()->FindTarget(te->TargetName);
const bool newCMP0022Behavior =
- tgt->GetPolicyStatusCMP0022() != cmPolicies::WARN
- && tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD;
+ (tgt &&
+ tgt->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
+ tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD);
if(!newCMP0022Behavior)
{