How do I set basic options with meson?
Asked Answered
B

1

15

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?

Breeches answered 23/8, 2020 at 16:21 Comment(2)
@blubase: Can you post a link to that issue please? Also, make that an answer?Breeches
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.Darkroom
D
18

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
Darkroom answered 24/8, 2020 at 9:59 Comment(4)
Why reconfigure rather than configure?Breeches
reconfigure is used to change an already existing build dir. meson configure just shows the current setup, as far as i understand.Darkroom
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.Darkroom
"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.Australorp

© 2022 - 2024 — McMap. All rights reserved.