command-linecommand-line-argumentsmeson-buildbuildconfiguration

How do I set basic options with meson?


I'm trying to configure a project with meson. Specifically, I'm trying to set some of the options.

meson config tells me, among other things:

Core options:
  Option          Current Value Possible Values                                          Description                                             
  ------          ------------- ---------------                                          -----------                                             
  buildtype       debug         [plain, debug, debugoptimized, release, minsize, custom] Build type to use                                       

Base options:
  Option      Current Value Possible Values                                               Description                                   
  ------      ------------- ---------------                                               -----------                                   
  b_lto       false         [true, false]                                                 Use link time optimization                    

(other options were clipped from this printout of course.)

So, I write:

meson build . --buildtype=release

in my build directory, and this goes fine - no warnings or errors (I double-checked that the option value had changed). Then I write:

meson build . --b_lto=true

but this gets me:

meson: error: unrecognized arguments: --b_lto=true

I also tried -b_lto=true, --b_lto true, b_lto=true and b_lto true. And all of those without the true value. No luck.

How do I set these "base options" then?


Solution

  • The --option=value, and --option value styles to pass arguments only applies to the universial options section in meson's manual...so not to base options, and others. Instead use the -Doption=value syntax to set options. It is the suggested way, since meson setup --help declares [-D option] to be used for setting all sorts of options. See this answer by the meson team. So, in your case run:

    meson build . -Db_lto=true
    

    or

    meson configure build -Db_lto=true
    

    If the build directory changed since the last configure use reconfigure instead.

    meson reconfigure build -Db_lto=true
    

    or explicitly:

    meson setup --reconfigure -Db_lto=true build