microsoft / microsoft/vscode-cmake-tools
Better support for multi-config generators
- Dominant language
- TypeScript
- Stars
- 1.7k
- Forks
- 546
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 32
Description
### Brief Issue Summary
One of the advantages of multi-config generators (e.g. Ninja Multi-Config) is to not require up-front specification of the required build configuration type. This flows through to `CMakePresets.json`, where you can omit the `configuration` field in the preset. For example:
```json
{
"version": 3,
"configurePresets": [{
"name": "ninja-multi-config",
"generator": "Ninja Multi-Config",
"binaryDir": "${sourceDir}/cmake-build-ninja-multi-config/"
}],
"buildPresets": [{
"name": "my-app",
"configurePreset": "ninja-multi-config",
"targets": "my-app-target"
}]
}
```
```
cmake --preset ninja-multi-config # Prepare for all configuration types in CMAKE_CONFIGURATION_TYPES
cmake --build --preset my-app --config [Debug|Release|RelWithDebugInfo|MinSizeRel|...]
```
If no `--config` switch is given, it will build the `CMAKE_DEFAULT_BUILD_TYPE` if set (this applies to multi-config generators only) or falls back to the first item in `CMAKE_CONFIGURATION_TYPES` (which is typically `Debug`).
As far as I can tell, this extension provides no way to specify a build type dynamically in this way. The only option is to explode the presets file to include every permutation of build type for each target.
It would be nice if this was detected, and an additional drop down given. The available options will always be defined in `CMAKE_CONFIGURATION_TYPES`.
In addition, currently this way of working fails in another way where the extension detects that no configuration was provided in the preset. You get the following error:
`The build configurations generated do not contain the active build configuration. Using "Debug" for CMAKE_BUILD_TYPE instead of "null" to ensure that Intellisense configurations can be found`
There are a couple of things wrong with this.
1. Firstly `CMAKE_BUILD_TYPE` has no meaning for multi-config generators, it should pass `--config Debug` for the build step instead.
2. It should not fall back to "Debug" if `CMAKE_DEFAULT_BUILD_TYPE` is set. Again, this is specific to multi-config generators.
### CMake Tools Diagnostics
_No response_
### Debug Log
_No response_
### Additional Information
_No response_
Contributor guide
Research direction
Start by tracing the extension's configure-preset and build-preset handling for CMakePresets.json, focusing on CMAKE_CONFIGURATION_TYPES and CMAKE_DEFAULT_BUILD_TYPE. Compare behavior when configuration is omitted and verify how the active configuration is selected. Done means multi-config presets offer the available configuration choices, pass --config for builds, and respect CMAKE_DEFAULT_BUILD_TYPE without forcing Debug.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, typescript
- Domain
- build-system, developer-experience
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100