Debian Codegraph @

subprojects/meson-docs/docs/markdown/Using-with-Visual-Studio.md

raw
1 ---
2 short-description: How to use Meson in Visual Studio
3 ...
4
5 # Using with Visual Studio
6
7 In order to generate Visual Studio projects, Meson needs to know the
8 settings of your installed version of Visual Studio.
9
10
11 The traditional way to get this information is to run Meson (or any build
12 system) under the Visual Studio Command Prompt.
13
14 If no Visual Studio Command Prompt was detected, and no mingw compilers are
15 detected either, meson will attempt to find "a" Visual Studio installation for
16 you automatically, by asking Microsoft's "vswhere" program. If you want to
17 ignore mingw compilers, pass the `--vsenv` option on the meson command line.
18 If you need to guarantee a specific Visual Studio version, set it up manually.
19
20 You can always find the Visual Studio Command Prompt by searching from
21 the Start Menu. However, the name is different for each Visual Studio
22 version. With Visual Studio 2019, look for "x64 Native Tools Command
23 Prompt for VS 2019". The next steps are [the same as
24 always](https://mesonbuild.com/Running-Meson.html#configuring-the-build-directory):
25
26 1. `cd` into your source directory
27 1. `meson setup builddir`, which will create and setup the build directory
28 1. `meson compile -C builddir`, to compile your code. You can also use `ninja -C builddir` here if you are using the default Ninja backend.
29
30 If you wish to generate Visual Studio project files, pass `--backend
31 vs`. At the time of writing the Ninja backend is more mature than the
32 VS backend so you might want to use it for serious work.
33
34 # Using Clang-CL with Visual Studio
35
36 *(new in 0.52.0)*
37
38 You will first need to get a copy of llvm+clang for Windows, such versions
39 are available from a number of sources, including the llvm website. Then you
40 will need the [llvm toolset extension for visual
41 studio](https://marketplace.visualstudio.com/items?itemName=LLVMExtensions.llvm-toolchain).
42 You then need to either use a [native file](Native-environments.md#binaries)
43 or `set CC=clang-cl`, and `set CXX=clang-cl` to use those compilers, Meson
44 will do the rest.
45
46 This only works with visual studio 2017 and 2019.
47
48 There is currently no support in Meson for clang/c2.
49
50 # Using Intel-CL (ICL) with Visual Studio
51
52 *(new in 0.52.0)*
53
54 To use ICL you need only have ICL installed and launch an ICL development
55 shell like you would for the ninja backend and Meson will take care of it.