diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2020-10-19 17:41:30 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2020-10-21 13:20:52 (GMT) |
commit | 638557cbfe0618d5a0fc6f9088e34aac708f5519 (patch) | |
tree | 306150b829afe8b1a538fb891f023d9b59ff7a7b /Source/cmake.cxx | |
parent | ec3b3d2c2f16397b9a40f79a9783f3d207088b93 (diff) | |
download | CMake-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/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 2a14b03..5b6bd1e 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1042,17 +1042,17 @@ void cmake::SetArgs(const std::vector<std::string>& args) this->PrintPresetList(settingsFile); return; } - if (preset->second.Hidden) { + if (preset->second.Unexpanded.Hidden) { cmSystemTools::Error(cmStrCat("Cannot use hidden preset in ", this->GetHomeDirectory(), ": \"", presetName, '"')); this->PrintPresetList(settingsFile); return; } - auto expandedPreset = settingsFile.ExpandMacros(preset->second); + auto const& expandedPreset = preset->second.Expanded; if (!expandedPreset) { cmSystemTools::Error(cmStrCat("Could not evaluate preset \"", - preset->second.Name, + preset->second.Unexpanded.Name, "\": Invalid macro expansion")); return; } @@ -1464,13 +1464,12 @@ void cmake::PrintPresetList(const cmCMakePresetsFile& file) const std::vector<cmCMakePresetsFile::UnexpandedPreset> presets; for (auto const& p : file.PresetOrder) { auto const& preset = file.Presets.at(p); - if (!preset.Hidden && + if (!preset.Unexpanded.Hidden && preset.Expanded && std::find_if(generators.begin(), generators.end(), [&preset](const GeneratorInfo& info) { - return info.name == preset.Generator; - }) != generators.end() && - file.ExpandMacros(preset)) { - presets.push_back(preset); + return info.name == preset.Unexpanded.Generator; + }) != generators.end()) { + presets.push_back(preset.Unexpanded); } } |