This entry describes, how to use cmake, gcc, ninja and gdb inside VSCode. First you need two VSCode plugins:
- CMake Tools
- C/C++
In the settings.json add:
"cmake.generator": "Ninja",
"cmake.cmakePath": "C:/Tools/msys64/ucrt64/bin/cmake.exe",
"cmake.configureSettings": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++"
}
"cmake.environment": {
"PATH": "C:\\Tools\\msys64\\ucrt64\\bin;C:\\Tools\\msys64\\usr\\bin;${env:PATH}"
}
This will setup the CMake toolchain from MSys2. Running build should now call cmake from MSys2.
To setup debugging with gdb from MSys2, add a new configuration to launch.json. It should look something like this:
{
"name": "(gdb) test_app",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/build/test_app.exe",
"args": [ "../tc123456.bin" ],
"stopAtEntry": false,
"cwd": "${workspaceRoot}/build",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:/Tools/msys64/ucrt64/bin/gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}