summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-06-02 14:57:10 (GMT)
committerBrad King <brad.king@kitware.com>2016-06-02 14:58:38 (GMT)
commitf500a784d008566d6eb6301b7c6a0f07847b856d (patch)
tree6d8fbe3bbad0ea13517ef0a029e373486523fb53 /Source
parent9d81f1b3aaa82d12a3a87067572b3ff5e2b9c4d2 (diff)
downloadCMake-f500a784d008566d6eb6301b7c6a0f07847b856d.zip
CMake-f500a784d008566d6eb6301b7c6a0f07847b856d.tar.gz
CMake-f500a784d008566d6eb6301b7c6a0f07847b856d.tar.bz2
Fix crash on $<TARGET_PROPERTY:...,LOCATION> genex (#16134)
Policy CMP0026 deprecated the LOCATION property, and we have long provided a $<TARGET_FILE:...> generator expression. However, if a project tries to use $<TARGET_PROPERTY:...,LOCATION> we should at least not crash. The compatibility implementation of the LOCATION property uses cmGlobalGenerator::CreateGenerationObjects to create the structures needed to evaluate the property before generation starts. The implementation assumed that accessing the property could only be done during configuration (via the typical get_property command use case). The $<TARGET_PROPERTY:...,LOCATION> genex causes the LOCATION property to be accessed during generation. Calling CreateGenerationObjects during generation blows away all the objects currently being used for generation and is not safe. Add a condition to call it only when configuration is not finished.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmTarget.cxx12
1 files changed, 9 insertions, 3 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 5e0d2b7..f435a1d 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1131,7 +1131,9 @@ const char* cmTarget::GetProperty(const std::string& prop,
// target because the configuration type may not be known at
// CMake time.
cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
- gg->CreateGenerationObjects();
+ if (!gg->GetConfigureDoneCMP0026()) {
+ gg->CreateGenerationObjects();
+ }
cmGeneratorTarget* gt = gg->FindGeneratorTarget(this->GetName());
this->Properties.SetProperty(propLOCATION, gt->GetLocationForBuild());
}
@@ -1150,7 +1152,9 @@ const char* cmTarget::GetProperty(const std::string& prop,
prop, this->ImportedGetFullPath(configName, false).c_str());
} else {
cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
- gg->CreateGenerationObjects();
+ if (!gg->GetConfigureDoneCMP0026()) {
+ gg->CreateGenerationObjects();
+ }
cmGeneratorTarget* gt = gg->FindGeneratorTarget(this->GetName());
this->Properties.SetProperty(
prop, gt->GetFullPath(configName, false).c_str());
@@ -1168,7 +1172,9 @@ const char* cmTarget::GetProperty(const std::string& prop,
prop, this->ImportedGetFullPath(configName, false).c_str());
} else {
cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
- gg->CreateGenerationObjects();
+ if (!gg->GetConfigureDoneCMP0026()) {
+ gg->CreateGenerationObjects();
+ }
cmGeneratorTarget* gt = gg->FindGeneratorTarget(this->GetName());
this->Properties.SetProperty(
prop, gt->GetFullPath(configName, false).c_str());