summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog/QCMake.cxx
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/QtDialog/QCMake.cxx
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/QtDialog/QCMake.cxx')
-rw-r--r--Source/QtDialog/QCMake.cxx22
1 files changed, 11 insertions, 11 deletions
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index 9017a63..3789e93 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -157,8 +157,8 @@ void QCMake::setPreset(const QString& name, bool setBinary)
if (!name.isNull()) {
std::string presetName(name.toLocal8Bit());
- auto const& preset = this->CMakePresetsFile.Presets[presetName];
- auto expandedPreset = this->CMakePresetsFile.ExpandMacros(preset);
+ auto const& expandedPreset =
+ this->CMakePresetsFile.Presets[presetName].Expanded;
if (expandedPreset) {
if (setBinary) {
QString binaryDir =
@@ -420,8 +420,7 @@ QCMakePropertyList QCMake::properties() const
if (!this->PresetName.isNull()) {
std::string presetName(this->PresetName.toLocal8Bit());
- auto p = this->CMakePresetsFile.ExpandMacros(
- this->CMakePresetsFile.Presets.at(presetName));
+ auto const& p = this->CMakePresetsFile.Presets.at(presetName).Expanded;
if (p) {
for (auto const& v : p->CacheVariables) {
if (!v.second) {
@@ -537,7 +536,8 @@ void QCMake::loadPresets()
QVector<QCMakePreset> presets;
for (auto const& name : this->CMakePresetsFile.PresetOrder) {
- auto const& p = this->CMakePresetsFile.Presets[name];
+ auto const& it = this->CMakePresetsFile.Presets[name];
+ auto const& p = it.Unexpanded;
if (p.Hidden) {
continue;
}
@@ -554,12 +554,12 @@ void QCMake::loadPresets()
preset.toolset = std::move(QString::fromLocal8Bit(p.Toolset.data()));
preset.setGenConfig = !p.GeneratorConfig ||
p.GeneratorConfig == cmCMakePresetsFile::CMakeGeneratorConfig::Default;
- preset.enabled = std::find_if(this->AvailableGenerators.begin(),
- this->AvailableGenerators.end(),
- [&p](const cmake::GeneratorInfo& g) {
- return g.name == p.Generator;
- }) != this->AvailableGenerators.end() &&
- this->CMakePresetsFile.ExpandMacros(p);
+ preset.enabled = it.Expanded &&
+ std::find_if(this->AvailableGenerators.begin(),
+ this->AvailableGenerators.end(),
+ [&p](const cmake::GeneratorInfo& g) {
+ return g.name == p.Generator;
+ }) != this->AvailableGenerators.end();
presets.push_back(preset);
}
emit this->presetsChanged(presets);