The Meson Build System http://mesonbuild.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

7.2 KiB

short-description
Building a project with Meson

Sometimes you want to add extra compiler flags, this can be done by passing them in environment variables when calling meson. See the reference tables for a list of all the environment variables. Be aware however these environment variables are only used for the native compiler and will not affect the compiler used for cross-compiling, where the flags specified in the cross file will be used.

Furthermore it is possible to stop meson from adding flags itself by using the --buildtype=plain option, in this case you must provide the full compiler and linker arguments needed.

Building the source

If you are not using an IDE, Meson uses the Ninja build system to actually build the code. To start the build, simply type the following command.

ninja

The main usability difference between Ninja and Make is that Ninja will automatically detect the number of CPUs in your computer and parallelize itself accordingly. You can override the amount of parallel processes used with the command line argument -j <num processes>.

It should be noted that after the initial configure step ninja is the only command you ever need to type to compile. No matter how you alter your source tree (short of moving it to a completely new location), Meson will detect the changes and regenerate itself accordingly. This is especially handy if you have multiple build directories. Often one of them is used for development (the "debug" build) and others only every now and then (such as a "static analysis" build). Any configuration can be built just by cd'ing to the corresponding directory and running Ninja.

Running tests

Meson provides native support for running tests. The command to do that is simple.

ninja test

Meson does not force the use of any particular testing framework. You are free to use GTest, Boost Test, Check or even custom executables.

Installing

Installing the built software is just as simple.

ninja install

Note that Meson will only install build targets explicitly tagged as installable, as detailed in the installing targets documentation.

By default Meson installs to /usr/local. This can be changed by passing the command line argument --prefix /your/prefix to Meson during configure time. Meson also supports the DESTDIR variable used in e.g. building packages. It is used like this:

DESTDIR=/path/to/staging ninja install

Command line help

Meson has a standard command line help feature. It can be accessed with the following command.

meson --help

Exit status

Meson exits with status 0 if successful, 1 for problems with the command line or meson.build file, and 2 for internal errors.