Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-target debug cwd configuration #1101

Open
j-m opened this issue Feb 29, 2020 · 7 comments
Open

Multi-target debug cwd configuration #1101

j-m opened this issue Feb 29, 2020 · 7 comments
Labels
enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: debug/launch
Milestone

Comments

@j-m
Copy link

j-m commented Feb 29, 2020

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

@bobbrow
Copy link
Member

bobbrow commented 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.

@bobbrow bobbrow added enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: debug/launch labels Mar 2, 2020
@bobbrow bobbrow added this to the Backlog milestone Mar 2, 2020
@geniass
Copy link

geniass commented Apr 2, 2020

@bobbrow any guidance on how/where to do this?
I might be keen to implement it.

I found

this._launchTerminal.sendText(quoted);
in async launchTarget(name?: string)

I suppose we could add a line something like this._launchTerminal.sendText("cd ${workingDirectory"); ?

That would require adding another cmake setting workingDirectory

@bobbrow
Copy link
Member

bobbrow commented Apr 6, 2020

I've been thinking about this and wasn't sure if this was the right approach. It would require a lot of manual target/path setting.

The mechanism that CMake provides to accumulate binaries/resources into a working location is INSTALL and the information should be mostly derivable from CMakeLists.txt, but I've been looking over the INSTALL documentation and it seems it allows for more scenarios than I anticipated. I want to sync with the Visual Studio team that owns the CMake experience and see what their thoughts are about this. I *think* that we could provide a debug selector that will also let you pick one of the paths specified in your INSTALL directive though I'm not sure how reliable the guessing will be since you can INSTALL to multiple locations.

@bobbrow
Copy link
Member

bobbrow commented Apr 8, 2020

Related #771

@LeLuc4
Copy link

LeLuc4 commented 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?

@github-actions
Copy link

This issue is now marked as 'stale-old' due to there being no activity on it for the past 720 days. Unless the 'stale-old' label is removed or the issue is commented on, this will be remain open for at least 14 days and then it may be closed. If you would like to make this issue exempt from getting stale, please add the 'stale-exempt' label.

@github-actions github-actions bot added the stale-old to use with the close-old-issues bot label Oct 19, 2023
@j-m
Copy link
Author

j-m commented Oct 28, 2023

I stopped using CMake in VSCode because of several small pain points like this, but I'd love to come back.
I'll try it again if there's no response in a week, but does anyone know (off-hand) if this issue has been solved?

@github-actions github-actions bot removed the stale-old to use with the close-old-issues bot label Oct 29, 2023
@github-project-automation github-project-automation bot moved this to Triage Needed in CMake Tools Nov 29, 2023
@gcampbell-msft gcampbell-msft moved this from Triage Needed to Pending Prioritization in CMake Tools Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: debug/launch
Projects
Status: Pending Prioritization
Development

No branches or pull requests

4 participants