You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Linux support is available in Visual Studio 2017 and later.
11
+
Linux support is available in Visual Studio 2017 and later. To see the documentation for these versions, set the Visual Studio **Version** selector control for this article to Visual Studio 2017 or Visual Studio 2019. It's found at the top of the table of contents on this page.
12
12
13
13
::: moniker-end
14
14
15
-
::: moniker range="vs-2019"
16
-
17
-
To create a new Linux CMake project in Visual Studio 2019:
18
-
19
-
1. Select **File > New Project** in Visual Studio, or press **Ctrl + Shift + N**.
20
-
1. Set the **Language** to **C++** and search for "CMake". Then choose **Next**. Enter a **Name** and **Location**, and choose **Create**.
21
-
22
-
Visual Studio creates a minimal *CMakeLists.txt* file with only the name of the executable and the minimum CMake version required. You can manually edit this file however you like; Visual Studio will never overwrite your changes. You can specify CMake command-line arguments and environment variables in this file. Right-click on the root *CMakeLists.txt* file in **Solution Explorer** and choose **CMake settings for project**. To specify options for debugging, right-click on the project node and choose **Debug and launch settings**.
23
-
24
-
::: moniker-end
25
-
26
-
When you open a folder that contains an existing CMake project, Visual Studio uses variables in the CMake cache to automatically configure IntelliSense and builds. Local configuration and debugging settings get stored in JSON files. You can optionally share these files with others who are using Visual Studio.
27
-
28
-
Visual Studio doesn't modify the *CMakeLists.txt* files. It's left alone so that others working on the same project can continue to use their existing tools. Visual Studio does regenerate the cache when you save edits to *CMakeLists.txt* or in some cases to *CMakeSettings.json*. But if you're using an **Existing Cache** configuration, then Visual Studio doesn't modify the cache.
29
-
30
-
For general information about CMake support in Visual Studio, see [CMake projects in Visual Studio](../build/cmake-projects-in-visual-studio.md). Read that first before continuing here.
15
+
::: moniker range=">=vs-2017"
31
16
32
17
## Before you begin
33
18
@@ -41,6 +26,8 @@ On the Linux system, make sure that the following are installed:
41
26
- zip
42
27
- ninja-build
43
28
29
+
::: moniker-end
30
+
44
31
::: moniker range="vs-2019"
45
32
46
33
Linux support for CMake projects requires the target machine to have a recent version of CMake. Often, the version offered by a distribution’s default package manager isn't recent enough to support all the features 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. It offers to install CMake for you from [https://github.com/Microsoft/CMake/releases](https://github.com/Microsoft/CMake/releases).
@@ -57,7 +44,28 @@ The binaries are installed in `~/.vs/cmake`. After deploying the binaries, your
57
44
58
45
:::moniker-end
59
46
60
-
## Open a folder
47
+
::: moniker range="vs-2019"
48
+
49
+
## Create a new Linux CMake project
50
+
51
+
To create a new Linux CMake project in Visual Studio 2019:
52
+
53
+
1. Select **File > New Project** in Visual Studio, or press **Ctrl + Shift + N**.
54
+
1. Set the **Language** to **C++** and search for "CMake". Then choose **Next**. Enter a **Name** and **Location**, and choose **Create**.
55
+
56
+
Visual Studio creates a minimal *CMakeLists.txt* file with only the name of the executable and the minimum CMake version required. You can manually edit this file however you like; Visual Studio will never overwrite your changes. You can specify CMake command-line arguments and environment variables in this file. Right-click on the root *CMakeLists.txt* file in **Solution Explorer** and choose **CMake settings for project**. To specify options for debugging, right-click on the project node and choose **Debug and launch settings**.
57
+
58
+
::: moniker-end
59
+
60
+
::: moniker range=">=vs-2017"
61
+
62
+
## Open a CMake project folder
63
+
64
+
When you open a folder that contains an existing CMake project, Visual Studio uses variables in the CMake cache to automatically configure IntelliSense and builds. Local configuration and debugging settings get stored in JSON files. You can optionally share these files with others who are using Visual Studio.
65
+
66
+
Visual Studio doesn't modify the *CMakeLists.txt* files. It's left alone so that others working on the same project can continue to use their existing tools. Visual Studio does regenerate the cache when you save edits to *CMakeLists.txt* or in some cases to *CMakeSettings.json*. But if you're using an **Existing Cache** configuration, then Visual Studio doesn't modify the cache.
67
+
68
+
For general information about CMake support in Visual Studio, see [CMake projects in Visual Studio](../build/cmake-projects-in-visual-studio.md). Read that first before continuing here.
61
69
62
70
To get started, choose **File** > **Open** > **Folder** from the main menu or else type `devenv.exe <foldername>` in a [developer command prompt](../build/building-on-the-command-line.md) window. The folder you open should have a *CMakeLists.txt* file in it, along with your source code.
63
71
@@ -76,7 +84,7 @@ int main(int argc, char* argv[])
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**. (See [Configure CMake settings for Linux](#configure_cmake_linux) below.)
88
96
97
+
::: moniker-end
98
+
89
99
::: moniker range="vs-2019"
90
100
91
101
To target Windows Subsystem for Linux, click on **Manage Configurations** in the configuration dropdown in the main toolbar. Then press the **Add Configuration** button and choose **WSL-Debug** or **WSL-Release** if using GCC. Use the Clang variants if using the Clang/LLVM toolset.
@@ -94,6 +104,8 @@ To target Windows Subsystem for Linux, click on **Manage Configurations** in the
94
104
95
105
::: moniker-end
96
106
107
+
::: moniker range=">=vs-2017"
108
+
97
109
Visual Studio chooses the first remote system in the list under **Tools** > **Options** > **Cross Platform** > **Connection Manager** by default for remote targets. If no remote connections are found, you're prompted to create one. For more information, see [Connect to your remote Linux computer](connect-to-your-remote-linux-computer.md).
98
110
99
111
If you specify a remote Linux target, your source is copied to the remote system.
@@ -125,6 +137,8 @@ To specify additional arguments, add them in the `args` JSON array. For more inf
125
137
126
138
A *CMakeSettings.json* file in a CMake Linux project can specify all the properties listed in [Customize CMake settings](../build/customize-cmake-settings.md), plus additional properties that control the build settings on the remote Linux machine.
127
139
140
+
::: moniker-end
141
+
128
142
::: moniker range="vs-2019"
129
143
130
144
To change the default CMake settings in Visual Studio 2019, from the main toolbar, open the **Configuration** dropdown and choose **Manage Configurations**.
@@ -133,11 +147,39 @@ To change the default CMake settings in Visual Studio 2019, from the main toolba
133
147
134
148
This command 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).
135
149
150
+
The default Linux-Debug configuration in Visual Studio 2019 version 16.1 and later is as shown here:
To change the default CMake settings in Visual Studio 2017, choose **CMake** > **Change CMake Settings** > **CMakeLists.txt** from the main menu. Or, right-click CMakeSettings.txt in **Solution Explorer** and choose **Change CMake Settings**. Visual Studio then creates a new *CMakeSettings.json* file in your root project folder. You can open the file using the **CMake Settings** editor or modify the file directly. For more information, see [Customize CMake settings](../build/customize-cmake-settings.md).
182
+
To change the default CMake settings in Visual Studio 2017, choose **CMake** > **Change CMake Settings** > **CMakeLists.txt** from the main menu. Or, right-click *CMakeSettings.txt* in **Solution Explorer** and choose **Change CMake Settings**. Visual Studio then creates a new *CMakeSettings.json* file in your root project folder. You can open the file using the **CMake Settings** editor or modify the file directly. For more information, see [Customize CMake settings](../build/customize-cmake-settings.md).
141
183
142
184
The following example shows the default configuration for Linux-Debug in Visual Studio 2017 (and Visual Studio 2019 version 16.0) based on the previous code example:
143
185
@@ -169,37 +211,7 @@ The following example shows the default configuration for Linux-Debug in Visual
169
211
170
212
::: moniker-end
171
213
172
-
::: moniker range="vs-2019"
173
-
174
-
The default Linux-Debug configuration in Visual Studio 2019 version 16.1 and later is as shown here:
0 commit comments