Skip to content

Commit

Permalink
Fix1639 - Don't have unremovable options for the configure command. A…
Browse files Browse the repository at this point in the history
…llow user to override the usual args passed by the extention towards cmake via configureSettings (#3266)

Co-authored-by: Garrett Campbell <[email protected]>
  • Loading branch information
andreeis and gcampbell-msft authored Jul 31, 2023
1 parent 49fbd3e commit 1205f3b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Bug Fixes:
- When using CMake presets, the Project Status View now shows the build target along with the build preset. [PR #3241](https://github.com/microsoft/vscode-cmake-tools/pull/3241)
- Fix per-folder browse configurations returning incorrect information. [#3155](https://github.com/microsoft/vscode-cmake-tools/issues/3155)
- IntelliSense resolves headers coming from MacOS frameworks. CMake 3.27 or later is required. [#2324](https://github.com/microsoft/vscode-cmake-tools/issues/2324)
- Allow configure settings to override the usual arguments the extension is usually passing to cmake. Don't have unremovable options. [#1639](https://github.com/microsoft/vscode-cmake-tools/issues/1639)
- Fix triggers of "Bad CMake Executable" error message. [#2368](https://github.com/microsoft/vscode-cmake-tools/issues/2368)
- Don't ignore empty cache string variables when configuring from presets. [#1842](https://github.com/microsoft/vscode-cmake-tools/issues/1842)
- Fix active build configuration warning coming from CppTools. [#2353](https://github.com/microsoft/vscode-cmake-tools/issues/2353)
Expand Down
24 changes: 13 additions & 11 deletions src/drivers/cmakeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1502,23 +1502,12 @@ export abstract class CMakeDriver implements vscode.Disposable {
private generateCMakeSettingsFlags(): string[] {
const settingMap: { [key: string]: util.CMakeValue } = {};

try {
util.objectPairs(this.config.configureSettings).forEach(([key, value]) => settingMap[key] = util.cmakeify(value));
} catch (e: any) {
log.error(e.message);
throw e;
}
util.objectPairs(this._variantConfigureSettings).forEach(([key, value]) => settingMap[key] = util.cmakeify(value as string));
if (this._variantLinkage !== null) {
settingMap.BUILD_SHARED_LIBS = util.cmakeify(this._variantLinkage === 'shared');
}

const configurationScope = this.workspaceFolder ? vscode.Uri.file(this.workspaceFolder) : null;
const config = vscode.workspace.getConfiguration("cmake", configurationScope);
// Export compile_commands.json
const exportCompileCommandsSetting = config.get<boolean>("exportCompileCommandsFile");
const exportCompileCommandsFile: boolean = exportCompileCommandsSetting === undefined ? true : (exportCompileCommandsSetting || false);
settingMap.CMAKE_EXPORT_COMPILE_COMMANDS = util.cmakeify(exportCompileCommandsFile);

const allowBuildTypeOnMultiConfig = config.get<boolean>("setBuildTypeOnMultiConfig") || false;

Expand All @@ -1533,6 +1522,19 @@ export abstract class CMakeDriver implements vscode.Disposable {
settingMap.CMAKE_INSTALL_PREFIX = util.cmakeify(this.installDir);
}

try {
util.objectPairs(this.config.configureSettings).forEach(([key, value]) => settingMap[key] = util.cmakeify(value));
} catch (e: any) {
log.error(e.message);
throw e;
}
util.objectPairs(this._variantConfigureSettings).forEach(([key, value]) => settingMap[key] = util.cmakeify(value as string));

// Export compile_commands.json
const exportCompileCommandsSetting = config.get<boolean>("exportCompileCommandsFile");
const exportCompileCommandsFile: boolean = exportCompileCommandsSetting === undefined ? true : (exportCompileCommandsSetting || false);
settingMap.CMAKE_EXPORT_COMPILE_COMMANDS = util.cmakeify(exportCompileCommandsFile);

console.assert(!!this._kit);
if (!this._kit) {
throw new Error(localize('no.kit.is.set', 'No kit is set!'));
Expand Down

0 comments on commit 1205f3b

Please sign in to comment.