我运行CMake: Select Variant
选择Relaese
并CMake: Configure
更新buid/CMakeCache.txt
以反映变体:
CMAKE_BUILD_TYPE:STRING=Release
CMake 扩展是 VSCode在项目状态Release
中显示的Configure
。但是,构建总是在x64/Debug
文件夹中输出构建工件,并且二进制文件是用而不是构建的,CMAKE_CXX_FLAGS_DEBUG
正如CMAKE_CXX_FLAGS_RELEASE
我使用file
命令检查时显示的那样with debug_info, not stripped
我Release
在 VSCode 终端输出中看到:
build task started....
/usr/bin/cmake --build /usr/src/MyApp/build --config Release --target all --
然而,在构建结束时,可执行文件被链接并构建在Debug
文件夹中:
[6/6 100% :: 11.014] Linking CXX executable /usr/src/MyApp/x64/Debug/Console
CMake: Log Diagnostics
:
{
"os": "linux",
"vscodeVersion": "1.94.2",
"cmtVersion": "1.19.52",
"configurations": [
{
"folder": "/usr/src/MyApp",
"cmakeVersion": "3.30.3",
"configured": true,
"generator": "Ninja",
"usesPresets": false,
"compilers": {
"C": "/usr/bin/gcc",
"CXX": "/usr/bin/g++"
}
}
],
"cpptoolsIntegration": {
"isReady": true,
"hasCodeModel": true,
"activeBuildType": "Release",
"buildTypesSeen": [
"Debug"
],
"requests": [],
"responses": [],
"partialMatches": [],
"targetCount": 31,
"executablesCount": 2,
"librariesCount": 1,
"targets": []
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "auto",
"configureOnOpen": true
}
]
当我CMake: Configure
从 VSCode 命令面板运行时:
[cpptools] The build configurations generated do not contain the active build configuration. Using "Debug" for CMAKE_BUILD_TYPE instead of "Release" to ensure that IntelliSense configurations can be found
根据文献
--config <cfg>
记载但是在您预设中定义的“生成器”:“Ninja”并不是多配置工具。
我猜测它应该是“Ninja Multi-Config”。