Skip to content

Commit ed19e2e

Browse files
authored
Merge pull request #2059 from mikeblome/mb-linux-asan
Updates for Linux projects in VS2019 16.1
2 parents ea801f1 + a20ddfc commit ed19e2e

35 files changed

+517
-131
lines changed

docs/linux/cmake-linux-project.md

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
---
22
title: "Configure a Linux CMake project in Visual Studio"
33
description: "How to configure, edit and compile a Linux CMake project in Visual Studio"
4-
ms.date: "05/21/2019"
4+
ms.date: "06/07/2019"
55
ms.assetid: f8707b32-f90d-494d-ae0b-1d44425fdc25
66
---
77

88
# Configure a Linux CMake project
99

10+
::: moniker range="vs-2015"
11+
12+
Linux support is available in Visual Studio 2017 and later.
13+
14+
::: moniker-end
15+
1016
When you open a folder that contains a CMake project, Visual Studio uses the metadata that CMake produces to configure IntelliSense and builds automatically. Local configuration and debugging settings are stored in JSON files that can optionally be shared with others who are using Visual Studio.
1117

1218
Visual Studio does not modify the CMakeLists.txt files or the original CMake cache, so that others working on the same project can continue to use whatever tools they are already using.
@@ -17,7 +23,7 @@ For general information about CMake support in Visual Studio, see [CMake Tools f
1723

1824
First, make sure you have the **Linux development with C++** workload installed, including the CMake component. See [Install the C++ Linux workload in Visual Studio](download-install-and-setup-the-linux-development-workload.md).
1925

20-
On the Linux machine, make sure that the following are installed:
26+
On the Linux system, make sure that the following are installed:
2127

2228
- gcc
2329
- gdb
@@ -26,16 +32,16 @@ On the Linux machine, make sure that the following are installed:
2632

2733
::: moniker range="vs-2019"
2834

29-
Linux support for CMake projects requires a recent version of CMake to be installed on the target machine. Often, the version offered by a distribution’s default package manager is not recent enough to support all the IDE’s features. Visual Studio 2019 can automatically install a user local copy of CMake on remote Linux machines that don’t have a recent version of CMake installed. If a compatible version of CMake isn’t detected the first time you build your project, you will see an info-bar offering to install CMake.
30-
31-
The binaries will be installed to `~/.vs/cmake`. After deploying the binaries, your project will automatically regenerate. Note that if the CMake specified by the `cmakeExecutable` field in `CMakeSettings.json` is invalid (doesn't exist or is an unsupported version) and the prebuilt binaries are present Visual Studio will ignore `cmakeExecutable` and use the prebuilt binaries.
35+
Linux support for CMake projects requires a recent version of CMake to be installed on the target machine. Often, the version offered by a distribution’s default package manager is not recent enough to support all the features that are required by Visual Studio. Visual Studio 2019 detects whether a recent version of CMake is installed on the Linux system. If none is found, Visual Studio shows an info-bar at the top of the editor pane that offers to install it for you.
3236

3337
::: moniker-end
3438

3539
::: moniker range="vs-2017"
3640

3741
The CMake support in Visual Studio requires the server mode support that was introduced in CMake 3.8. For a Microsoft-provided CMake variant, download the latest prebuilt binaries at [https://github.com/Microsoft/CMake/releases](https://github.com/Microsoft/CMake/releases).
3842

43+
The binaries will be installed to `~/.vs/cmake`. After deploying the binaries, your project will automatically regenerate. Note that if the CMake specified by the `cmakeExecutable` field in `CMakeSettings.json` is invalid (doesn't exist or is an unsupported version) and the prebuilt binaries are present Visual Studio will ignore `cmakeExecutable` and use the prebuilt binaries.
44+
3945
:::moniker-end
4046

4147
## Open a folder
@@ -63,19 +69,29 @@ add_executable(hello-cmake hello.cpp)
6369

6470
## Choose a Linux target
6571

66-
As soon as you open the folder, Visual Studio parses the CMakeLists.txt file and specifies a Windows target of **x86-Debug**. To target Linux, change the project settings to **Linux-Debug** or **Linux-Release**.
72+
As soon as you open the folder, Visual Studio parses the CMakeLists.txt file and specifies a Windows target of **x86-Debug**. To target a remote Linux system, change the project settings to **Linux-Debug** or **Linux-Release**.
73+
74+
::: moniker range="vs-2019"
75+
76+
To target Windows Subsystem for Linux, choose **WSL-Debug** or **WSL-Release** if using GCC, or the Clang variants if using the Clang/LLVM toolset.
77+
78+
**Visual Studio 2019 version 16.1** When targeting WSL, no copying or sources or headers is necessary because the compiler on Linux has direct access to the Windows file system where your source files are located, and Visual Studio likewise can access the Linux header files directly.
79+
80+
::: moniker-end
81+
82+
For remote targets, Visual Studio by default chooses the first remote system in the list under **Tools** > **Options** > **Cross Platform** > **Connection Manager**. If no remote connections are found, you are prompted to create one. For more information, see [Connect to your remote Linux computer](connect-to-your-remote-linux-computer.md).
6783

68-
By default, Visual Studio chooses the first remote system in the list under **Tools** > **Options** > **Cross Platform** > **Connection Manager**. If no remote connections are found, you are prompted to create one. For more information, see [Connect to your remote Linux computer](connect-to-your-remote-linux-computer.md).
84+
If you specify a remote Linux target, your source is copied to the remote system.
6985

70-
After you specify a Linux target, your source is copied to your Linux machine. Then, CMake is run on the Linux machine to generate the CMake cache for your project.
86+
After you select a target, CMake runs automatically on the Linux system to generate the CMake cache for your project.
7187

7288
![Generate CMake cache on Linux](media/cmake-linux-1.png "Generate the CMake cache on Linux")
7389

74-
To provide IntelliSense support for remote headers, Visual Studio automatically copies them from the Linux machine to a directory on your local Windows machine. For more information, see [IntelliSense for remote headers](configure-a-linux-project.md#remote_intellisense).
90+
To provide IntelliSense support for headers on remote Linux systems, Visual Studio automatically copies them from the Linux machine to a directory on your local Windows machine. For more information, see [IntelliSense for remote headers](configure-a-linux-project.md#remote_intellisense).
7591

7692
## Debug the project
7793

78-
To debug your code on the remote system, set a breakpoint, select the CMake target as the startup item in the toolbar menu next to the project setting, and choose **⏵ Start** on the toolbar, or press F5.
94+
To debug your code on the specified debug target system, set a breakpoint, select the CMake target as the startup item in the toolbar menu next to the project setting, and choose **⏵ Start** on the toolbar, or press F5.
7995

8096
To customize your program’s command line arguments, right-click on the executable in **Solution Explorer** and select **Debug and Launch Settings**. This opens or creates a launch.vs.json configuration file that contains information about your program. To specify additional arguments, add them in the `args` JSON array. For more information, see [Open Folder projects for C++](../build/open-folder-projects-cpp.md) and [Configure CMake debugging sessions](../build/configure-cmake-debugging-sessions.md).
8197

@@ -87,7 +103,7 @@ A CMakeSettings.json file in a CMake Linux project can specify all the propertie
87103

88104
To change the default CMake settings in Visual Studio 2019, from the main toolbar, open the **Configuration** drop down and choose **Manage Configurations**.
89105

90-
![CMake Manage Configurations](../build/media/vs2019-cmake-manage-configurations.png "CMake configurations drop-down")
106+
![CMake Manage Configurations](../build/media/vs2019-cmake-manage-configurations.png "CMake configurations drop-down")
91107

92108
This brings up the **CMake Settings Editor** which you can use to edit the `CMakeSettings.json` file in your root project folder. You can also open the file directly by clicking the **Edit JSON** button in the editor. For more information, see [Customize CMake Settings](../build/customize-cmake-settings.md).
93109

@@ -153,7 +169,7 @@ You can use these optional settings for more control:
153169
}
154170
```
155171

156-
These options allow you to run commands on the remote system before and after building, and before CMake generation. The values can be any command that is valid on the remote system. The output is piped back to Visual Studio.
172+
These options allow you to run commands on the Linux system before and after building, and before CMake generation. The values can be any command that is valid on the remote system. The output is piped back to Visual Studio.
157173

158174
::: moniker range="vs-2019"
159175

0 commit comments

Comments
 (0)