You can specify a different type of build with the `--buildtype` command line
argument. It can have one of the following values.
| value | meaning |
| ------ | -------- |
| `plain` | no extra build flags are used, even for compiler warnings, useful for distro packagers and other cases where you need to specify all arguments by yourself |
| `debug` | debug info is generated but the result is not optimized, this is the default |
| `debugoptimized` | debug info is generated and the code is optimized (on most compilers this means `-g -O2`) |
| `release` | full optimization, no debug info |
The build directory is mandatory. The reason for this is that it simplifies the
build process immensely. Meson will not under any circumstances write files
inside the source directory (if it does, it is a bug and should be fixed). This
means that the user does not need to add a bunch of files to their revision
control's ignore list. It also means that you can create arbitrarily many build
directories for any given source tree.
For example, if we wanted to test building the source code with the Clang
compiler instead of the system default, we could just type the following
commands:
```sh
cd /path/to/source/root
CC=clang CXX=clang++ meson setup buildclang
```
This separation is even more powerful if your code has multiple configuration
options (such as multiple data backends). You can create a separate
subdirectory for each of them. You can also have build directories for
optimized builds, code coverage, static analysis and so on. They are all neatly
separated and use the same source tree. Changing between different
configurations is just a question of changing to the corresponding directory.
Unless otherwise mentioned, all following command line invocations are meant to
be run in the source directory.
By default Meson will use the Ninja backend to build your project. If you wish
to use any of the other backends, you need to pass the corresponding argument
during configuration time. As an example, here is how you would use Meson to