Enhancing the CMake Targets View in Visual Studio
The CMake Targets View in Visual Studio is a view that allows you to visualize your CMake project structure by the CMake targets and build specified target libraries and executables. To make this view more usable, we have implemented a few new improvements to make it easier than ever to navigate your CMake targets. This includes improved navigation to the CMake Targets View, a new, more simplified CMake Targets View, and the ability to exclude specified CMake items from the Targets View. Additionally, we have future planned work in the near-term to allow users to customize this view to their desired configuration. Download the latest preview version of Visual Studio to try out the new updates for the CMake Targets View.
Get to your CMake Targets View Quicker Than Ever
Customers have reported that it can be cumbersome to switch between CMake Targets View and the Solution Explorer. To address this, we have implemented new entry points to open the CMake Targets View much more quickly.
Switch to your CMake Targets View from Solution Explorer
Now, you can right-click anywhere in your Solution Explorer and simply navigate to the CMake Targets View from the context menu.
Open the CMake Targets View from the ‘View’ Dropdown Menu
You can also access the CMake Targets View globally at any point in your CMake projects by selecting from the View dropdown.
Simplify your Source Navigation
The CMake Targets View has been further simplified so that users don’t have to click through folders without buildable executables to get to their desired target.
Define Items to Exclude from View
You can now define in your VSWorkspaceSettings.json items to exclude from the CMake Targets View using the new
CMakeTargetsViewExcludedItems field. The
CMakeTargetsViewExcludedItems field is an array of strings. The field supports the following syntax and identifiers:
Syntax for the
CMakeTargetsViewExcludedItems is the following:
This will specify any identifier with the specified name.
- For example,
CMakeTarget:app. Any CMake targets with the name “app” anywhere in the CMake Targets View will be excluded.
Additionally, if you want to specify specific items to be excluded, you can use a
- to chain declarations together:
- For example,
Example usage in a VSWorkspaceSettings.json:
-CMakeFile:*", "CMakeTarget -*-CMakeFile:*", "CMakeTarget: -*-*-CMakeFile:*"
What’s Coming Next?
We are continuing to develop the CMake Targets View to allow for further customization of this view based on customer feedback. Stay tuned for the latest updates as these ship in the future!
- We are planning to give users the ability to filter their CMake Targets view by type of target, project, etc.
- Users will be able to dynamically pin and unpin their most used targets to the top of the CMake Targets View.
We are using this suggestion ticket to track any other requests you may have for improvements to the CMake Targets View to meet your CMake needs: CMake Targets View Suggestions – Developer Community (visualstudio.com)