-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
IndepthTutorial
In this tutorial we set up a project with multiple targets, unit tests and dependencies between targets. Our main product is a shared library called foo that is written in C++11. We are going to ignore the contents of the source files, as they are not really important from a build definition point of view.
The source tree contains three subdirectories src, include and test that contain, respectively, the source code, headers and unit tests of our project.
To start things up, here is the top level meson.build file.
project('c++ foolib', 'cpp')
add_global_arguments('-std=c++11', language : 'cpp')
inc = include_directories('include')
subdir('src')
subdir('test')
First we define the project's name and the programmin languages it uses (in this case only C++). Then we add a global compiler argument -std=c++11. This flag is used for all C++ source file compilations. It is not possible to unset it for some targets. The reason for this is that it is hard to keep track of what compiler flags are in use if global settings change per target.
Since include directory contains the header files, we need a way to tell compilations to add that directory to the compiler command line. This is done with the include_directories command that takes a directory and returns an object representing this directory. It is stored in variable inc which makes it accessible later on.
After this are two subdir commands. These instruct Meson to go to the specified subdirectory, open the meson.build file that's in there and execute it.
All documentation is now on the main web site.
This page should be at this address.