Target Debugging
This issue is used to collect feedback on the experimental Target Debugging feature.
If you have tried out target debugging and find that it works and is useful for your project, add a 👍 reaction to let me know.
Any feedback would be highly appreciated.
Learn more about this feature in these docs for Target Debugging.
This line makes it possible to make tools working:
include(${CMAKE_BINARY_DIR}/CMakeTools/CMakeToolsHelpers.cmake)
Launching of application is working but launch.json provide possibility to pass environment variables but CMakeTools are not.
CMake Tools sets up the module path such that you only need to
include(CMakeToolsHelpers OPTIONAL)
and it will be fine. No need to specify the full path to the file. Actually: please do not specify the full path, because it may be moved in the future. See the docs on how to configure the debugger, which should let you specify environment variables, program arguments, etc.
Thanks for trying it out! Any feedback is welcome!
include(CMakeToolsHelpers OPTIONAL)
It doesn't work for me (OSX cmake version 3.6.1).
CMake Tools generates a debugging configuration object on-the-fly, when debugging is requested. To set some additional parameters to this debug configuration, use the cmake.debugConfig
How environment variables should be passed to cmake.debugConfig? Thanks!
Hmm... do you set(CMAKE_MODULE_PATH ...) at any point in your CMakeLists.txt? Does it fail with any error/warning messages?
For configuring, set the same values in the all section of the cmake.debugConfig that you would in a launch.json file. For example:
"cmake.debugConfig": {
"all": {
"request": "launch",
"cwd": "${workspaceRoot}",
"environment": [{
"foo": "bar"
}],
"linux": {
"MIMode": "gdb"
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb"
}
}
}
I'll update the docs to talk more about this.
Yep, I have set CMAKE_MODULE_PATH var before. It's clear now how to set environment variables. Thanks!
Ah, ok. Instead of using set to add things to CMAKE_MODULE_PATH, use this:
list(APPEND CMAKE_MODULE_PATH "SomeDirectoryHere")
Replacing SomeDirectoryHere with what you want to add to the path.
I'll add a note to the docs about this.
I have successfully launched app! Thanks! Is it possible to associate keys for launching debugger?
Yes, just add a keybinding for the cmake.debugTarget command
For some reason, whenever I add the include(CMakeToolsHelpers OPTIONAL) call, I will often see errors from CMake when generating build files through vscode:
CMake Error in CMakeLists.txt:
Evaluation file to be written multiple times for different configurations
or languages with different content:
<full path omitted>/build/CMakeToolsMeta.txt
The error tends to repeat a dozen or so times in the output. Running the build again works fine and I can pick debug targets and debug with impunity, so it's not clear what exactly is wrong here. This happens on a couple of different trees, so it doesn't sound like something specific to one particular build.
FWIW, I'm running CMake 3.6.1 on Windows, target compiler is MSVC 19 (VS 2015), using the Visual Studio 2015 generator.
@nsubtil, I know what causes that. It's because the Visual Studio generators are multi-config generators. I didn't think about the interaction here. Thanks for the heads up, I'll put in a fix!
It works for me, on OS X 10.9.5 / VSCode 1.5.3 / CMake 2.8.3 / CMake Tools 0.6.0
Thanks for this, it's very handy ! Somehow the native launch.jsonmethod did not work initially, but this worked like a charm.
Including CMakeToolsHelper breaks my Qt5 applications build.
In order to access a specific Qt build I have a cache entry "QT_ROOT" this is set as the CMAKE_PREFIX_PATH.
Once I use include(CMakeToolsHelpers OPTIONAL) I get the following error during configuration:
-- Configuring done
CMake Error at build/CMakeTools/CMakeToolsHelpers.cmake:59 (file):
Error evaluating generator expression:
$<TARGET_FILE:Qt5::qmake>
No target "Qt5::qmake"
Call Stack (most recent call first):
CMakeLists.txt:3 (include)
@photex Thanks for the notice. I have a good idea of how to fix that.
Indeed, just taking a quick peek at the module, it seems to be missing the imported check for executables right?
That's correct. I've noticed it doing this before, but it's never actually caused an error... I'll have to add the check to make sure this error doesn't happen. Usually people aren't interested in debugging an imported executable.
This works great! MacOS 10.12.1, VSCode 1.6.1, Cmake 3.6.2
it was working but something happened and now there arent any any available targets for debugging. ive tried everything.
That's no good. Can you find a CMakeToolsMeta.txt file? What is inside it? What have you tried?