Debian Codegraph @

subprojects/meson-docs/docs/markdown/Vs-External.md

raw
1 # Visual Studio's external build projects
2
3 Visual Studio supports developing projects that have an external build
4 system. If you wish to use this integration method, here is how you
5 set it up. This documentation describes Visual Studio 2019. Other
6 versions have not been tested, but they should work roughly in the
7 same way.
8
9 ## Creating and compiling
10
11 Check out your entire project in some directory. Then open Visual
12 Studio and select `File -> New -> Project` and from the list of
13 project types select `Makefile project`. Click `Next`.
14
15 Type your project's name In the `Project name` entry box. In this
16 example we're going to use `testproj`. Next select the `Location`
17 entry and browse to the root of your project sources. Make sure that
18 the checkbox `Place solution and project in the same directory` is
19 checked. Click `Create`.
20
21 The next dialog page defines build commands, which you should set up
22 as follows:
23
24 | entry | value |
25 | ----- | ----- |
26 |build | `meson compile -C $(Configuration)` |
27 |clean | `meson compile -C $(Configuration) --clean` |
28 |rebuild| `meson compile -C $(Configuration) --clean && meson compile -C $(Configuration)` |
29 |Output | `$(Configuration)\name_of_your_executable.exe` |
30
31
32 Then click `Finish`.
33
34 Visual Studio has created a subdirectory in your source root. It is
35 named after the project name. In this case it would be `testproj`. Now
36 you need to set up Meson for building both Debug and Release versions
37 in this directory. Open a VS dev tool terminal, go to the source root
38 and issue the following commands.
39
40 ```
41 meson testproj\Debug
42 meson testproj\Release --buildtype=debugoptimized
43 ```
44
45 Now you should have a working VS solution that compiles and runs both
46 in Debug and Release modes.
47
48 ## Adding sources to the project
49
50 This project is not very useful on its own, because it does not list
51 any source files. VS does not seem to support adding entire source
52 trees at once, so you have to add sources to the solution manually.
53
54 In the main view go to `Solution Explorer`, right click on the project
55 you just created and select `Add -> Existing Item`, browse to your
56 source tree and select all files you want to have in this project. Now
57 you can use the editor and debugger as in a normal VS project.