Visual Studio 2022 CMake 预设

Visual Studio 2022 CMake Presets

我在我的项目中使用 CMake,我开始探索 CMakePresets 的可能性

我设法创建了一个默认 windows 预设。目前我的 Windows 默认预设将 CMAKE_BUILD_TYPE 设置为调试。 现在我想 select 左侧下拉菜单中的配置和右侧下拉菜单中的构建类型(见图)

这有可能吗?

谢谢你的帮助

我只是自己理解这一点,但我相信你想要的是像这样设置“buildPresets”:

{
   "name": "windows-debug",
   "displayName": "Debug",
   "configurePreset": "windows-default",
   "configuration": "Debug"
},
{
   "name": "windows-release",
   "displayName": "Release",
   "configurePreset": "windows-default",
   "configuration": "Release"
}

我认为应该使用“配置”而不是 CMAKE_BUILD_TYPE,因为它与

中的标志 --config 相同
> cmake --build . --config Release

来源:https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html#build-preset