diff options
author | Thibault Saunier <thibault.saunier@osg.samsung.com> | 2017-03-29 15:03:43 -0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-04-26 17:56:33 +0300 |
commit | b371875e02cce2fb3fbb9fbb8f07eb5817ae0e8f (patch) | |
tree | 6e1a3c34b1a85479d3b9f42ccd071096e637929b /docs/markdown/Build-options.md | |
parent | 7dc747ea54480c452b913e4bfe682ec67061c9bf (diff) | |
download | meson-b371875e02cce2fb3fbb9fbb8f07eb5817ae0e8f.zip meson-b371875e02cce2fb3fbb9fbb8f07eb5817ae0e8f.tar.gz meson-b371875e02cce2fb3fbb9fbb8f07eb5817ae0e8f.tar.bz2 |
docs: Import the website and wiki and build with hotdoc
This allows us to more easily have the documentation in sync with
the source code as people will have to document new features etc
right at the time where they implement it.
Diffstat (limited to 'docs/markdown/Build-options.md')
-rw-r--r-- | docs/markdown/Build-options.md | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/docs/markdown/Build-options.md b/docs/markdown/Build-options.md new file mode 100644 index 0000000..64e2d38 --- /dev/null +++ b/docs/markdown/Build-options.md @@ -0,0 +1,31 @@ +# Build options + +Most non-trivial builds require user-settable options. As an example a program may have two different data backends that are selectable at build time. Meson provides for this by having a option definition file. Its name is `meson_options.txt` and it is placed at the root of your source tree. + +Here is a simple option file. + +```meson +option('someoption', type : 'string', value : 'optval', description : 'An option') +option('other_one', type : 'boolean', value : false) +option('combo_opt', type : 'combo', choices : ['one', 'two', 'three'], value : 'three') +``` + +This demonstrates the three basic option types and their usage. String option is just a free form string and a boolean option is, unsurprisingly, true or false. The combo option can have any value from the strings listed in argument `choices`. If `value` is not set, it defaults to empty string for strings, `true` for booleans or the first element in a combo. You can specify `description`, which is a free form piece of text describing the option. It defaults to option name. + +These options are accessed in Meson code with the `get_option` function. + +```meson +optval = get_option('opt_name') +``` + +This function also allows you to query the value of Meson's built-in project options. For example, to get the installation prefix you would issue the following command: + +```meson +prefix = get_option('prefix') +``` + +It should be noted that you can not set option values in your Meson scripts. They have to be set externally with the `mesonconf` command line tool. Running `mesonconf` without arguments in a build dir shows you all options you can set. To change their values use the `-D` option: + +```console +$ mesonconf -Doption=newvalue +``` |