Skip to content

Commit

Permalink
ensure we update the driver's cmake (#3491)
Browse files Browse the repository at this point in the history
* ensure we update the driver's cmake

* update changelog
  • Loading branch information
gcampbell-msft authored Jan 2, 2024
1 parent 5c2fd6e commit e123bc2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions src/cmakeProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/cmakeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e123bc2

Please sign in to comment.