Skip to content

Commit

Permalink
Correct usage of toolset and architecture when no `configurepreset.ge…
Browse files Browse the repository at this point in the history
…nerator` is defined in the preset. (#4208)

* fix architecture and toolset with no preset generator

* conditionally get these values if we're using presets

* update changelog

* unnecessary import
  • Loading branch information
gcampbell-msft authored Jan 10, 2025
1 parent 1df786f commit 35f3449
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Bug Fixes:
- Ensure that tests are updated after a build. [#4148](https://github.com/microsoft/vscode-cmake-tools/pull/4148)
- Fix various GCC compiler errors and GCC linker errors not showing up in Problems View [#2864](https://github.com/microsoft/vscode-cmake-tools/issues/2864)
- Fix reloading presets when included files are changed or renamed and updated. [#3963](https://github.com/microsoft/vscode-cmake-tools/issues/3963)
- Fix the usage of toolset and archiecture in presets without generator set. [#4181](https://github.com/microsoft/vscode-cmake-tools/issues/4181)
- Fix compilation database path comparison with the `cmake.copyCompileCommands` that could otherwise overwrite that file. [#4207](https://github.com/microsoft/vscode-cmake-tools/issues/4207) [@k0zmo](https://github.com/k0zmo)
- Fix parsing of CMakeUserPresets.json containing configure preset that is referenced in workflow preset. [#4202](https://github.com/microsoft/vscode-cmake-tools/pull/4202)
- Fix auto select active project corner case. [#4146](https://github.com/microsoft/vscode-cmake-tools/issues/4146) Contributed by STMicroelectronics
Expand Down
8 changes: 8 additions & 0 deletions src/drivers/cmakeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,14 @@ export abstract class CMakeDriver implements vscode.Disposable {
return this._useCMakePresets;
}

get configurePresetArchitecture(): string | preset.ValueStrategy | undefined {
return this._configurePreset?.architecture;
}

get configurePresetToolset(): string | preset.ValueStrategy | undefined {
return this._configurePreset?.toolset;
}

private _configurePreset: preset.ConfigurePreset | null = null;

private _buildPreset: preset.BuildPreset | null = null;
Expand Down
15 changes: 15 additions & 0 deletions src/drivers/cmakeFileApiDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,21 @@ export class CMakeFileApiDriver extends CMakeDriver {
args.push('-A');
args.push(generator.platform);
}
} else {
if (this.useCMakePresets) {
const presetArchitecture = this.configurePresetArchitecture;
const presetToolset = this.configurePresetToolset;
const platform = presetArchitecture ? getValue(presetArchitecture) : undefined;
const toolset = presetToolset ? getValue(presetToolset) : undefined;
if (toolset) {
args.push('-T');
args.push(toolset);
}
if (platform) {
args.push("-A");
args.push(platform);
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/installs/visualStudio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function targetArchFromGeneratorPlatform(generatorPlatform?: string) {
if (!generatorPlatform) {
return undefined;
}
return vsArchFromGeneratorPlatform[generatorPlatform] || generatorPlatform;
return vsArchFromGeneratorPlatform[generatorPlatform.toLowerCase()] || generatorPlatform;
}

/**
Expand Down

0 comments on commit 35f3449

Please sign in to comment.