meson-build

Read a variable from commandline in meson


In my meson.build:

project('coolproject', 'c', version : '1.0.0.0', default_options : ['warning_level=3'])
message('USE_CAIRO=' + get_option('USE_CAIRO'))

I'm trying to read USE_CAIRO like this:

meson setup -DUSE_CAIRO=TRUE --reconfigure

But I get: ERROR: Unknown options: "USE_CAIRO" . Any ideas about how to read custom command line variables?


Solution

  • User options must be declared in meson.options file first:

    # meson.options
    option('USE_CAIRO', type : boolean, value : true)
    

    Here true is only default value that may be redefined by specific build.