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
Copy file name to clipboardExpand all lines: docs/build/clang-support-msbuild.md
+53-10
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
description: "Learn more about: Clang/LLVM support in Visual Studio projects"
3
-
title: "Clang/LLVM support in Visual Studio Visual Studio projects"
4
-
ms.date: "06/02/2020"
3
+
title: "Clang/LLVM support in Visual Studio projects"
4
+
ms.date: 02/05/2021
5
5
ms.description: "Configure a Visual Studio MSBuild project to use the Clang/LLVM toolchain."
6
6
helpviewer_keywords: ["Clang support for C++ MSBuild projects"]
7
7
---
@@ -19,7 +19,9 @@ You can use Visual Studio 2019 version 16.2 with Clang to edit, build, and debug
19
19
20
20
## Install
21
21
22
-
For best IDE support in Visual Studio, we recommend using the latest Clang compiler tools for Windows. If you don't already have those, you can install them by opening the Visual Studio Installer and choosing **C++ Clang tools for Windows** under **Desktop development with C++** optional components. If you prefer to use an existing Clang installation on your machine, choose the **C++ Clang-cl for v142 build tools.** optional component. The Microsoft C++ Standard Library currently requires at least Clang 8.0.0; the bundled version of Clang will automatically be updated to stay current with updates in the Microsoft implementation of the Standard Library.
22
+
For best IDE support in Visual Studio, we recommend using the latest Clang compiler tools for Windows. If you don't already have the tools, you can install them by opening the Visual Studio Installer and choosing **C++ Clang tools for Windows** under **Desktop development with C++** optional components. You may prefer to use an existing Clang installation on your machine; if so, choose the **C++ Clang-cl for v142 build tools.** optional component.
23
+
24
+
The Microsoft C++ Standard Library currently requires at least Clang 8.0.0. The bundled version of Clang gets updated automatically to stay current with updates in the Microsoft implementation of the Standard Library.
23
25
24
26

25
27
@@ -29,9 +31,9 @@ To configure a Visual Studio project to use Clang, right-click on the project no
29
31
30
32

31
33
32
-
If you are using the Clang tools that are bundled with Visual Studio, no additional steps are required. For Windows projects, Visual Studio by default invokes Clang in [clang-cl](https://llvm.org/devmtg/2014-04/PDFs/Talks/clang-cl.pdf) mode and links with the Microsoft implementation of the Standard Library. By default, **clang-cl.exe** is located in *%VCINSTALLDIR%\\Tools\\Llvm\\bin\\* and *%VCINSTALLDIR%\\Tools\\Llvm\\x64\\bin\\*.
34
+
If you're using the Clang tools that are bundled with Visual Studio, no extra steps are required. For Windows projects, Visual Studio by default invokes Clang in [clang-cl](https://llvm.org/devmtg/2014-04/PDFs/Talks/clang-cl.pdf) mode. It links with the Microsoft implementation of the Standard Library. By default, **clang-cl.exe** is located in *%VCINSTALLDIR%\\Tools\\Llvm\\bin\\* and *%VCINSTALLDIR%\\Tools\\Llvm\\x64\\bin\\*.
33
35
34
-
If you are using a custom Clang installation, you can either modify **Project** > **Properties** > **VC++ DIrectories** > **Configuration Properties** > **Executable Directories** by adding the custom Clang installation root as the first directory there, or change the value of the `LLVMInstallDir` property. See [Set a custom LLVM location](#custom_llvm_location) for more information.
36
+
If you're using a custom Clang installation, you can either modify **Project** > **Properties** > **VC++ DIrectories** > **Configuration Properties** > **Executable Directories** by adding the custom Clang installation root as the first directory there, or change the value of the `LLVMInstallDir` property. For more information, see [Set a custom LLVM location](#custom_llvm_location).
35
37
36
38
## Configure a Linux project to use Clang tools
37
39
@@ -41,28 +43,69 @@ To configure a Visual Studio Linux project to use Clang:
41
43
42
44
1. Right-click on the project node in **Solution Explorer** and choose **Properties**.
43
45
1. Typically, you should first choose **All configurations** at the top of the dialog.
44
-
1. Under **General** > **Platform Toolset**, choose **WSL_Clang_1_0** if you are using Windows Subsystem for Linux, or **Remote_Clang_1_0** if you are using a remote machine or VM.
46
+
1. Under **General** > **Platform Toolset**, choose **WSL_Clang_1_0** if you're using Windows Subsystem for Linux (WSL). Choose **Remote_Clang_1_0** if you're using a remote machine or VM.
45
47
1. Press **OK**.
46
48
47
49

48
50
49
-
On Linux, Visual Studio by default uses the first Clang location that it encounters in the PATH environment property. If you are using a custom Clang installation, then you must change the value of the `LLVMInstallDir` property or else substitute a path under **Project** > **Properties** > **VC++ DIrectories** > **Configuration Properties** > **Executable Directories**. See [Set a custom LLVM location](#custom_llvm_location) for more information.
51
+
On Linux, Visual Studio by default uses the first Clang location that it finds in the PATH environment property. If you're using a custom Clang installation, then either change the value of the `LLVMInstallDir` property or else enter the path under **Project** > **Properties** > **Configuration Properties** > **VC++ DIrectories** > **Executable Directories**. For more information, see [Set a custom LLVM location](#custom_llvm_location).
50
52
51
53
## <aname="custom_llvm_location"></a> Set a custom LLVM location
52
54
53
-
You can set a custom path for LLVM for one or more projects by creating a *Directory.build.props* file and adding that file to the root folder of any project. You can add it to the root solution folder to apply it to all projects in the solution. The file should look like this (but substitute your actual path):
55
+
You can set a custom path to LLVM for one or more projects by creating a *Directory.build.props* file. Then, add that file to the root folder of any project. You can add it to the root solution folder to apply it to all projects in the solution. The file should look like this (but use your actual LLVM path):
54
56
55
57
```xml
56
58
<Project>
57
59
<PropertyGroup>
58
-
<LLVMInstallDir>c:\MyLLVMRootDir</LLVMInstallDir>
60
+
<LLVMInstallDir>C:\MyLLVMRootDir</LLVMInstallDir>
59
61
</PropertyGroup>
60
62
</Project>
61
63
```
62
64
65
+
You can combine this property with a custom LLVM toolset version. For more information, see [Set a custom LLVM toolset version](#custom_llvm_toolset).
66
+
67
+
## <aname="custom_llvm_toolset"></a> Set a custom LLVM toolset version
68
+
69
+
Starting in Visual Studio 2019 version 16.9, you can set a custom toolset version for LLVM. To set this property in a project in Visual Studio:
70
+
71
+
1. Open the project's **Property Pages** dialog box. For details, see [Set C++ compiler and build properties in Visual Studio](./working-with-project-properties.md).
72
+
73
+
1. Select the **Configuration Properties** > **General** property page.
74
+
75
+
1. Modify the **Platform Toolset** property to *LLVM (clang-cl)*, if it isn't already set.
76
+
77
+
1. Select the **Configuration Properties** > **Advanced** property page.
78
+
79
+
1. Modify the **LLVM Toolset Version** property to your preferred version, and then choose **OK** to save your changes.
80
+
81
+
The **LLVM Toolset Version** property only appears when the LLVM platform toolset is selected.
82
+
83
+
You can set the toolset version for one or more projects by creating a *Directory.build.props* file. Then, add that file to the root folder of any project. Add it to the root solution folder to apply it to all projects in the solution. The file should look like this (but use your actual LLVM path):
84
+
85
+
```xml
86
+
<Project>
87
+
<PropertyGroup>
88
+
<LLVMToolsVersion>11.0.0</LLVMToolsVersion>
89
+
</PropertyGroup>
90
+
</Project>
91
+
```
92
+
93
+
You can also combine this property with a custom LLVM location. For example, your *Directory.build.props* file could look like:
94
+
95
+
```xml
96
+
<Project>
97
+
<PropertyGroup>
98
+
<LLVMInstallDir>C:\MyLLVMRootDir</LLVMInstallDir>
99
+
<LLVMToolsVersion>11.0.0</LLVMToolsVersion>
100
+
</PropertyGroup>
101
+
</Project>
102
+
```
103
+
104
+
When you add a *Directory.build.props* file, the settings appear as the default in the project Property Pages dialog. However, changes to these properties in Visual Studio override the settings in the *Directory.build.props* file.
105
+
63
106
## Set additional properties, edit, build, and debug
64
107
65
-
After you have set up a Clang configuration, right-click again on the project node and choose **Reload project**. You can now build and debug the project using the Clang tools. Visual Studio detects that you are using the Clang compiler and provides IntelliSense, highlighting, navigation, and other editing features. Errors and warnings are displayed in the **Output Window**. The project property pages for a Clang configuration are very similar to those for MSVC, although some compiler-dependent features such as Edit and Continue are not available for Clang configurations. To set a Clang compiler or linker option that is not available in the property pages, you can add it manually in the property pages under **Configuration Properties** > **C/C++ (or Linker)** > **Command Line** > **Additional Options**.
108
+
After you have set up a Clang configuration, right-click again on the project node and choose **Reload project**. You can now build and debug the project using the Clang tools. Visual Studio detects that you're using the Clang compiler and provides IntelliSense, highlighting, navigation, and other editing features. Errors and warnings are displayed in the **Output Window**. The project property pages for a Clang configuration are similar to the ones for MSVC. However, some compiler-dependent features such as Edit and Continue aren't available for Clang configurations. You can set a Clang compiler or linker option that isn't available in the property pages. Add it manually in the property pages under **Configuration Properties** > **C/C++ (or Linker)** > **Command Line** > **Additional Options**.
66
109
67
110
When debugging, you can use breakpoints, memory and data visualization, and most other debugging features.
ms.description: "Use the Advanced property page in Visual Studio 2019 to set various properties for C++ projects."
7
7
---
8
8
# Advanced Property Page
@@ -83,6 +83,10 @@ The Advanced property page is available in Visual Studio 2019 and later.
83
83
84
84
Specifies the full version of the MSVC toolset that's used to build the project. You may have various update and preview versions of a toolset installed. You can specify which one to use here.
85
85
86
+
-**LLVM Toolset Version**
87
+
88
+
Specifies the full version of the LLVM toolset that's used to build the project. This property is available when **LLVM (clang-cl)** is selected as the platform toolset, starting in Visual Studio 2019 version 16.9. For more information, see [Set a custom LLVM toolset version](..\clang-support-msbuild.md#custom_llvm_toolset).
0 commit comments