{"id":19305,"date":"2018-05-02T03:00:36","date_gmt":"2018-05-02T10:00:36","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/?p=19305"},"modified":"2019-02-18T17:47:56","modified_gmt":"2019-02-18T17:47:56","slug":"cmake-support-in-visual-studio-code-analysis-and-cmake-3-11","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/cmake-support-in-visual-studio-code-analysis-and-cmake-3-11\/","title":{"rendered":"CMake Support in Visual Studio \u2013 Code Analysis and CMake 3.11"},"content":{"rendered":"<p><a href=\"https:\/\/www.visualstudio.com\/vs\/preview\/\">Visual Studio 2017 15.7 Preview 4<\/a> is now available and we have added a few more CMake features in addition to the <a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2018\/04\/09\/cmake-support-in-visual-studio-targets-view-single-file-compilation-and-cache-generation-settings\/\">Targets View and single file compilation<\/a> added in Preview 3.\u00a0 We keep the version of CMake that ships with Visual Studio as fresh as possible, so we have updated it to version 3.11.\u00a0 We are also excited to announce that CMake projects now support the IDE\u2019s code analysis features that previously required a VCXProj to take advantage of.<\/p>\n<p>Please download the preview and check out the latest CMake features such as the Targets View, single file compilation, and more control over when projects are configured.\u00a0 As always, we would love to hear your feedback too.<\/p>\n<p><em>If you are new to CMake in Visual Studio, check out <\/em><a href=\"https:\/\/aka.ms\/cmake\"><em>how to get started<\/em><\/a><em>.<\/em><\/p>\n<h3>Code Analysis for CMake Projects<\/h3>\n<p>In the latest preview, you can now run Visual Studio\u2019s <a href=\"https:\/\/docs.microsoft.com\/en-us\/visualstudio\/code-quality\/code-analysis-for-c-cpp-overview\">comprehensive code analysis tools<\/a> on CMake projects.\u00a0 Currently, you can run code analysis at the target level.\u00a0 Options to run code analysis for single files or your entire project are coming soon.<\/p>\n<p>To run code analysis on a CMake target you can select \u201cRun Code Analysis\u201d from the CMake menu:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/CMake-Menu-Code-Analysis.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/CMake-Menu-Code-Analysis.png\" alt=\"CMake Menu Code Analysis\" class=\"size-full wp-image-19315 aligncenter\" width=\"243\" height=\"275\" \/><\/a><\/p>\n<p>Or, if you are using the <a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2018\/04\/09\/cmake-support-in-visual-studio-targets-view-single-file-compilation-and-cache-generation-settings\/\">Targets View<\/a> you can simply right click on any target and select \u201cRun Code Analysis:\u201d<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/Targets-View-Code-Analysis.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/Targets-View-Code-Analysis.png\" alt=\"Targets View Code Analysis\" class=\"size-full wp-image-19325 aligncenter\" width=\"526\" height=\"527\" \/><\/a><\/p>\n<p>Any analysis errors or warnings that are detected will appear in the Output Window:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/Code-Analysis-Output.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/Code-Analysis-Output.png\" alt=\"Code Analysis Output Window\" class=\"size-full wp-image-19335 aligncenter\" width=\"1181\" height=\"336\" \/><\/a><\/p>\n<p>By default CMake projects use the \u201cMicrosoft Native Recommended Rules\u201d <a href=\"https:\/\/docs.microsoft.com\/en-us\/visualstudio\/code-quality\/how-to-set-code-analysis-properties-for-c-cpp-projects\">rule set<\/a>, but you can change this by modifying your CMakeSettings.json file.\u00a0 Just add the <strong>&#8220;codeAnalysisRuleset&#8221;<\/strong> tag to your configuration with the name or path to a rule set file.<\/p>\n<h3>CMake 3.11<\/h3>\n<p>To ensure that your projects can take advantage of the latest and greatest CMake features we have upgraded the version of CMake that ships with Visual Studio from 3.10 to 3.11.\u00a0 You can find the full lists of enhancements to CMake 3.11 in the <a href=\"https:\/\/cmake.org\/cmake\/help\/v3.11\/release\/3.11.html\">CMake 3.11 release notes<\/a>.<\/p>\n<h3>Send Us Feedback<\/h3>\n<p>Your feedback is a critical part of ensuring that we can deliver the best CMake experience.\u00a0 We would love to know how <a href=\"https:\/\/www.visualstudio.com\/vs\/preview\/\">Visual Studio 2017 Preview<\/a> is working for you.\u00a0 If you have any feedback specific to CMake Tools, please reach out to <a href=\"mailto:cmake@microsoft.com\">cmake@microsoft.com<\/a>.\u00a0 For general issues please <a href=\"https:\/\/docs.microsoft.com\/en-us\/visualstudio\/ide\/how-to-report-a-problem-with-visual-studio-2017\">Report a Problem<\/a><span>.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Visual Studio 2017 15.7 Preview 4 is now available and we have added a few more CMake features in addition to the Targets View and single file compilation added in Preview 3.\u00a0 We keep the version of CMake that ships with Visual Studio as fresh as possible, so we have updated it to version 3.11.\u00a0 [&hellip;]<\/p>\n","protected":false},"author":326,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[266],"tags":[8,140,252,233,6,268],"class_list":["post-19305","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cmake","tag-announcement","tag-c","tag-cmake","tag-cross-platform","tag-ide","tag-openfolder"],"acf":[],"blog_post_summary":"<p>Visual Studio 2017 15.7 Preview 4 is now available and we have added a few more CMake features in addition to the Targets View and single file compilation added in Preview 3.\u00a0 We keep the version of CMake that ships with Visual Studio as fresh as possible, so we have updated it to version 3.11.\u00a0 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/19305","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\/326"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=19305"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/19305\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=19305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=19305"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=19305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}