Skip to content

Add cmake.exclude setting to allow for multi-root scenarios to ignore certain folders #4440

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

Merged
merged 17 commits into from
May 5, 2025

Conversation

gcampbell-msft
Copy link
Collaborator

@gcampbell-msft gcampbell-msft commented Apr 29, 2025

Add cmake.exclude setting to allow for users to, in both the User and Workspace vscode settings, specifically ignore folders in a multi-root scenario that they don't want the CMake Tools extension to acknowledge.

Fixes #1069.
Fixes #4112.

We believe that this solves the issues that users had mentioned in #4112 and associated bugs, because it allows users to specifically ignore folders that they don't want acknowledged. There are two main scenarios that this could happen.

  1. "True" multi-root. This is a scenario where a user opens a workspace file that has multiple folders opened. In this case, users can utilize the cmake.exclude setting to ignore certain folders.
  2. Multiple sub-folders multi-root. This is a scenario where a user opens a single workspace folder, but they have nested subfolders (either CMake or non-CMake). The first time this is opened, CMake Tools will ask if you want to configure the project, and if so, you will be prompted to select a folder. This folder will then be set as the cmake.sourceDirectory. In this case, users can be selective in their cmake.sourceDirectory setting, and by omitting any folders they don't want handled by CMake Tools, they can effectively be ignored.

This may still hit, in a "True" multi-root scenario, a pop-up asking you if you want to configure with CMake Tools in a non-CMake folder, but you can use this feature to ignore it after this.

@gcampbell-msft gcampbell-msft changed the title Dev/gcampbell/multi root improvements Add cmake.ignoredFolders setting to allow for multi-root scenarios to ignore certain folders Apr 29, 2025
@gcampbell-msft gcampbell-msft marked this pull request as ready for review April 29, 2025 14:50
@gcampbell-msft
Copy link
Collaborator Author

@danniesim I'd appreciate your review and feedback, as you've worked and helped post issues in this space. You can either test with this locally, or you could use this .vsix.
cmake-tools.zip
Reminder: You'll need to download the file and modify the file extension to be .vsix.

@gcampbell-msft gcampbell-msft changed the title Add cmake.ignoredFolders setting to allow for multi-root scenarios to ignore certain folders Add cmake.exclude setting to allow for multi-root scenarios to ignore certain folders Apr 29, 2025
@gcampbell-msft
Copy link
Collaborator Author

TODO: Investigate and confirm that default active folder is handled correctly and the active folder selection, related settings: cmake.autoSelectActiveFolder, cmake.defaultActiveFolder

paulmaybee
paulmaybee previously approved these changes Apr 29, 2025
@danniesim
Copy link
Contributor

@danniesim I'd appreciate your review and feedback, as you've worked and helped post issues in this space. You can either test with this locally, or you could use this .vsix. cmake-tools.zip Reminder: You'll need to download the file and modify the file extension to be .vsix.

Will do. Thanks!

paulmaybee
paulmaybee previously approved these changes Apr 30, 2025
@gcampbell-msft
Copy link
Collaborator Author

@danniesim I've made a couple of updates, so it'd be better to test locally rather than the previously uploaded vsix, just FYI. Thanks!

@gcampbell-msft
Copy link
Collaborator Author

@danniesim I've gotten approval from some team members, so please keep me in the loop with any testing you do. I'd love to merge this PR this week or next. I understand you likely have many other things taking your attention, so no worries, I just wanted to check with you since you've helped contribute to this area. Thanks!

@gcampbell-msft gcampbell-msft merged commit a1ceda2 into main May 5, 2025
4 of 6 checks passed
@gcampbell-msft gcampbell-msft deleted the dev/gcampbell/MultiRootImprovements branch May 5, 2025 18:09
@danniesim
Copy link
Contributor

@gcampbell-msft It works, nice one, and thanks to all contributors. However, absolute paths are not great. Paths relative to the workspace file would be better as it would be portable to anywhere/path/machine the repo is cloned to. See screenshot for how it works on my workspace:
Screenshot 2025-05-06 at 10 18 24

@gcampbell-msft
Copy link
Collaborator Author

@danniesim Thanks for the feedback! I did consider this, but for the initial MVP I wanted to make sure we didn't introduce confusion, and relative paths introduce difficulties if people set this at the user level. However, we are more than willing to consider this, please create a feature request and we'll do our best to prioritize it accordingly. Thanks!

@danniesim
Copy link
Contributor

@gcampbell-msft Perhaps something like this "${workspaceFolder}/project_folder" (The Python extension supports this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve multi-root CMake detection Ignore some root folders in a multi-root workspace
4 participants