Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix generator logic #4033

Merged
merged 4 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
24 changes: 15 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,17 @@ 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)) {
if (!(gen_name.startsWith("Visual Studio") && platform === "win32")) {
return gen;
}
}
continue;
} else {
return gen;
Expand Down
Loading