mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-04 04:03:22 +03:00
presets: De-duplicate field inheritance
Add maps to the existing set of helpers.
This commit is contained in:
1 parent
a22686a839
commit
9c1931af44
1 file changed
+12
-12
@@ -80,6 +80,15 @@ void InheritVector(std::vector<T>& child, std::vector<T> const& parent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void InheritMap(std::map<std::string, T>& child,
|
||||||
|
std::map<std::string, T> const& parent)
|
||||||
|
{
|
||||||
|
for (auto const& v : parent) {
|
||||||
|
child.insert(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check preset inheritance for cycles (using a DAG check algorithm) while
|
* Check preset inheritance for cycles (using a DAG check algorithm) while
|
||||||
* also bubbling up fields through the inheritance hierarchy, then verify
|
* also bubbling up fields through the inheritance hierarchy, then verify
|
||||||
@@ -142,9 +151,7 @@ bool VisitPreset(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const& v : parentPreset.Environment) {
|
InheritMap(preset.Environment, parentPreset.Environment);
|
||||||
preset.Environment.insert(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!preset.ConditionEvaluator) {
|
if (!preset.ConditionEvaluator) {
|
||||||
preset.ConditionEvaluator = parentPreset.ConditionEvaluator;
|
preset.ConditionEvaluator = parentPreset.ConditionEvaluator;
|
||||||
@@ -788,10 +795,7 @@ bool cmCMakePresetsGraph::ConfigurePreset::VisitPresetInherit(
|
|||||||
InheritOptionalValue(preset.WarnUninitialized, parent.WarnUninitialized);
|
InheritOptionalValue(preset.WarnUninitialized, parent.WarnUninitialized);
|
||||||
InheritOptionalValue(preset.WarnUnusedCli, parent.WarnUnusedCli);
|
InheritOptionalValue(preset.WarnUnusedCli, parent.WarnUnusedCli);
|
||||||
InheritOptionalValue(preset.WarnSystemVars, parent.WarnSystemVars);
|
InheritOptionalValue(preset.WarnSystemVars, parent.WarnSystemVars);
|
||||||
|
InheritMap(preset.CacheVariables, parent.CacheVariables);
|
||||||
for (auto const& v : parent.CacheVariables) {
|
|
||||||
preset.CacheVariables.insert(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -994,11 +998,7 @@ bool cmCMakePresetsGraph::PackagePreset::VisitPresetInherit(
|
|||||||
parent.InheritConfigureEnvironment);
|
parent.InheritConfigureEnvironment);
|
||||||
InheritVector(preset.Generators, parent.Generators);
|
InheritVector(preset.Generators, parent.Generators);
|
||||||
InheritVector(preset.Configurations, parent.Configurations);
|
InheritVector(preset.Configurations, parent.Configurations);
|
||||||
|
InheritMap(preset.Variables, parent.Variables);
|
||||||
for (auto const& v : parent.Variables) {
|
|
||||||
preset.Variables.insert(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
InheritOptionalValue(preset.DebugOutput, parent.DebugOutput);
|
InheritOptionalValue(preset.DebugOutput, parent.DebugOutput);
|
||||||
InheritOptionalValue(preset.VerboseOutput, parent.VerboseOutput);
|
InheritOptionalValue(preset.VerboseOutput, parent.VerboseOutput);
|
||||||
InheritString(preset.PackageName, parent.PackageName);
|
InheritString(preset.PackageName, parent.PackageName);
|
||||||
|
|||||||
Reference in new issue
Block a user