Skip to content

Commit

Permalink
fix generator logic (#4033)
Browse files Browse the repository at this point in the history
* fix generator logic

* fix logic

* fix logic

* fix use of gen.name
  • Loading branch information
gcampbell-msft authored Aug 30, 2024
1 parent 4a334a6 commit 5fbcb13
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

## 1.19.50

Bug Fixes:
Bug Fixes:

- Fix env expansion of all variables (toolchainFile, etc.) in presets. [#4019](https://github.com/microsoft/vscode-cmake-tools/issues/4019)
- Fix generator and preferredGenerator logic. [#4031](https://github.com/microsoft/vscode-cmake-tools/issues/4031), [#4005](https://github.com/microsoft/vscode-cmake-tools/issues/4005), [#4032](https://github.com/microsoft/vscode-cmake-tools/issues/4032)

## 1.19.49

Expand Down
22 changes: 13 additions & 9 deletions src/drivers/cmakeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -744,17 +744,17 @@ export abstract class CMakeDriver implements vscode.Disposable {
preferredGenerators.push({ name: "Unix Makefiles" });
}

// If a generator is set in the "cmake.generator" setting, push it to the front
// of the "best generator" logic
// Use the "best generator" logic only if the user did not define a particular
// generator to be used via the `cmake.generator` setting.
if (this.config.generator) {
preferredGenerators.unshift({
this._generator = {
name: this.config.generator,
platform: this.config.platform || undefined,
toolset: this.config.toolset || undefined
});
};
} else {
this._generator = await this.findBestGenerator(preferredGenerators);
}

this._generator = await this.findBestGenerator(preferredGenerators);
}

protected abstract doSetConfigurePreset(needsClean: boolean, cb: () => Promise<void>): Promise<void>;
Expand Down Expand Up @@ -1004,7 +1004,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
return false;
})();
if (!generator_present) {
const vsMatch = /^(Visual Studio \d{2} \d{4})($|\sWin64$|\sARM$)/.exec(gen.name);
const vsMatch = /^(Visual Studio \d{2} \d{4})($|\sWin64$|\sARM$)/.exec(gen_name);
if (platform === 'win32' && vsMatch) {
let possibleArchitecture = vsMatch[2].trim();
if (possibleArchitecture && possibleArchitecture === "Win64") {
Expand All @@ -1016,11 +1016,15 @@ export abstract class CMakeDriver implements vscode.Disposable {
toolset: gen.toolset
};
}
if (gen.name.toLowerCase().startsWith('xcode') && platform === 'darwin') {
if (gen_name.toLowerCase().startsWith('xcode') && platform === 'darwin') {
return gen;
}

// If the generator isn't found, move on to the next one
// If it is not a common generator that we can find, but it is a known cmake generator (cmakeGenerators), return it.
// The only caveat is that we should not return a Visual Studio generator on non-Windows platforms.
if (this.cmakeGenerators.indexOf(gen_name) >= 0 && !this.isCommonGenerator(gen_name) && !(gen_name.startsWith("Visual Studio") && platform !== "win32")) {
return gen;
}
continue;
} else {
return gen;
Expand Down

0 comments on commit 5fbcb13

Please sign in to comment.