summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2022-02-02 16:30:56 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2022-02-02 20:17:30 (GMT)
commitc18409cdac4d9a8213201eaec53b3cc2d60c68e3 (patch)
tree27cf6445a79d9d8cb99a08209c6de2844e93f91c /Source
parent92459258108c0036808f29f83a8503fea18ccee9 (diff)
downloadCMake-c18409cdac4d9a8213201eaec53b3cc2d60c68e3.zip
CMake-c18409cdac4d9a8213201eaec53b3cc2d60c68e3.tar.gz
CMake-c18409cdac4d9a8213201eaec53b3cc2d60c68e3.tar.bz2
CMakePresets.json: Ensure configurePreset is reachable from current file
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCMakePresetsGraph.cxx14
-rw-r--r--Source/cmCMakePresetsGraph.h3
2 files changed, 14 insertions, 3 deletions
diff --git a/Source/cmCMakePresetsGraph.cxx b/Source/cmCMakePresetsGraph.cxx
index 79e8191..705e2b0 100644
--- a/Source/cmCMakePresetsGraph.cxx
+++ b/Source/cmCMakePresetsGraph.cxx
@@ -108,7 +108,7 @@ ReadFileResult VisitPreset(
auto& parentPreset = parent->second.Unexpanded;
if (!preset.OriginFile->ReachableFiles.count(parentPreset.OriginFile)) {
- return ReadFileResult::PRESET_UNREACHABLE_FROM_FILE;
+ return ReadFileResult::INHERITED_PRESET_UNREACHABLE_FROM_FILE;
}
auto result = VisitPreset(parentPreset, presets, cycleStatus, graph);
@@ -925,6 +925,10 @@ cmCMakePresetsGraph::ReadProjectPresetsInternal(bool allowNoFiles)
if (configurePreset == this->ConfigurePresets.end()) {
return ReadFileResult::INVALID_CONFIGURE_PRESET;
}
+ if (!it.second.Unexpanded.OriginFile->ReachableFiles.count(
+ configurePreset->second.Unexpanded.OriginFile)) {
+ return ReadFileResult::CONFIGURE_PRESET_UNREACHABLE_FROM_FILE;
+ }
if (it.second.Unexpanded.InheritConfigureEnvironment.value_or(true)) {
it.second.Unexpanded.Environment.insert(
@@ -945,6 +949,10 @@ cmCMakePresetsGraph::ReadProjectPresetsInternal(bool allowNoFiles)
if (configurePreset == this->ConfigurePresets.end()) {
return ReadFileResult::INVALID_CONFIGURE_PRESET;
}
+ if (!it.second.Unexpanded.OriginFile->ReachableFiles.count(
+ configurePreset->second.Unexpanded.OriginFile)) {
+ return ReadFileResult::CONFIGURE_PRESET_UNREACHABLE_FROM_FILE;
+ }
if (it.second.Unexpanded.InheritConfigureEnvironment.value_or(true)) {
it.second.Unexpanded.Environment.insert(
@@ -992,8 +1000,10 @@ const char* cmCMakePresetsGraph::ResultToString(ReadFileResult result)
return "Duplicate presets";
case ReadFileResult::CYCLIC_PRESET_INHERITANCE:
return "Cyclic preset inheritance";
- case ReadFileResult::PRESET_UNREACHABLE_FROM_FILE:
+ case ReadFileResult::INHERITED_PRESET_UNREACHABLE_FROM_FILE:
return "Inherited preset is unreachable from preset's file";
+ case ReadFileResult::CONFIGURE_PRESET_UNREACHABLE_FROM_FILE:
+ return "Configure preset is unreachable from preset's file";
case ReadFileResult::INVALID_MACRO_EXPANSION:
return "Invalid macro expansion";
case ReadFileResult::BUILD_TEST_PRESETS_UNSUPPORTED:
diff --git a/Source/cmCMakePresetsGraph.h b/Source/cmCMakePresetsGraph.h
index d3a5cfc..9d6c61a 100644
--- a/Source/cmCMakePresetsGraph.h
+++ b/Source/cmCMakePresetsGraph.h
@@ -35,7 +35,8 @@ public:
INVALID_VARIABLE,
DUPLICATE_PRESETS,
CYCLIC_PRESET_INHERITANCE,
- PRESET_UNREACHABLE_FROM_FILE,
+ INHERITED_PRESET_UNREACHABLE_FROM_FILE,
+ CONFIGURE_PRESET_UNREACHABLE_FROM_FILE,
INVALID_MACRO_EXPANSION,
BUILD_TEST_PRESETS_UNSUPPORTED,
INCLUDE_UNSUPPORTED,