vscode-cmake-tools
vscode-cmake-tools copied to clipboard
[FR] Build->Install->Debug from Install directory
[FEATURE REQUEST]
Implement Debug from Install directory similar to what Visual Studio's feature.
We should be able to select which install target to run and debug and hide targets we don't want to see.
Is it possible to debug from the install directory? And even better to configure the tools to build, install and launch the debugger from the install directory/target?
To be able to debug/run an executable from an install location is very useful.
The extension does not support this, and I don't think it is possible to support this. CMake does not provide information about where an executable is/will be installed, so CMake Tools would have no way of knowing the path to an executable.
The best you can do is create an entry in launch.json
that runs the installed executable. Sorry.
VS2017 15.8 supports debugging from the install directory without any extra configuration steps. How do they do it I have no idea but it works great. VS2017 can do all of this in one step: it builds, installs and runs the executable in the debugger.
A use case for this is to copy the built DLLs, executable into a directory containing assets and run the executable from there. This significantly simplifies the workflow.
# Set installation path
set (InstallationPath ${CMAKE_INSTALL_PREFIX})
if (option_ENGINE_LIBRARY_AS_SHARED)
# Install targets
install (
TARGETS
${PROJECT_NAME}
RUNTIME DESTINATION
${InstallationPath}
)
endif ()
# Install required files
install (
FILES
${SharedLibraries}
DESTINATION
${InstallationPath}
)
CMAKE_INSTALL_PREFIX
can be set from the command line? And the extension knows the name of the executable? So the extension could debug the executable located in CMAKE_INSTALL_PREFIX
which is set manually. I guess Visual Studio 2017 is doing like that as the install directory is set in the CMakeSettings.json
.
For example like that: "installRoot": "${workspaceRoot}\\..\\__install-output\\${name}",
If we already have:
installDir
get installDir(): string | null
Inherited from CMakeDriver.installDir
Defined in driver.ts:396
Directory where the targets will be installed.
Returns string | null
We also know the executable targets and we also have an action to install all targets. So it should be fairly easy to execute a selected target.
targets
get targets(): RichTarget[]
Overrides CMakeDriver.targets
Defined in cms-driver.ts:153
Returns RichTarget[]
If one wants to add such functionality where is the entry point? For example: // Resolved by CMake Tools: "program": "${command:cmake.launchTargetPath}", But this doesn't work: "preLaunchTask": "command:cmake.install",
The best you can do is create an entry in launch.json that runs the installed executable. Sorry.
@vector-of-bool I have configured launch.json to point to the installed location, but it is necessary to manually change launch entry if one change the current target (Release or Debug in my case)
Is it somehow possible to link the current target to an entry in the launch.json
?
Or have substitution like follow would work in my case
{
"program": "${workspaceFolder}/install/${buildType}-${buildKit}/MyExe.exe",
}
Is it something like this feasible?
@bobbrow Has anything been done in that area (debugging from an install directory)? I'd like to have the same functionality as it is in VS2019: I can select an install target from a drop-down menu and just debug it without any special configurations. Would that be difficult to implement in the next release?
It won't be in 1.2.0, but I'll put it "on deck" for investigation.
Have not see this feature on Oct 22 2020.
@joshion, that is correct. This feature has not been assigned a release milestone yet. Please add a 👍 reaction to the first comment if this feature is important to you. That helps us prioritize which features are implemented first. We would also accept a PR from the community if someone is interested in working on this before we have a chance to get to it.
@bobbrow With presets now supported, this is the last big feature missing to have feature parity with Visual Studio 2019. Will you consider accepting it for 1.9? I think it is too big and important to be left to somebody to do on the side.
@bobbrow With presets now supported, this is the last big feature missing to have feature parity with Visual Studio 2019. Will you consider accepting it for 1.9? I think it is too big and important to be left to somebody to do on the side.
Agree with that.
@bobbrow I'd like to make a gentle reminder about this feature request. Is there any chance of this being worked on any time soon? This feature, including the other suggested improvements to the project outliner (one of which would be including the install targets, etc.).
@Zingam sorry we haven't made any progress on this one. I don't anticipate us working on this in the next few months. As of this writing it's number 13 on the list of issues sorted by 👍 reactions. We don't always do things in exact priority order, but it's far enough down the list that we aren't tracking it yet.
@benmcmorran Thank you for planning this feature. I hope to see a preview soon.
I think install and debug support https://github.com/microsoft/vscode-cmake-tools/issues/532 and cpptools support for debug as root
https://github.com/microsoft/vscode-cpptools/issues/3155 will make developing daemons so much easier.