microsoft / microsoft/vscode-cmake-tools
[Feature] Add option to specify `cmake.buildDirectory` for single- and multi-config generators, respectively
- Dominant language
- TypeScript
- Stars
- 1.7k
- Forks
- 546
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 32
Description
## Problem Description
In CMake Generator, there are **single-** and **multi-config** generator to choose. If we use **single-config**, such as `MinGW Makefiles`, I would like to separate build directories for **Configurations** and **Architectures**. Thanks to the [Substitution Variable](https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/cmake-settings.md#variable-substitution) provided by CMake-Tools, we can design our custom build directory.
### 1. Single-Config Generator
If I use **single-config** Generator, for example `MinGW Makefiles` or `NMake Makefiles`, one **Makefile** file only supports one configuration. So in order to differentiate **Debug** and **Release** configurations, I will set `cmake.buildDirectory` like this:
```json
{
"cmake.buildDirectory":
"${workspaceFolder}/build/${buildKitTargetOs}-${buildKitVendor}-${buildKitTargetArch}-${buildType}"
}
```
The possible results of build directories will look like this:
```
build/
win32-MSVC-x64-Debug/
win32-MSVC-x64-Release/
win32-MSVC-x86-Debug/
win32-MSVC-x86-Release/
win32-GCC-x86-Debug/
win32-GCC-x86-Release/
win32-GCC-x86-MinSizeRel/
```
### 2. Multi-Config Generator
However, if I choose to use **multi-config** generators such as `Ninja Multi-Config`, it is a waste to separate different configurations into individual sub-folders. So I will delete `${buildType}` variable from the **single-config** format. Here is my format of `cmake.buildDirectory`:
```json
{
"cmake.buildDirectory":
"${workspaceFolder}/build/${buildKitTargetOs}-${buildKitVendor}-${buildKitTargetArch}"
}
```
The possible results of build directories will look like:
```bash
build/
win32-MSVC-x64/
win32-MSVC-x86/
win32-GCC-x64/
win32-GCC-x86/
```
## Expected Setting
I hope CMake-Tools can give us an option to set `cmake.buildDirectory` for **single-config** and **multi-config**, respectively. And Then CMake-Tools will **auto-detect** which type our currently-used generator belongs to, **single-config** or **multi-config**.
For example:
```json
{
"cmake.buildDirectory": {
"singleConfig": "${workspaceFolder}/build",
"multiConfig": "${workspaceFolder}/build",
}
}
```
Of course, we can still retain the original format of `cmake.buildDirectory`. That means both **single-** and **multi-config** will use the same format of `cmake.buildDirectory`:
```json
{
"cmake.buildDirectory": "${workspaceFolder}/build/${buildKitHostOs}_${buildKitTargetOs}"
}
```
In my case, I would like to set this settings like this:
```json
{
"cmake.buildDirectory": {
"singleConfig":
"${workspaceFolder}/build/${buildKitTargetOs}-${buildKitVendor}-${buildKitTargetArch}-${buildType}",
"multiConfig":
"${workspaceFolder}/build/${buildKitTargetOs}-${buildKitVendor}-${buildKitTargetArch}"
}
}
```
## Platform and Version:
- **Visual Studio Code Version:** 1.65.2
- **CMake Tools Version:** 1.9.2
- **CMake Version:** 3.21.2
Contributor guide
Assessment
This issue has not been assessed yet.