Just starting to use the cmake tools built into VS 2022 and i built a quick windows test program based off of the CMakeLists.txt and CMakePresets.json which are generated when i create a new project using the ‘CMake Project’ template. This works fine; the test project builds and runs. The issue is that I can’t find a way to switch from a Debug build config to Release. In the Standard Toolbar, the ‘Build Preset Selector’ is not showing, even though in the toolbar configuration it is enabled. I tried forcing this with ‘set(CMAKE_CONFIGURATION_TYPES “Release”)’ in CMakeLists.txt and nothing. Seems like I’m missing something obvious.
Is your project available?
With CMake presets, you need i.e. a Debug and a Release preset.
here is the CMakePresets.json file:
{
"version": 3,
"configurePresets": [
{
"name": "windows-base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "x64-debug",
"displayName": "x64 Debug",
"inherits": "windows-base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x64-release",
"displayName": "x64 Release",
"inherits": "x64-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x86-debug",
"displayName": "x86 Debug",
"inherits": "windows-base",
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x86-release",
"displayName": "x86 Release",
"inherits": "x86-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
]
}
You need a build preset
for every configure preset
at least.
I recommend to add workflow presets
too.
thanks for the help Claus!