In Visual Studio 2019 you can target both Windows and Linux from the comfort of a single IDE. Visual Studio’s native support for CMake lets you open any folder containing C++ code and a CMakeLists.txt file directly in Visual Studio to edit, build, and debug your CMake project on Windows, Linux, and the Windows Subsystem for Linux (WSL). Visual Studio’s MSBuild-based Linux support allows you to create and debug console applications that execute on a remote Linux system or WSL. For either of these scenarios, the Linux development with C++ workload is required.
Visual Studio 2019 version 16.3 Preview 2 introduces several improvements specific to Visual Studio’s native CMake support and MSBuild-based Linux support. If you are just getting started with Linux development in Visual Studio, I recommend trying our native support for WSL.
Install missing vcpkg packages with a quick action in CMake projects
Vcpkg helps you manage C and C++ libraries on Windows, Linux, and macOS. In Visual Studio 2019 version 16.3 we have improved vcpkg integration in Visual Studio for CMake projects that are using the vcpkg toolchain file and have run ‘vcpkg integrate install’. You will now be prompted to install missing vcpkg packages via a quick action:
Selecting “Install package…” will automatically install the missing package (and all required dependencies) using vcpkg and route all output to the Output Window.
CMake Settings Editor usability improvements
We’ve made it easier to configure CMake projects in Visual Studio by improving property descriptions in the CMake Settings Editor and providing in-editor links to relevant documentation.
The CMake Settings Editor now maps Visual Studio properties to the corresponding CMake variable (e.g. configuration type to CMAKE_BUILD_TYPE) and describes other tools (vcpkg, rsync) that can be configured in Visual Studio.
Remote header performance improvements for Linux projects
When you connect to a remote Linux system, Visual Studio automatically copies the include directories for the compiler from the remote system to Windows to provide IntelliSense as if you were working on your remote machine. In Visual Studio 2019 version 16.3 Preview 2 the remote header copy has been optimized and now runs in parallel. This leads to performance improvements for large codebases. For example, the initial remote header sync for MySQL Server now runs ~30% faster. Performance improvements for your own codebase may vary.
These performance improvements apply to both CMake Linux projects and MSBuild-based Linux projects. More IntelliSense improvements for Linux projects are coming soon and will be available in a future release, so stay tuned.
Improvements to Visual Studio’s native support for WSL
In Visual Studio 2019 version 16.1 we announced native support for C++ with WSL. This allows you to build and debug on your local WSL installation without adding a remote connection or configuring SSH. In Visual Studio 2019 version 16.3 Preview 2 we have added support for parallel builds for MSBuild-based Linux projects targeting WSL. You can configure the maximum number of compilation processes to be created in parallel via Properties > C/C++ > General > Max Parallel Compilation Jobs:
Support for parallel compilation jobs has been added for WSL applications that use gcc or Clang.
We also added support for WSL build events for MSBuild-based Linux projects targeting WSL. These events allow you to specify a command for the pre-build, pre-link, and post-build event tools to run in the WSL shell and can be configured via Properties > Build Events.
Resolved issues
The best way to report a problem or suggest a feature to the C++ team is via Developer Community. The following feedback tickets related to C++ cross-platform development are resolved in Visual Studio 2019 version 16.3 (some fixes will be available soon in 16.3 Preview 3):
VS2019 wipes CMake build directory each time I touch CMakeLists.txt
CTest’s add_test passes incorrect number of arguments to command
CMake cache generation always deletes build directory if toolchain path has backslashes
CMake MSVC_TOOLSET_VERSION is incorrect in Visual Studio 2019
VS API issue on CMake solutions in VS 16.2 Preview
Talk to us!
Do you have feedback on our Linux tooling or CMake support in Visual Studio? We’d love to hear your feedback to help us prioritize and build the right features for you. We can be reached via the comments below, email (visualcpp@microsoft.com), and Twitter (@VisualC).
The post C++ Cross-Platform Development with Visual Studio 2019 version 16.3: vcpkg, CMake configuration, remote headers, and WSL appeared first on C++ Team Blog.