Skip to content

Commit

Permalink
Fix preset inheritance for condition field. (#3494)
Browse files Browse the repository at this point in the history
The parent condition shouldn't be considered if a child preset defines
its own condition. Basically, a child-defined condition overrides
inherited conditions. This is based on feedback and experimentation with
the cmake.exe cli.
  • Loading branch information
gcampbell-msft authored Dec 19, 2023
1 parent 6876476 commit b34d610
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,12 @@ function evaluateInheritedPresetConditions(preset: Preset, allPresets: Preset[],
}

export function evaluatePresetCondition(preset: Preset, allPresets: Preset[], references?: Set<string>): boolean | undefined {
if (!evaluateInheritedPresetConditions(preset, allPresets, references || new Set<string>())) {
const condition = preset.condition;

if (condition === undefined && !evaluateInheritedPresetConditions(preset, allPresets, references || new Set<string>())) {
return false;
}

const condition = preset.condition;
if (condition === undefined || condition === null) {
return true;
} else if (typeof condition === 'boolean') {
Expand Down

0 comments on commit b34d610

Please sign in to comment.