13

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?

einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • @blubase: Can you post a link to that issue please? Also, make that an answer? – einpoklum Aug 24 '20 at 10:34
  • The meson team informed me, that actually, the `--option=value` and `--option value` style passing of arguments only applies to the information in the `universal options` but not the other group of objects, the manual was not explicit in this regard. I'll change my answer (again) to reflect his information. – blubase Aug 24 '20 at 12:32

1 Answers1

15

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

but, better use this ordering, since its specified this way in the manual (man meson).

meson -Db_lto=true build . 

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
blubase
  • 795
  • 7
  • 19
  • Why `reconfigure` rather than `configure`? – einpoklum Aug 24 '20 at 10:35
  • `reconfigure` is used to change an already existing build dir. `meson configure` just shows the current setup, as far as i understand. – blubase Aug 24 '20 at 10:43
  • 1
    Ok, i reread that part of the manual. Actually, in many cases `configure` and `reconfigure` do the same. Only if new options have been introduced since the last configure, just `meson configure build -D option=value` might not allow to set this new option, `reconfigure`, and explicitly `meson setup --reconfigure` do. – blubase Aug 24 '20 at 10:56
  • "better use this ordering, since its specified this way in the manual" -> Actually this ordering will lead to ```WARNING: Running the setup command as `meson [options]` instead of `meson setup [options]` is ambiguous and deprecated.``` – robertspierre Jun 04 '23 at 00:15