I have a cmake project for VSCode with several build variants.
That is, I have cmake-variants.json defined as:
{
"buildType": {
"default": "Debug",
"description": "The build type",
"choices": {
"Debug": {
"short": "Debug",
"long": "Debug: with debug info",
"buildType": "Debug"
},
"Release": {
"short": "Release",
"long": "Release: no debug info",
"buildType": "Release"
},
...
}
},
"buildVariant": {
"default": "gcc-a64",
"description": "Build variant (host or cross-compiling with GCC or Clang)",
"choices": {
"gcc-a64": {
"short": "gcc-a64",
"long": "GCCg cross-compile for A64",
},
....
}
}
}
And then in settings.json, I define cmake build directory using variant expansion as follows:
"C_Cpp.default.configurationProvider": "vector-of-bool.cmake-tools",
"cmake.buildDirectory": "${workspaceFolder}/build/${variant:buildVariant}-${buildType}"
"cmake.generator": "Ninja",
...
But now for remote debugging, I need the path to executable to be available in launch.json (i.e. path to the build artifacts):
"configurations": [
{
"name": "(cross-gdb) Launch program",
"type": "cppdbg",
"request": "launch",
"program": "/path/to/cmake/build/directory/program",
...
}
It seems that launch.json does not know about "cmake.buildDirectory": it only knows "${workspaceFolder}". Is there any way to tell launch json where the build artifacts should lie?
Found it myself:
"program": "${command:cmake.launchTargetDirectory}/program"
https://vector-of-bool.github.io/docs/vscode-cmake-tools/debugging.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With