Is there a way to configure what happens when I press "Launch selected target without debugging" command in CMakeTools in VSCode?
My problem is that the target is launched but it doesn't pick up the config file I specified in my launch.json for the Debug configuration:
launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "lldb",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [
"/home/<myuser>/dev/my_api_conf.ini"
],
"cwd": "${workspaceRoot}",
"preLaunchTask": "${defaultBuildTask}",
"initCommands": [ "command source ${workspaceRoot}/.lldbinit"]
}
]
}
Use the cmake.debugConfig
setting (docs). I think it uses the same schema as the cppdbg
launch configuration type. You can use it in your workspace .vscode/settings.json file, or your user settings.json file. I noticed this setting thanks to this comment in a historically related issue ticket. For some reason, at the time of this writing, this setting is not mentioned in https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/debug-launch.md. I'm not sure if anything from this applies to running without debugging, but it's definitely used with the CMake: Debug
command / action.
If you want to use your launch config, then you will have to use the keyboard shortcut / command / button for running with that launch config- not the button provided by CMake Tools. Ex. the button in the Run and Debug View, or the Debug: Start Without Debugging
command in the command palette (instead of the CMake: Run Without Debugging
command).
If you want different targets to have different launch configurations, see In CMake Tools, how to have different args for launching different targets?.