Skip to content

Commit

Permalink
Add "Unspecified" Build Type and Use by Default (Kits Only) (#3879)
Browse files Browse the repository at this point in the history
* add unspecified build type and remove CMAKE_BUILD_TYPE prop when it's used

* reverted commenting out debugger

* let debugger stop on error again

* updated changelog

* updated the docs with the new option

* updated default kit build type

* fix failing tests

---------

Co-authored-by: Garrett Campbell <[email protected]>
  • Loading branch information
snehara99 and gcampbell-msft authored Jul 11, 2024
1 parent 46aac7d commit c892b18
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

Improvements:

- Add `Unspecified` option for selecting a kit variant to allow CMake itself to select the build type. [#3821](https://github.com/microsoft/vscode-cmake-tools/issues/3821)
- Skip loading variants when using CMakePresets. [#3300](https://github.com/microsoft/vscode-cmake-tools/issues/3300)

Bug Fixes:
Expand Down Expand Up @@ -33,7 +34,7 @@ Bug Fixes:
- Update localized strings for Project Status UI and quick pick dropdowns. [#3803](https://github.com/microsoft/vscode-cmake-tools/issues/3803), [#3802](https://github.com/microsoft/vscode-cmake-tools/issues/3802)
- Fix issue where new presets couldn't inherit from presets in CmakeUserPresets.json. These presets are now added to CmakeUserPresets.json instead of CmakePresets.json. [#3725](https://github.com/microsoft/vscode-cmake-tools/issues/3725)
- Fix issue where CMakeTools does not recheck CMake Path to see if user installed CMake after launching VS Code. [3811](https://github.com/microsoft/vscode-cmake-tools/issues/3811)
- Fix issue where `cmake.buildToolArgs` was sometimes applied incorrectly when presets are used [#3754](https://github.com/microsoft/vscode-cmake-tools/issues/3754)
- Fix issue where `cmake.buildToolArgs` was sometimes applied incorrectly when presets are used. [#3754](https://github.com/microsoft/vscode-cmake-tools/issues/3754)
- Fix issue where `preferredGenerator.platform` and `preferredGenerator.toolset` wasn't being compared between the old and new kit to trigger a clean configure on a kit selection change. [#2699](https://github.com/microsoft/vscode-cmake-tools/issues/2699)
- Still allow for users to add `--warn-unused-cli`. Now instead of overriding, it will remove our default `--no-warn-unused-cli`. [#1090](https://github.com/microsoft/vscode-cmake-tools/issues/1090)
- Ensure `useCMakePresets` context is set after making a CMakePreset.json with `Quick Start`. [#3734](https://github.com/microsoft/vscode-cmake-tools/issues/3734)
Expand All @@ -47,7 +48,7 @@ Bug Fixes:
## 1.18.41
Features:

- Add the possibility to open the current build directory in the Explorer [#1451](https://github.com/microsoft/vscode-cmake-tools/issues/1451)
- Add the possibility to open the current build directory in the Explorer. [#1451](https://github.com/microsoft/vscode-cmake-tools/issues/1451)
- Add support for CMakePresets V7 and V8. [#3549](https://github.com/microsoft/vscode-cmake-tools/issues/3549)
- Update `api.ts` to add the `onSelectedConfigurationChanged` event. [#3671](https://github.com/microsoft/vscode-cmake-tools/pull/3671) [@OrkunTokdemir](https://github.com/OrkunTokdemir)
- Improve CMake QuickStart by allowing the user to dynamically create a CMakePresets.json file. [#3649](https://github.com/microsoft/vscode-cmake-tools/issues/3649)
Expand Down
15 changes: 8 additions & 7 deletions docs/variants.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ The main way to create a variant is via a `cmake-variants.json` or `cmake-varian

Variants are a different concept than toolchains or toolsets. Those are handled by [CMake kits](kits.md).

By default, if a variants file isn't present, CMake Tools loads four variants that correspond to default CMake build types: **Release**, **Debug**, **MinSizeRel**, and **RelWithDebInfo**. These variants do the following:
By default, if a variants file isn't present, CMake Tools loads five options. Four options are variants that correspond to the default CMake build types: **Release**, **Debug**, **MinSizeRel**, and **RelWithDebInfo**. One **Unspecified** option lets CMake select the build type itself. The options do the following:

|Option | Description |
| Option | Description |
|---------|---------|
|`Debug` | Disables optimizations and includes debug info.|
|`Release`| Includes optimizations but no debug info.|
|`MinSizeRel`| Optimizes for size. No debug info.|
|`RelWithDebInfo` | Optimizes for speed but also includes debug info. |
| `Debug` | Variant - Disables optimizations and includes debug info. |
| `Release` | Variant - Includes optimizations but no debug info. |
| `MinSizeRel` | Variant - Optimizes for size. No debug info. |
| `RelWithDebInfo` | Variant - Optimizes for speed but also includes debug info. |
| `Unspecified` | Lets CMake select a default build type. |

Selecting one of these variants configures and builds using the corresponding build type.
Selecting one of the variants configures and builds using the corresponding build type.

> **Important:**
> CMake Tools does not respect `CMAKE_CONFIGURATION_TYPES`. Only the default configuration types listed above are present. A custom variant file is required to load other build types.
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2437,6 +2437,11 @@
"short": "RelWithDebInfo",
"long": "%cmake-tools.configuration.cmake.defaultVariants.buildType.reldeb.long%",
"buildType": "RelWithDebInfo"
},
"unspecified": {
"short": "Unspecified",
"long": "%cmake-tools.configuration.cmake.defaultVariants.buildType.unspecified.long%",
"buildType": "Unspecified"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"cmake-tools.configuration.cmake.debugConfig.setupCommands.description.description": "Description of the command.",
"cmake-tools.configuration.cmake.defaultVariants.overall.description": "Configure the default variant settings.",
"cmake-tools.configuration.cmake.defaultVariants.buildType.description": "The build type.",
"cmake-tools.configuration.cmake.defaultVariants.buildType.unspecified.long": "Let CMake pick the default build type.",
"cmake-tools.configuration.cmake.defaultVariants.buildType.debug.long": "Disable optimizations - include debug information.",
"cmake-tools.configuration.cmake.defaultVariants.buildType.release.long": "Optimize for speed - exclude debug information.",
"cmake-tools.configuration.cmake.defaultVariants.buildType.minsize.long": "Optimize for smallest binary size - exclude debug information.",
Expand Down
6 changes: 4 additions & 2 deletions src/drivers/cmakeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1664,8 +1664,10 @@ export abstract class CMakeDriver implements vscode.Disposable {

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

if (!this.isMultiConfFast || (this.isMultiConfFast && allowBuildTypeOnMultiConfig)) {
// Mutliconf generators do not need the CMAKE_BUILD_TYPE property
if ((!this.isMultiConfFast || (this.isMultiConfFast && allowBuildTypeOnMultiConfig)) && (this.currentBuildType !== "Unspecified")) {
// Mutliconf generators do not need the CMAKE_BUILD_TYPE property.
// Also, do not set CMAKE_BUILD_TYPE when the user has not
// specified the build type.
settingMap.CMAKE_BUILD_TYPE = util.cmakeify(this.currentBuildType);
}

Expand Down
5 changes: 5 additions & 0 deletions src/variant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ export const DEFAULT_VARIANTS: VarFileRoot = {
short: 'RelWithDebInfo',
long: localize('optimize.and.debug', 'Perform optimizations AND include debugging information'),
buildType: 'RelWithDebInfo'
},
unspecified: {
short: 'Unspecified',
long: localize('unspec.build.type', 'Let CMake pick the default build type'),
buildType: 'Unspecified'
}
}
}
Expand Down

0 comments on commit c892b18

Please sign in to comment.