{"id":32833,"date":"2023-09-20T17:28:56","date_gmt":"2023-09-20T17:28:56","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cppblog\/?p=32833"},"modified":"2023-10-31T23:02:18","modified_gmt":"2023-10-31T23:02:18","slug":"enhancing-the-cmake-targets-view-in-visual-studio","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/enhancing-the-cmake-targets-view-in-visual-studio\/","title":{"rendered":"Enhancing the CMake Targets View in Visual Studio"},"content":{"rendered":"<p>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. <a href=\"https:\/\/visualstudio.microsoft.com\/vs\/preview\/\" target=\"_blank\" rel=\"noopener\">Download the latest preview version of Visual Studio<\/a> to try out the new updates for the CMake Targets View.<\/p>\n<h3>Get to your CMake Targets View Quicker Than Ever<\/h3>\n<p>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.<\/p>\n<h5><em>Switch to your CMake Targets View from Solution Explorer<\/em><\/h5>\n<p>Now, you can right-click anywhere in your Solution Explorer and simply navigate to the CMake Targets View from the context menu.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/09\/Switch-to-CMake-Targets-View.png\"><img decoding=\"async\" class=\"size-full wp-image-32834 aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/09\/Switch-to-CMake-Targets-View.png\" alt=\"Right-Click Context Menu to Switch To CMake Targets View\" width=\"1008\" height=\"900\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/09\/Switch-to-CMake-Targets-View.png 1008w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/09\/Switch-to-CMake-Targets-View-300x268.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/09\/Switch-to-CMake-Targets-View-768x686.png 768w\" sizes=\"(max-width: 1008px) 100vw, 1008px\" \/><\/a><\/p>\n<h5><em>Open the CMake Targets View from the &#8216;View&#8217; Dropdown Menu<\/em><\/h5>\n<p>You can also access the CMake Targets View globally at any point in your CMake projects by selecting from the View dropdown.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/09\/cmake-targets-dropdown.png\"><img decoding=\"async\" class=\"size-large wp-image-32836 aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/09\/cmake-targets-dropdown-361x1024.png\" alt=\"The CMake Targets View option in the View dropdown in Visual Studio\" width=\"361\" height=\"1024\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/09\/cmake-targets-dropdown-361x1024.png 361w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/09\/cmake-targets-dropdown-106x300.png 106w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/09\/cmake-targets-dropdown.png 390w\" sizes=\"(max-width: 361px) 100vw, 361px\" \/><\/a><\/p>\n<h3>Simplify your Source Navigation<\/h3>\n<p>The CMake Targets View has been further simplified so that users don&#8217;t have to click through folders without buildable executables to get to their desired target.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/09\/Simplified-CMake-Targets-View-1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-32838\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/09\/Simplified-CMake-Targets-View-1.png\" alt=\"Simplified CMake Targets View navigation\" width=\"858\" height=\"991\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/09\/Simplified-CMake-Targets-View-1.png 858w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/09\/Simplified-CMake-Targets-View-1-260x300.png 260w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/09\/Simplified-CMake-Targets-View-1-768x887.png 768w\" sizes=\"(max-width: 858px) 100vw, 858px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3>Define Items to Exclude from View<\/h3>\n<p>You can now define in your VSWorkspaceSettings.json items to exclude from the CMake Targets View using the new <code>CMakeTargetsViewExcludedItems<\/code> field. The\u00a0<code>CMakeTargetsViewExcludedItems<\/code> field is an array of strings. The field supports the following syntax and identifiers:<\/p>\n<p><span style=\"text-decoration: underline;\">Supported &#8220;identifiers&#8221;<\/span><strong>:<\/strong><code> CMakeProject<\/code>,\u00a0<code>CMakeTarget<\/code>,\u00a0<code>CMakeReference<\/code>,<code>\u00a0CMakeFolder<\/code>,\u00a0<code>CMakeFile<\/code>.<\/p>\n<p><span style=\"text-decoration: underline;\">Syntax for the <code>CMakeTargetsViewExcludedItems<\/code>\u00a0is the following<\/span>: <code>&lt;identifier&gt;:&lt;name&gt;<\/code><\/p>\n<p><code><\/code><code><\/code><code><\/code><code><\/code>This will specify any identifier with the specified name.<\/p>\n<ul>\n<li>For example,\u00a0<code>CMakeTarget:app<\/code>. Any CMake targets with the name &#8220;app&#8221; anywhere in the CMake Targets View will be excluded.<\/li>\n<\/ul>\n<p>Additionally, if you want to specify specific items to be excluded, you can use a<code> |\u00a0<\/code>to chain declarations together:<code>&lt;identifier&gt;:&lt;name&gt;|&lt;identifier&gt;:&lt;name&gt;...<\/code><\/p>\n<ul>\n<li>For example,\u00a0<code>CMakeProject:thirdPartyDependency|CMakeTarget:irrelevantThirdParty<\/code>.<\/li>\n<\/ul>\n<p>Example usage in a VSWorkspaceSettings.json:<\/p>\n<pre><code><span class=\"TextRun SCXW140431815 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun ContextualSpellingAndGrammarErrorV2Themed SCXW140431815 BCX8\" data-ccp-charstyle=\"pun\" data-ccp-charstyle-defn=\"{&quot;ObjectId&quot;:&quot;be55c42b-bb3f-490a-a548-6141e9a8ee43|72&quot;,&quot;ClassId&quot;:1073872969,&quot;Properties&quot;:[469775450,&quot;pun&quot;,201340122,&quot;1&quot;,469778129,&quot;pun&quot;,335572020,&quot;1&quot;,134234073,&quot;true&quot;,134234074,&quot;true&quot;,134233614,&quot;true&quot;,469778324,&quot;Default Paragraph Font&quot;]}\">{<\/span><\/span> <span class=\"TextRun SCXW140431815 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun ContextualSpellingAndGrammarErrorV2Themed SCXW140431815 BCX8\" data-ccp-charstyle=\"pln\">\u202f<\/span> <\/span><span class=\"TextRun SCXW140431815 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\" data-ccp-charstyle-defn=\"{&quot;ObjectId&quot;:&quot;be55c42b-bb3f-490a-a548-6141e9a8ee43|75&quot;,&quot;ClassId&quot;:1073872969,&quot;Properties&quot;:[469775450,&quot;str&quot;,201340122,&quot;1&quot;,469778129,&quot;str&quot;,335572020,&quot;1&quot;,134234073,&quot;true&quot;,134234074,&quot;true&quot;,134233614,&quot;true&quot;,469778324,&quot;Default Paragraph Font&quot;]}\">\"<\/span><span class=\"NormalTextRun SpellingErrorV2Themed SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">CMakeTargetsViewExcludedItems<\/span><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">\"<\/span><\/span><span class=\"TextRun SCXW140431815 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"pun\">:<\/span><\/span> <span class=\"TextRun SCXW140431815 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"pun\">[<\/span><\/span> <span class=\"TextRun SCXW140431815 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"pln\">\u202f\u202f\u202f <\/span><\/span><span class=\"TextRun SCXW140431815 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">\"<\/span><span class=\"NormalTextRun SpellingErrorV2Themed SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">CMakeTarget<\/span><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">:&lt;name&gt;<\/span><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">|<\/span><span class=\"NormalTextRun SpellingErrorV2Themed SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">CMakeFile<\/span><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">:*\"<\/span><\/span><span class=\"TextRun SCXW140431815 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"pun\">,<\/span><\/span> <span class=\"TextRun SCXW140431815 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">\"<\/span><span class=\"NormalTextRun SpellingErrorV2Themed SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">CMakeTarget<\/span><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">&lt;name&gt;<\/span><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">|<\/span><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">*<\/span><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">|<\/span><span class=\"NormalTextRun SpellingErrorV2Themed SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">CMakeFile<\/span><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">:*\"<\/span><\/span><span class=\"TextRun SCXW140431815 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"pun\">,<\/span><\/span> <span class=\"TextRun SCXW140431815 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">\"<\/span><span class=\"NormalTextRun SpellingErrorV2Themed SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">CMakeTarget<\/span><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">:&lt;name&gt;<\/span><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">|<\/span><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">*<\/span><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">|<\/span><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">*<\/span><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">|<\/span><span class=\"NormalTextRun SpellingErrorV2Themed SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">CMakeFile<\/span><span class=\"NormalTextRun SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">:*<\/span><span class=\"NormalTextRun ContextualSpellingAndGrammarErrorV2Themed SCXW140431815 BCX8\" data-ccp-charstyle=\"str\">\"<\/span><\/span>\u00a0}<\/code><\/pre>\n<h3>What\u2019s Coming Next?<\/h3>\n<p>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!<\/p>\n<ol>\n<li>We are planning to give users the ability to filter their CMake Targets view by type of target, project, etc.<\/li>\n<li>Users will be able to dynamically pin and unpin their most used targets to the top of the CMake Targets View.<\/li>\n<\/ol>\n<p>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: <a href=\"https:\/\/developercommunity.visualstudio.com\/t\/CMake-Targets-View-Suggestions\/10471305\">CMake Targets View Suggestions &#8211; Developer Community (visualstudio.com)<\/a><\/p>\n<h3>Anything else?<\/h3>\n<p>You can also find us on Twitter (<a href=\"https:\/\/twitter.com\/visualc\" target=\"_blank\" rel=\"noopener\">@VisualC<\/a>) or via email at\u00a0<a href=\"mailto:visualcpp@microsoft.com\">visualcpp@microsoft.com<\/a>. To open a bug, please see\u00a0<a href=\"https:\/\/developercommunity.visualstudio.com\/report?space=8&amp;entry=problem\" target=\"_blank\" rel=\"noopener\">Visual Studio Feedback<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":85413,"featured_media":32838,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,266],"tags":[],"class_list":["post-32833","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus","category-cmake"],"acf":[],"blog_post_summary":"<p>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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/32833","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/85413"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=32833"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/32833\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/32838"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=32833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=32833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=32833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}