summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorSam Freed <safreed@microsoft.com>2021-03-15 21:44:43 (GMT)
committerSam Freed <safreed@microsoft.com>2021-03-15 21:44:43 (GMT)
commit83eeeff7dc0cf5c298d8696096926c57cd6cff5e (patch)
treedc298cf5527e95e71e5dd9f44f34fecea9e3de52 /Source
parentdfdea7d9e3900dfc778b4c5243c0aa13379cb56d (diff)
downloadCMake-83eeeff7dc0cf5c298d8696096926c57cd6cff5e.zip
CMake-83eeeff7dc0cf5c298d8696096926c57cd6cff5e.tar.gz
CMake-83eeeff7dc0cf5c298d8696096926c57cd6cff5e.tar.bz2
Fail at read-time if configurePreset field invalid
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCMakePresetsFile.cxx16
-rw-r--r--Source/cmCMakePresetsFile.h1
2 files changed, 13 insertions, 4 deletions
diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx
index c8d69b8..dda3661 100644
--- a/Source/cmCMakePresetsFile.cxx
+++ b/Source/cmCMakePresetsFile.cxx
@@ -1431,8 +1431,11 @@ cmCMakePresetsFile::ReadProjectPresetsInternal(bool allowNoFiles)
if (!it.second.Unexpanded.Hidden) {
const auto configurePreset =
this->ConfigurePresets.find(it.second.Unexpanded.ConfigurePreset);
- if (it.second.Unexpanded.InheritConfigureEnvironment.value_or(true) &&
- configurePreset != this->ConfigurePresets.end()) {
+ if (configurePreset == this->ConfigurePresets.end()) {
+ return ReadFileResult::INVALID_CONFIGURE_PRESET;
+ }
+
+ if (it.second.Unexpanded.InheritConfigureEnvironment.value_or(true)) {
it.second.Unexpanded.Environment.insert(
configurePreset->second.Unexpanded.Environment.begin(),
configurePreset->second.Unexpanded.Environment.end());
@@ -1448,8 +1451,11 @@ cmCMakePresetsFile::ReadProjectPresetsInternal(bool allowNoFiles)
if (!it.second.Unexpanded.Hidden) {
const auto configurePreset =
this->ConfigurePresets.find(it.second.Unexpanded.ConfigurePreset);
- if (it.second.Unexpanded.InheritConfigureEnvironment.value_or(true) &&
- configurePreset != this->ConfigurePresets.end()) {
+ if (configurePreset == this->ConfigurePresets.end()) {
+ return ReadFileResult::INVALID_CONFIGURE_PRESET;
+ }
+
+ if (it.second.Unexpanded.InheritConfigureEnvironment.value_or(true)) {
it.second.Unexpanded.Environment.insert(
configurePreset->second.Unexpanded.Environment.begin(),
configurePreset->second.Unexpanded.Environment.end());
@@ -1502,6 +1508,8 @@ const char* cmCMakePresetsFile::ResultToString(ReadFileResult result)
case ReadFileResult::BUILD_TEST_PRESETS_UNSUPPORTED:
return "File version must be 2 or higher for build and test preset "
"support.";
+ case ReadFileResult::INVALID_CONFIGURE_PRESET:
+ return "Invalid \"configurePreset\" field";
}
return "Unknown error";
diff --git a/Source/cmCMakePresetsFile.h b/Source/cmCMakePresetsFile.h
index e92c86b..3067d5e 100644
--- a/Source/cmCMakePresetsFile.h
+++ b/Source/cmCMakePresetsFile.h
@@ -32,6 +32,7 @@ public:
USER_PRESET_INHERITANCE,
INVALID_MACRO_EXPANSION,
BUILD_TEST_PRESETS_UNSUPPORTED,
+ INVALID_CONFIGURE_PRESET,
};
enum class ArchToolsetStrategy