Visual Studio 2022是否支持CMakePresets v6版本?
我尝试在CMakePresets.json中使用outputJUnitFile选项,该选项是CMakePresets v6版本(要求CMake ≥3.25)新增的功能。根据相关视频内容,该功能理应从VS 17.7版本开始支持,但我使用的VS 17.12.3版本中,CMakePresets的最高支持版本仍显示为v5。
我有两个疑问:
- VS本地安装的schema是否只是过时,IDE实际上支持与自带CMake版本匹配的CMakePresets?
- 还是VS 2022确实仅支持到CMakePresets v5版本?
我未能找到VS2022对CMakePresets支持进展的相关信息,仅能找到2023年6月9日更新的Microsoft Learn文档,以及2024年4月24日Pure Virtual C++大会的相关视频。不确定该功能是否已支持但我操作有误,或是被推迟到VS 2024等后续版本。
我的配置
测试预设配置
"testPresets": [ { "name": "vs-test", "configurePreset": "vs-with-test", "output": { "shortProgress": true, "verbosity": "verbose", "outputOnFailure": true, "outputJUnitFile": "${sourceDir}/out/test/vs-test/results.xml" }, "execution": { "noTestsAction": "error", "stopOnFailure": false }, "condition": { "type": "equals", "lhs": "${hostSystemName}", "rhs": "Windows" } }, { "name": "vs-nost-test", "configurePreset": "vs-nost-with-test", "inherits": "vs-test", "output": { "outputJUnitFile": "${sourceDir}/out/test/vs-nost-test/results.xml" } }, { "name": "vs64-test", "configurePreset": "vs64-with-test", "inherits": "vs-test", "output": { "outputJUnitFile": "${sourceDir}/out/test/vs64-test/results.xml" } }, { "name": "vs64-nost-test", "configurePreset": "vs64-nost-with-test", "inherits": "vs-nost-test", "output": { "outputJUnitFile": "${sourceDir}/out/test/vs64-nost-test/results.xml" } } ]
版本与最低CMake要求
"version": 6, "cmakeMinimumRequired": { "major": 3, "minor": 25, "patch": 0 }
出现的警告
上述配置导致Visual Studio 2022的错误列表中出现如下警告,且VS会回退到默认配置:
Severity Description Project File Line
Warning Property name is not allowed by the schema Miscellaneous Files Code\TestCPP\CMakePresets.json 375
Warning Property name is not allowed by the schema Miscellaneous Files Code\TestCPP\CMakePresets.json 392
Warning Property name is not allowed by the schema Miscellaneous Files Code\TestCPP\CMakePresets.json 400
Warning Property name is not allowed by the schema Miscellaneous Files Code\TestCPP\CMakePresets.json 408
请问我是否应该向Visual Studio团队提交bug?
更新记录
- UPDATE 1:尝试手动更新CMakePresets v6的JSON schema但未成功。VS 2022运行时更新schema后不会重新加载,重启VS则会将schema文件还原为旧的v5版本。已将VS 2022更新至17.12.4版本(2025-01-23),但其自带的CMakePresets JSON schema仍为CMake 3.24对应的v5版本。
- UPDATE 2:已向Visual Studio团队提交相关问题,补充了VS 2022 CMake Presets集成支持情况的信息及疑问。VS 2022 17.12.4版本自带的CMake 3.29.5支持CMakePresets.json schema v8,但VS的CMake Presets集成仍仅支持到v5版本。截至2025-02-05,已收到微软反馈并回复。
- UPDATE 3:微软已确认并修复了与该问题相关的多个问题,目前这些修复待发布。另有一个未修复的问题正在排队等待优先级划分(该问题与使用不支持的版本标识符但VS未报错相关),相关问题已有部分进展。
内容的提问来源于stack exchange,提问作者jhyry

