Update: This was formerly discovered while I was playing around with passing args to my program. After playing around for a bit, I think this "might" be the reason: VS Code was complaining Running contributing command "cmake.outline.debugTarget" failed when I tried to debug.
It seems CMake: Execute the current target without a debugger or CMake: Debug target is not picking up my launch.json (so I could not pass in any args to my program), and VS code was also complaining Running contributing command cmake.outline.debugTarget failed (I could not find cmake.outline.debugTarget anywhere...so I am clueless how to resolve this)
Forgive me if I was being dumb. This issue was mentioned #99. I also checked the cmake documentation FAQ: The “Debug” button and “Debug target” features are ignoring my launch.json and Debugging with CMake Tools and launch.json, but they did not work.
I executed my target using CMake: Execute the current target without a debugger or CMake: Debug target (by, yeah, pressing F1 and hitting Enter), VS Code was complaining Running contributing command "cmake.outline.debugTarget" failed when I tried to debug
I have launch.json configured like
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
// Resolved by CMake Tools:
"program": "${command:cmake.launchTargetPath}",
"args": ["some_args_here"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
However, my program was still complaining I did not pass in any args (apparently my launch.json was not picked up by CMake tool as I inserted some random nonsense to this and the program was still executing).
same issue
I don't reproduce any debug command failure on latest CMake Tools (1.3.1). I just tried a simple project created with the cmake.quickStart command on WSL. The command succeeds even if the arguments don't reach my sample project and the sample "main" returns error.
But I can comment about launch.json and arguments passing.
When you use the CMake Tools debug command, your launch.json is not read. That is by design. A small simple launch.json is created on the fly and fed to the VSCode debugging infrastructure.
You can hook up some arguments to this scenario by defining "cmake.debugConfig" in your settings.
If you want to consume the launch.json for debugging, invoke the CppTools extension debug feature via "F5". That will still integrate with the CMake Tools extension via the command ${command:cmake.launchTargetPath}. And it will pick up any arguments you define.
Passing arguments to the non debug execution is not yet supported in CMake Tools. We are tracking this feature request with https://github.com/microsoft/vscode-cmake-tools/issues/924, which has an ongoing PR attached, so it will be fixed eventually. Not for the next release though since there are some issues to figure out about all the scenarios of quoting the arguments passed to various kinds of terminals.
A duplicate to that issue is https://github.com/microsoft/vscode-cmake-tools/issues/1177, which has some interesting workarounds.
Closing this as duplicate (since we track the arguments passing with the other issues) but reactivate if the debug command target failure is something different and still happening on latest CMake Tools.
Most helpful comment
I don't reproduce any debug command failure on latest CMake Tools (1.3.1). I just tried a simple project created with the cmake.quickStart command on WSL. The command succeeds even if the arguments don't reach my sample project and the sample "main" returns error.
But I can comment about launch.json and arguments passing.
When you use the CMake Tools debug command, your launch.json is not read. That is by design. A small simple launch.json is created on the fly and fed to the VSCode debugging infrastructure.
You can hook up some arguments to this scenario by defining "cmake.debugConfig" in your settings.
If you want to consume the launch.json for debugging, invoke the CppTools extension debug feature via "F5". That will still integrate with the CMake Tools extension via the command ${command:cmake.launchTargetPath}. And it will pick up any arguments you define.
Passing arguments to the non debug execution is not yet supported in CMake Tools. We are tracking this feature request with https://github.com/microsoft/vscode-cmake-tools/issues/924, which has an ongoing PR attached, so it will be fixed eventually. Not for the next release though since there are some issues to figure out about all the scenarios of quoting the arguments passed to various kinds of terminals.
A duplicate to that issue is https://github.com/microsoft/vscode-cmake-tools/issues/1177, which has some interesting workarounds.
Closing this as duplicate (since we track the arguments passing with the other issues) but reactivate if the debug command target failure is something different and still happening on latest CMake Tools.