summaryrefslogtreecommitdiffstats
path: root/Source/cmCMakePresetsFile.h
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-10-19 17:41:30 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2020-10-21 13:20:52 (GMT)
commit638557cbfe0618d5a0fc6f9088e34aac708f5519 (patch)
tree306150b829afe8b1a538fb891f023d9b59ff7a7b /Source/cmCMakePresetsFile.h
parentec3b3d2c2f16397b9a40f79a9783f3d207088b93 (diff)
downloadCMake-638557cbfe0618d5a0fc6f9088e34aac708f5519.zip
CMake-638557cbfe0618d5a0fc6f9088e34aac708f5519.tar.gz
CMake-638557cbfe0618d5a0fc6f9088e34aac708f5519.tar.bz2
CMakePresets.json: Properly report macro expansion errors
Make a distinction between strings which simply use the $vendor{<...>} macro, which is valid but makes it unusable by CMake, and strings which actually contain invalid macro expansions. Fixes: #21308
Diffstat (limited to 'Source/cmCMakePresetsFile.h')
-rw-r--r--Source/cmCMakePresetsFile.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/Source/cmCMakePresetsFile.h b/Source/cmCMakePresetsFile.h
index 70ec4c5..87797d7 100644
--- a/Source/cmCMakePresetsFile.h
+++ b/Source/cmCMakePresetsFile.h
@@ -102,8 +102,15 @@ public:
}
};
+ class PresetPair
+ {
+ public:
+ UnexpandedPreset Unexpanded;
+ cm::optional<ExpandedPreset> Expanded;
+ };
+
std::string SourceDir;
- std::map<std::string, UnexpandedPreset> Presets;
+ std::map<std::string, PresetPair> Presets;
std::vector<std::string> PresetOrder;
enum class ReadFileResult
@@ -123,6 +130,7 @@ public:
DUPLICATE_PRESETS,
CYCLIC_PRESET_INHERITANCE,
USER_PRESET_INHERITANCE,
+ INVALID_MACRO_EXPANSION,
};
static std::string GetFilename(const std::string& sourceDir);
@@ -131,11 +139,9 @@ public:
bool allowNoFiles = false);
static const char* ResultToString(ReadFileResult result);
- cm::optional<ExpandedPreset> ExpandMacros(
- const UnexpandedPreset& preset) const;
-
private:
- ReadFileResult ReadJSONFile(
- const std::string& filename, std::vector<std::string>& presetOrder,
- std::map<std::string, UnexpandedPreset>& presetMap, bool user);
+ ReadFileResult ReadJSONFile(const std::string& filename,
+ std::vector<std::string>& presetOrder,
+ std::map<std::string, PresetPair>& presetMap,
+ bool user);
};