microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.46k stars 452 forks source link

Set default active workspace in workspace settings #1078

Open giantmustache opened 4 years ago

giantmustache commented 4 years ago

Brief Issue Summary

I have a workspace file that contains 3 folders, only one of them is a cmake project the second one is a cmake folder that gets included as external. autoSelectActiveFolder doesn't help me here since it might be that I don't have any file open at the moment that I open vs code and press the build button.

Expected:

I would like to see that I can set the default active folder in my project, so that I know that pressing build will actually build the default project.

Apparent Behavior:

Depending on what cmake tools chooses, it might be that I get an error, because it cannot find a CMakeLists.txt or it find one in another folder, which is actually an external folder and therefore it is not a root CMakeLists.txt. You get an error that it cannot find project() for example. I just don't want this project to build at all.

Platform and Versions

bobbrow commented 4 years ago

Am I understanding correctly that you only want one of the folders to build?

If you set autoSelectActiveFolder to false and then pick "main_project" as the active folder (click on the status bar item or run the "select active folder" command), does that work for you?

giantmustache commented 4 years ago

Yes I am trying to build only one folder. I have set autoSelectActiveFolder to false and that works. It builds fine.

But when someone opens the project for the first time, that folder is not guaranteed to be the selected folder by default. Therefore I need to tell all my colleagues or document in the setup steps, that they need to set the active folder correctly when they start up the project for the first time. This is prone to errors and I would rather see that someone opens the workspace file and can start working directly from there. I think it would be best if the workspace settings can have an option where we put the active folder to build.

bobbrow commented 4 years ago

That's fair. I'll change this into a feature request. I don't think we'd want to add a setting for the current active folder, but rather the default active folder when no other folder is set as active.

pkral78 commented 4 years ago

Using multi root project should not mean, that all folders automatically contains standalone top level projects. CMakeLists.txt in these folders can be included using add(...) directive from "main" project folder CMakeLists.txt and are not means to be configured as self-contained.

There should be option to exclude configuration of that folders.

mischelebuha commented 2 years ago

I am struggling with the same problem as @giantmustache . Every time I reopen vs code and a file from another folder was previously opened, this folder is automatically set as the active folder. And the build will fail.

bobbrow commented 2 years ago

@mischelebuha does setting autoSelectActiveFolder to false and then having you manually select the active folder in the status bar not remember the correct folder for you the next time you open VS Code?

Mrkol commented 2 years ago

Any progress on this one? I'm using multiroot workspaces for students' homework setup: main root is the course repo that contains tests and cmake files, another one is a student's repository that only contains headers. I want this setup to be as error prone as possible so that no one gets confused or stuck due to a wrong active folder

JoJossd commented 1 year ago

@mischelebuha does setting autoSelectActiveFolder to false and then having you manually select the active folder in the status bar not remember the correct folder for you the next time you open VS Code?

No it doesn't.

arthur-flam commented 1 year ago

Hi everyone, Not remembering the previous setting is frustrating. Users need to reselect the active project every time they open or reload vscode. Even being able to set the default as part of the settings (like suggested in this issue) would be helpful.

I got a sense of what needs to be changed searching for autoSelectActiveFolder and ActiveFolder. If I find time I'll try to submit a PR.

Thanks a lot for your work,

sanore commented 5 months ago

Hi all, I have exact the same use case and it's really annoying to select the correct project on each start.

I've opened a Pull Request and hope this fixes your use case too. #3730 @gcampbell-msft Maybe you can have a look or assign somewhere to review my changes. Would be great to see this in a next release