From e123bc29a2c56f0101714db647b5b745a6ad318e Mon Sep 17 00:00:00 2001 From: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com> Date: Mon, 1 Jan 2024 20:49:14 -0500 Subject: [PATCH] ensure we update the driver's cmake (#3491) * ensure we update the driver's cmake * update changelog --- CHANGELOG.md | 1 + src/cmakeProject.ts | 8 ++++++++ src/drivers/cmakeDriver.ts | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 207f1f466..1fd60cde8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Bug Fixes: - Ensure that the output is cleared for `debugTarget` and `launchTarget` [#3489](https://github.com/microsoft/vscode-cmake-tools/issues/3489) - Fix the inheritance of the `environment` for CMakePresets. [#3473](https://github.com/microsoft/vscode-cmake-tools/issues/3473) - Removed an unnecessary `console.assert` [#3474](https://github.com/microsoft/vscode-cmake-tools/issues/3474) +- Ensure that, when switching between presets, the CMake executable is modified. [#2791](https://github.com/microsoft/vscode-cmake-tools/issues/2791) ## 1.16.32 Improvements: diff --git a/src/cmakeProject.ts b/src/cmakeProject.ts index c023877c4..182327f8b 100644 --- a/src/cmakeProject.ts +++ b/src/cmakeProject.ts @@ -285,6 +285,7 @@ export class CMakeProject { await this.resetPresets(drv); return; } + const priorCMakePath = await this.getCMakePathofProject(); // used for later comparison to determine if we need to update the driver's cmake. this._configurePreset.set(expandedConfigurePreset); if (previousGenerator && previousGenerator !== expandedConfigurePreset?.generator) { await this.shutDownCMakeDriver(); @@ -294,6 +295,13 @@ export class CMakeProject { try { this.statusMessage.set(localize('reloading.status', 'Reloading...')); await drv.setConfigurePreset(expandedConfigurePreset); + const updatedCMakePath = await this.getCMakePathofProject(); + + // check if we need to update the driver's cmake, if so, update. + if (priorCMakePath !== updatedCMakePath) { + drv.cmake = await this.getCMakeExecutable(); + } + await this.workspaceContext.state.setConfigurePresetName(this.folderName, configurePreset, this.isMultiProjectFolder); this.statusMessage.set(localize('ready.status', 'Ready')); } catch (error: any) { diff --git a/src/drivers/cmakeDriver.ts b/src/drivers/cmakeDriver.ts index 639687265..928452cb9 100644 --- a/src/drivers/cmakeDriver.ts +++ b/src/drivers/cmakeDriver.ts @@ -184,7 +184,7 @@ export abstract class CMakeDriver implements vscode.Disposable { * Construct the driver. Concrete instances should provide their own creation * routines. */ - protected constructor(public readonly cmake: CMakeExecutable, + protected constructor(public cmake: CMakeExecutable, readonly config: ConfigurationReader, protected sourceDirUnexpanded: string, // The un-expanded original source directory path, where the CMakeLists.txt exists. private readonly isMultiProject: boolean,