The humble beginning
main.c
The c source is:
#include<stdio.h>
int main(int argc, char **argv) {
printf("Hello there.\n");
return 0;
}
meson.build
meson.build
is the file which describes the relationships between source files and buildable objects.
project('tutorial', 'c')
executable('demo', 'main.c')
Building
In the directory where meson.build
is located, the meson
compiler(?) needs to be invoked:
$ meson builddir
This command creates the directory builddir
in which ninja is used to compile the project:
$ cd builddir
$ ninja
$ ./demo
Nice features
Meson seems to have a few nice features. The following meson.build
script determines the version of the c compiler and issues a message if it is smaller than 7.0.0
:
project('nice-features', 'c')
c=meson.get_compiler('c')
c_version = c.version()
message('compiler version ' + c_version)
if c_version.version_compare('< 7.0.0')
message('Please upgrade to at least 7.0.0')
endif