From 35f344905ff2a1c0220b04e26872f1bb82a48e3e Mon Sep 17 00:00:00 2001 From: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com> Date: Fri, 10 Jan 2025 14:11:08 -0500 Subject: [PATCH] Correct usage of toolset and architecture when no `configurepreset.generator` 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 --- CHANGELOG.md | 1 + src/drivers/cmakeDriver.ts | 8 ++++++++ src/drivers/cmakeFileApiDriver.ts | 15 +++++++++++++++ src/installs/visualStudio.ts | 2 +- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b0e5affa..5ca5bcac8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/drivers/cmakeDriver.ts b/src/drivers/cmakeDriver.ts index 3861b4895..08c9f3dbc 100644 --- a/src/drivers/cmakeDriver.ts +++ b/src/drivers/cmakeDriver.ts @@ -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; diff --git a/src/drivers/cmakeFileApiDriver.ts b/src/drivers/cmakeFileApiDriver.ts index b12571df8..70ec57366 100644 --- a/src/drivers/cmakeFileApiDriver.ts +++ b/src/drivers/cmakeFileApiDriver.ts @@ -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); + } + } } } diff --git a/src/installs/visualStudio.ts b/src/installs/visualStudio.ts index 4e5fb2d39..963a428e5 100644 --- a/src/installs/visualStudio.ts +++ b/src/installs/visualStudio.ts @@ -135,7 +135,7 @@ export function targetArchFromGeneratorPlatform(generatorPlatform?: string) { if (!generatorPlatform) { return undefined; } - return vsArchFromGeneratorPlatform[generatorPlatform] || generatorPlatform; + return vsArchFromGeneratorPlatform[generatorPlatform.toLowerCase()] || generatorPlatform; } /**