造成这个的原因主要是: CMAKE_BUILD_TYPE的定义与vscode里面active build preset不一致造成的
修改方式:
在CMakePresets.json文件中增加对CMAKE_BUILD_TYPE的定义即可
"configurePresets": [
{
"name": "Default",
"hidden": true,
"binaryDir": "${sourceDir}/.build/${presetName}",
"generator": "Ninja"
},
{
"name": "LinuxRelease",
"inherits": "Default",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "LinuxDebug",
"inherits": "Default",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},