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 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:
{
"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:
{
"cmake.buildDirectory":
"${workspaceFolder}/build/${buildKitTargetOs}-${buildKitVendor}-${buildKitTargetArch}"
}
The possible results of build directories will look like:
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:
{
"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:
{
"cmake.buildDirectory": "${workspaceFolder}/build/${buildKitHostOs}_${buildKitTargetOs}"
}
In my case, I would like to set this settings like this:
{
"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
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 provided by CMake-Tools, we can design our custom build directory.1. Single-Config Generator
If I use single-config Generator, for example
MinGW MakefilesorNMake Makefiles, one Makefile file only supports one configuration. So in order to differentiate Debug and Release configurations, I will setcmake.buildDirectorylike this:{ "cmake.buildDirectory": "${workspaceFolder}/build/${buildKitTargetOs}-${buildKitVendor}-${buildKitTargetArch}-${buildType}" }The possible results of build directories will look like this:
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 ofcmake.buildDirectory:{ "cmake.buildDirectory": "${workspaceFolder}/build/${buildKitTargetOs}-${buildKitVendor}-${buildKitTargetArch}" }The possible results of build directories will look like:
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.buildDirectoryfor 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:
{ "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 ofcmake.buildDirectory:{ "cmake.buildDirectory": "${workspaceFolder}/build/${buildKitHostOs}_${buildKitTargetOs}" }In my case, I would like to set this settings like this:
{ "cmake.buildDirectory": { "singleConfig": "${workspaceFolder}/build/${buildKitTargetOs}-${buildKitVendor}-${buildKitTargetArch}-${buildType}", "multiConfig": "${workspaceFolder}/build/${buildKitTargetOs}-${buildKitVendor}-${buildKitTargetArch}" } }Platform and Version: