question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multi-target debug cwd configuration

See original GitHub issue

My workspace is structured like so:

${workspaceFolder}
  |----- CMakeLists.txt 
  |
  |----- build/
  |
  |----- projects/
             |----- projectA/
             |        |----- src/
             |        |----- out/
             |        |----- resources/ 
             |        |----- CMakeLists.txt 
             |
            ... (3 more identically structured projects)

When debugging, I want CMake Tools to set the cwd to each project’s out directory because I distribute the files from resources/ to out/ and access them using relative paths.
The cwd is currently set to ${workspaceFolder} which means none of the resources are found.

I have tried putting this in each project’s CMakeLists.txt but it did not work

set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

Any suggestions?

Edit: ${CMAKE_BINARY_DIR} is set to ${PROJECT_SOURCE_DIR}/out in each project’s CMake Lists.txt

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
bobbrowcommented, Mar 2, 2020

We can mark this as a feature request. In the meantime, you can use the cmake.debugConfig object to override certain debugger settings like “cwd” (current working directory).

cmake.debugConfig: {
    "cwd": "${workspaceFolder}/projects/projectA/out"
}

This is not ideal for a project with multiple targets since you’ll have to change the cwd each time you change debug targets, but it can get you by until the feature is implemented.

1reaction
LeLuc4commented, Jun 23, 2020

We can mark this as a feature request. In the meantime, you can use the cmake.debugConfig object to override certain debugger settings like “cwd” (current working directory).

cmake.debugConfig: {
    "cwd": "${workspaceFolder}/projects/projectA/out"
}

This is not ideal for a project with multiple targets since you’ll have to change the cwd each time you change debug targets, but it can get you by until the feature is implemented.

You can use the following in your settings.json without having to modify the cwd each time:

 "cmake.debugConfig": {
        "cwd": "${command:cmake.launchTargetDirectory}"
    },

However, this does not work for non-debug launches. Any ideas?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging in Visual Studio Code
In order to start a debug session, first select the configuration named Launch Program using the Configuration dropdown in the Run and Debug...
Read more >
Setting up multi-target (compound) debugging in VS Code
Debug your renderer process. Configure VS Code to debug both processes at the same time using multi-target (compound) debugging!
Read more >
How to seamlessly multi target Electron debug with VSCode ...
I suggest to change the value of the "protocol" attribute in the top most debug configuration to "legacy" (assuming that the protocol is...
Read more >
Debug both javascript and c# in ASP.NET Core MVC using VS ...
VS Code will automatically start multi-target debugging. You will want to start an "attach to chrome" session (see below for configuration ...
Read more >
Debug ASP.NET Core Blazor WebAssembly - Microsoft Learn
Start Without Debugging [ Ctrl + F5 (Windows) or ⌘ + F5 (macOS)] isn't supported. When the app is run in Debug configuration,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found