{"id":25432,"date":"2020-01-24T01:36:21","date_gmt":"2020-01-24T01:36:21","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cppblog\/?p=25432"},"modified":"2020-01-24T01:36:21","modified_gmt":"2020-01-24T01:36:21","slug":"cmake-linux-targeting-and-intellisense-improvements-in-visual-studio-2019-version-16-5-preview-2","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/cmake-linux-targeting-and-intellisense-improvements-in-visual-studio-2019-version-16-5-preview-2\/","title":{"rendered":"CMake, Linux targeting, and IntelliSense improvements in Visual Studio 2019 version 16.5 Preview 2"},"content":{"rendered":"<p>Visual Studio\u2019s <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/build\/cmake-projects-in-visual-studio?view=vs-2019\">native support for CMake<\/a> allows you to target both Windows and Linux from the comfort of a single IDE. <a href=\"https:\/\/visualstudio.microsoft.com\/vs\/preview\/\">Visual Studio 2019 version 16.5 Preview 2<\/a> introduces several new features specific to cross-platform development, including:<\/p>\n<ul>\n<li><a href=\"#fileops\">File copy optimizations for CMake projects targeting a remote Linux system<\/a><\/li>\n<li><a href=\"#wsl\">Native WSL support when separating your build system from your remote deploy system<\/a><\/li>\n<li><a href=\"#cmake\">The ability to easily add, remove, and rename files in CMake projects<\/a><\/li>\n<li><a href=\"#lang\">CMake language services<\/a><\/li>\n<li><a href=\"#command\">A command line utility to interact with the Connection Manager<\/a><\/li>\n<li><a href=\"#fips\">FIPS 140-2 compliance for remote C++ development<\/a><\/li>\n<li><a href=\"#int\">IntelliSense improvements for both CMake projects and MSBuild-based solutions<\/a><\/li>\n<\/ul>\n<h4><span style=\"color: inherit; font-family: inherit; font-size: 14pt;\"><a name=\"fileops\"><\/a><span style=\"font-size: 18pt;\">File copy optimizations for CMake projects targeting a remote Linux system<\/span><\/span><\/h4>\n<p>Visual Studio automatically copies source files from your local Windows machine to your remote Linux system when building and debugging on Linux. In Visual Studio 2019 version 16.5 this behavior has been optimized. Visual Studio now keeps a &#8220;fingerprint file&#8221; of the last set of sources copied remotely and optimizes behavior based on the number of files that have changed.<\/p>\n<ol>\n<li>If no changes are identified, then no copy occurs.<\/li>\n<li>If only a few files have changed, then sftp is used to copy the files individually.<\/li>\n<li>If only a few directories have changed, then a non-recursive rsync command is issued to copy those directories.<\/li>\n<li>Otherwise, a rsync recursive copy is called from the first common parent directory of the changed files.<\/li>\n<\/ol>\n<p>These improvements were tested against <a href=\"https:\/\/github.com\/llvm\/llvm-project\">LLVM<\/a>. A trivial change was made to a source file, which causes the remote source file copy to be called and the executable to be rebuilt when the user starts debugging.<\/p>\n<table style=\"height: 56px;\" border=\"1\">\n<tbody>\n<tr style=\"height: 28px;\">\n<td style=\"width: 28.1837%; height: 28px;\"><\/td>\n<td style=\"width: 27.399%; height: 28px;\"><strong>Debugging LLVM-objdump with no optimizations<\/strong><\/td>\n<td style=\"width: 30.685%; height: 28px;\"><strong>Debugging LLVM-objdump with 16.5 optimizations\u00a0<\/strong><\/td>\n<\/tr>\n<tr style=\"height: 28px;\">\n<td style=\"width: 28.1837%; height: 28px;\"><strong>Time elapsed for remote source file copy<\/strong><\/td>\n<td style=\"width: 27.399%; height: 28px;\">3 minutes and 24 seconds<\/td>\n<td style=\"width: 30.685%; height: 28px;\">2 seconds<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>With no optimizations, a full recursive rsync copy is executed from the CMake root. With these optimizations, Visual Studio detects that a single file has changed and uses sftp to re-copy only the file that has changed.<\/p>\n<p>These optimizations are enabled by default. The following new options can be added to CMakeSettings.json to customize file copy behavior.<\/p>\n<p style=\"margin: 0in; margin-bottom: .0001pt;\"><span style=\"font-family: 'Courier New';\">&#8220;remoteCopyOptimizations&#8221; : {<\/span><\/p>\n<p style=\"margin: 0in 0in .0001pt 27.0pt;\"><span style=\"font-family: 'Courier New';\">&#8220;remoteCopyUseOptmizations&#8221;: \u201cRsyncAndSftp\u201d<\/span><\/p>\n<p style=\"margin: 0in 0in .0001pt 27.0pt;\"><span style=\"font-family: 'Courier New';\">&#8220;rsyncSingleDirectoryCommandArgs&#8221;: &#8220;-t&#8221;<\/span><\/p>\n<p style=\"margin: 0in; margin-bottom: .0001pt;\"><span style=\"font-family: 'Courier New';\">}<\/span><\/p>\n<p>Possible values for <span style=\"font-family: 'Courier New';\">remoteCopyOptimizations<\/span> are <span style=\"font-family: 'Courier New';\">RsyncAndSftp<\/span> (default), <span style=\"font-family: 'Courier New';\">RsyncOnly<\/span>, and <span style=\"font-family: 'Courier New';\">None<\/span> (where a full recursive rsync copy is always executed from the CMake root). <span style=\"font-family: 'Courier New';\">rsyncSingleDirectoryCommandArgs<\/span> can be passed to customize rsync behavior when a non-recursive rsync command is issued (step 3 above). The existing properties <span style=\"font-family: 'Courier New';\">remoteCopySources<\/span>, <span style=\"font-family: 'Courier New';\">rsyncCommandArgs <\/span>(which are passed when a recursive rsync command is issued, step 4 above) and <span style=\"font-family: 'Courier New';\">rsyncCopySourcesMethod <\/span>can also be used to customize file copy behavior. Please see <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/build\/cmakesettings-reference?view=vs-2019#additional-settings-for-cmake-linux-projects\">Additional settings for CMake Linux projects<\/a> for more information.<\/p>\n<p>Note that these performance improvements are specific to remote connections. Visual Studio\u2019s <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/c-with-visual-studio-2019-and-windows-subsystem-for-linux-wsl\/\">native support for WSL<\/a> can access files stored in the Windows filesystem, which eliminates the need to copy and maintain sources on a remote machine.<\/p>\n<h4><a name=\"wsl\"><\/a><span style=\"font-size: 18pt;\">Native WSL support with the separation of build and deploy<\/span><\/h4>\n<p>Visual Studio 2019 version 16.1 introduced the ability to separate your remote build system from your remote deploy system. In Visual Studio 2019 version 16.5 this functionality has been extended to include our <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/c-with-visual-studio-2019-and-windows-subsystem-for-linux-wsl\/\">native support for WSL<\/a>. Now, you can build natively on WSL and deploy\/debug on a second remote Linux system connected over SSH.<\/p>\n<h5><span style=\"font-size: 14pt;\">Separation of build and deploy with CMake projects<\/span><\/h5>\n<p>The Linux system specified in the <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/build\/customize-cmake-settings?view=vs-2019\">CMake Settings Editor<\/a> is used for build. To build natively on WSL, navigate to the CMake Settings Editor (Configuration drop-down &gt; Manage Configurations\u2026) and add a new WSL configuration. You can select either <strong>WSL-GCC-Debug<\/strong> or <strong>WSL-Clang-Debug<\/strong> depending on which toolset you would like to use.<\/p>\n<p>The remote Linux system specified in <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/build\/configure-cmake-debugging-sessions?view=vs-2019\">launch.vs.json<\/a> is used for debugging. To debug on a second remote Linux system, add a new remote Linux configuration to launch.vs.json (right-click on the root CMakeLists.txt in the Solution Explorer &gt; Debug and Launch Settings) and select <strong>C\/C++ Attach for Linux (gdb). <\/strong>Please see <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/build\/configure-cmake-debugging-sessions?view=vs-2019#launchvsjson-reference-for-remote-linux-projects\">launch.vs.json reference for remote Linux projects<\/a> to learn more about customizing this configuration and properties specific to the separation of build and deploy.<\/p>\n<p>Note that the C\/C++ Attach for Linux (gdb) configuration is for debugging on remote Linux systems. If you want to build and debug on the same instance of WSL, add a <strong>C\/C++ Launch for WSL<\/strong> configuration to launch.vs.json. More information on the <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/build\/configure-cmake-debugging-sessions?view=vs-2019#customize-debugger-settings\">entry points to launch.vs.json can be found here<\/a>.<\/p>\n<h5><span style=\"font-size: 14pt;\">Separation of build and deploy with MSBuild-based Linux projects<\/span><\/h5>\n<p>The Linux system specified in the Linux <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/linux\/prop-pages\/general-linux?view=vs-2019\">Property Pages<\/a> is used for build. To build natively on WSL, navigate to Configuration Properties &gt; General and set the <strong>Platform Toolset<\/strong>. You can select either <strong>GCC for Windows Subsystem for Linux <\/strong>or <strong>Clang for Windows Subsystem for Linux <\/strong>depending on which toolset you would like to use. Click \u201cApply.\u201d<\/p>\n<p>By default, Visual Studio builds and debugs in WSL. To specify a second remote system for debugging, navigate to Configuration Properties &gt; Debugging and set <strong>Remote Debug Machine<\/strong> to one of the specified remote connections. You can <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/linux\/connect-to-your-remote-linux-computer?view=vs-2019\">add a new remote connection<\/a> via the Connection Manager. You can also specify a path to the directory on the remote system for the project to deploy to via <strong>Remote Deploy Directory<\/strong>.<\/p>\n<h4><span style=\"font-size: 18pt;\"><a name=\"cmake\"><\/a>Easily add, remove, and rename files in CMake projects<\/span><\/h4>\n<p>It\u2019s easier than ever to work with CMake projects in Visual Studio. In the latest preview, you can add, remove, and rename source files and targets in your CMake projects from the IDE without manually editing your CMake scripts. When you add or remove files with the Solution Explorer, Visual Studio will automatically edit your CMake project. You can also add, remove, and rename the project\u2019s targets from the Solution Explorer\u2019s targets view.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-25440 size-full\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/01\/CMake-Targets-View-Add-Menu.png\" alt=\"You can now easily add, remove, and rename files in CMake projects in Visual Studio\" width=\"820\" height=\"637\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/01\/CMake-Targets-View-Add-Menu.png 820w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/01\/CMake-Targets-View-Add-Menu-300x233.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/01\/CMake-Targets-View-Add-Menu-768x597.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/p>\n<p>In some cases, there may be more than one place where it makes sense to add a source file to a CMake script. When this happens, Visual Studio will ask you where you want to make the change and display a preview of the proposed modifications:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-25441\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/01\/CMake-Project-Editor-Reslove-Ambiguity.png\" alt=\"Visual Studio will prompt you to resolve ambiguity when adding a new file to your CMake project\" width=\"982\" height=\"519\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/01\/CMake-Project-Editor-Reslove-Ambiguity.png 982w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/01\/CMake-Project-Editor-Reslove-Ambiguity-300x159.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/01\/CMake-Project-Editor-Reslove-Ambiguity-768x406.png 768w\" sizes=\"(max-width: 982px) 100vw, 982px\" \/><\/p>\n<p>This feature is enabled by default as of Visual Studio 2019 15.5 Preview 2, but it can be turned off in Tools &gt; Options &gt; CMake, \u201cEnable automatic CMake script modification\u2026\u201d<\/p>\n<h4><span style=\"font-size: 18pt;\"><a name=\"lang\"><\/a>CMake language services<\/span><\/h4>\n<p>The latest Visual Studio preview also makes it easy to make sense of complex CMake projects. Code navigation features such as Go To Definition and Find All References are now supported for variables, functions, and targets in CMake script files.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-25442\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/01\/CMake-Lang-Services-Peek-Small.png\" alt=\"CMake language services, including Peek Definition, in CMakeLists.txt\" width=\"800\" height=\"436\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/01\/CMake-Lang-Services-Peek-Small.png 1023w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/01\/CMake-Lang-Services-Peek-Small-300x164.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/01\/CMake-Lang-Services-Peek-Small-768x419.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>These navigation features work across your entire CMake project to offer more productivity than na\u00efve text search across files and folders, and are integrated with other IDE productivity features such as <a href=\"https:\/\/docs.microsoft.com\/en-us\/visualstudio\/ide\/how-to-view-and-edit-code-by-using-peek-definition-alt-plus-f12?view=vs-2019\">Peek Definition<\/a>. Stay tuned for more information on both CMake features in standalone blog posts coming soon.<\/p>\n<h4><span style=\"font-size: 18pt;\"><a name=\"command\"><\/a>Command line utility to interact with the Connection Manager<\/span><\/h4>\n<p>In Visual Studio 2019 version 16.5 or later you can use a command line utility to programmatically add and remove remote connections from the connection store. This is useful for tasks such as provisioning a new development machine or setting up Visual Studio in continuous integration. Full documentation on the utility including <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/linux\/connectionmanager-reference?view=vs-2019\">usage, commands, and options can be found here<\/a>.<\/p>\n<h4><span style=\"font-size: 18pt;\"><a name=\"fips\"><\/a>FIPS 140-2 compliance for remote C++ development<\/span><\/h4>\n<p>Federal Information Processing Standard (FIPS) Publication 140-2 is a U.S. government standard for cryptographic models. Implementations of the standard are validated by NIST. Starting with Visual Studio version 16.5 remote Linux development with C++ is <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/security\/threat-protection\/fips-140-validation\">FIPS 140-2 compliant<\/a>. You can follow our <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/linux\/set-up-fips-compliant-secure-remote-linux-development?view=vs-2019\">step-by-step instructions to set up a secure, FIPS-compliant connection between Visual Studio and your remote Linux system<\/a>.<\/p>\n<h4><span style=\"font-size: 18pt;\"><a name=\"int\"><\/a>IntelliSense improvements\u00a0<\/span><\/h4>\n<p>IntelliSense now displays more readable type names when dealing with the Standard Library. For example, in the Quick Info tooltip <span style=\"font-family: 'Courier New';\">std::_vector_iterator&lt;int&gt; <\/span>becomes_<span style=\"font-family: 'Courier New';\">std::vector&lt;int&gt;::iterator<\/span>.<\/p>\n<p>We&#8217;ve also added the ability to toggle whether Enter, Space, and Tab function as commit characters, and to toggle whether Tab is used to Insert Snippet. Whether using a CMake or MSBuild project, you can find these settings under Tools &gt; Options &gt; Text Editor &gt; C\/C++ &gt; Advanced &gt; IntelliSense.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-25443\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/01\/intellisense.png\" alt=\"New Tools &gt; Options &gt; Text Editor &gt; C\/C++ &gt; Advanced &gt; IntelliSense settings in Visual Studio\" width=\"899\" height=\"139\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/01\/intellisense.png 899w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/01\/intellisense-300x46.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/01\/intellisense-768x119.png 768w\" sizes=\"(max-width: 899px) 100vw, 899px\" \/><\/p>\n<h4><span style=\"font-size: 18pt;\">Give us your feedback<\/span><\/h4>\n<p>Download <a href=\"https:\/\/visualstudio.microsoft.com\/vs\/preview\/\">Visual Studio 2019 version 16.5 Preview 2<\/a> today and give it a try. We\u2019d love to hear from you to help us prioritize and build the right features for you. We can be reached via the comments below, <a href=\"https:\/\/developercommunity.visualstudio.com\/spaces\/8\/index.html\">Developer Community<\/a>, email (<a href=\"mailto:visualcpp@microsoft.com\">visualcpp@microsoft.com<\/a>), and Twitter (<a href=\"https:\/\/twitter.com\/visualc\">@VisualC<\/a>). The best way to file a bug or suggest a feature is via Developer Community.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Visual Studio\u2019s native support for CMake allows you to target both Windows and Linux from the comfort of a single IDE. Visual Studio 2019 version 16.5 Preview 2 introduces several new features specific to cross-platform development, including: File copy optimizations for CMake projects targeting a remote Linux system Native WSL support when separating your build [&hellip;]<\/p>\n","protected":false},"author":2953,"featured_media":25442,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,266,279,230],"tags":[],"class_list":["post-25432","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus","category-cmake","category-linux","category-new-feature"],"acf":[],"blog_post_summary":"<p>Visual Studio\u2019s native support for CMake allows you to target both Windows and Linux from the comfort of a single IDE. Visual Studio 2019 version 16.5 Preview 2 introduces several new features specific to cross-platform development, including: File copy optimizations for CMake projects targeting a remote Linux system Native WSL support when separating your build [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/25432","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\/2953"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=25432"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/25432\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/25442"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=25432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=25432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=25432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}