Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subproject default_options are ignored #6728

Open
shdnx opened this issue Mar 3, 2020 · 15 comments
Open

Subproject default_options are ignored #6728

shdnx opened this issue Mar 3, 2020 · 15 comments

Comments

@shdnx
Copy link

shdnx commented Mar 3, 2020

Describe the bug

The 'default_options' argument to 'subproject()' seems to be ignored.

To Reproduce

Main meson.build:

...
libfoo = subproject('libfoo', default_options: [ 'BUILD_TESTS=false' ])
...

Libfoo meson.build:

...
if get_option('BUILD_TESTS')
    message('Building unit tests')
    subdir('tests')
endif
...

Libfoo meson_options.txt:

option('BUILD_TESTS', type: 'boolean', value: true)

Then:

rm -rf ./build
meson ./build

Tests are built, the default_options setting is ignored. meson configure shows 'libfoo:BUILD_TESTS = true'.

To achieve desired behaviour, the option has to be specified from the command line:

rm -rf ./build
meson ./build -D libfoo:BUILD_TESTS=false

Expected behavior

Don't ignore subproject() default_options.

system parameters

  • Plain native build
  • Oracle Linux 7.7
  • Python version: 3.7.4
  • Meson version: 0.53.1
  • Ninja version: 1.9.0
@Akaricchi
Copy link
Contributor

This seems to be a long-standing issue. As a workaround you can put all default options for your subprojects in the superproject's project() statement, like so:

project('taisei', 'c',
    license : 'MIT',
    version : 'v1.4-dev',
    meson_version : '>=0.48.0',
    default_options : [
        # Should really be c11, but gnu11 is a safer default because everything is terrible.
        'c_std=gnu11',

        'default_library=static',

        'libzip:enable_crypto=false',
        'libzip:enable_bzip2=false',

        'sdl2:use_haptic=disabled',
        'sdl2:use_power=disabled',
        'sdl2:use_render=disabled',
        'sdl2:use_sensor=disabled',

        # You may want to change these for a debug build dir
        'buildtype=release',
        'strip=true',
        'b_lto=true',
        'b_ndebug=if-release',
    ]
)

@shdnx
Copy link
Author

shdnx commented Mar 6, 2020

@Akaricchi Thank you very much for the workaround, that's not too bad!

@haata
Copy link

haata commented Jul 21, 2020

As a data point, this workaround hasn't been working for me with meson 0.55.0.
The toplevel project sets c_std=c99 and the subproject should be setting c_std=gnu99, but for some reason isn't set.

@Akaricchi
Copy link
Contributor

I don't think it's possible to have a per-project c_std unless you override it in every build target, because it's a global option. It's a deliberate design choice (that I don't agree with). In my opinion c_std doesn't even make sense as a user-settable option at all.

@xclaesse
Copy link
Member

It will be changed to per subprojects option, there is a wip branch there: #6729.

@phillipjohnston
Copy link
Contributor

Is it still the case that default_options are ignored in subprojects?

@dcbaker
Copy link
Member

dcbaker commented Oct 22, 2020

@phillipjohnston Right now only a couple of options are allowed on a per-project basis: default_library, werror (and one more I can't remember off the top of my head). We keep adding more over time, but other ones are ignored, yes.

@phillipjohnston
Copy link
Contributor

phillipjohnston commented Oct 22, 2020

@dcbaker, thanks for that note. Here, I was specifically referring to default_options as passed to a subproject() call. Sorry for being vague!

libfoo = subproject('libfoo', default_options: [ 'BUILD_TESTS=false' ])

@dcbaker
Copy link
Member

dcbaker commented Oct 22, 2020

I think you should be able to pass user options via default_options, but @xclaesse probably knows better.

@BarabashkaD
Copy link

in addition any user defined common options between superproject and subproject doesn't passed
let say both projects have in meson_options.txt
option('product-type', type : 'string', value : 'l4',yield : true, description : 'Product type l4/l3')
and super projects setup as
meson setup -Dproduct-type=l3 .\build
in configure I get

....
  product-type          l3                                                                             Product type l4/l3
                                                                                                           
Subproject test-proj:                                                                                    
                                                                                                           
  Project options       Current Value        Possible Values                                               Description
  ---------------       -------------        ---------------                                               -----------
  product-type          l4                                                                              Product type l4/l3

@phillipjohnston
Copy link
Contributor

Do you have yield: true set for that option in the subproject?

@BarabashkaD
Copy link

yes as in my example

@phillipjohnston
Copy link
Contributor

Sorry... I missed that, I put it at the end in mine, so my brain went right past it :)

@BarabashkaD
Copy link

any idea ?

@ocrete
Copy link

ocrete commented Jun 13, 2022

Is it possible to add a warning/error for any options that are ignored ?

jlindgren90 added a commit to jlindgren90/wlroots that referenced this issue Oct 15, 2023
These are normally set in labwc's meson.build, but for some reason that
isn't working correctly with subproject().

Possibly related:
mesonbuild/meson#6728
jlindgren90 added a commit to jlindgren90/wlroots that referenced this issue Oct 21, 2023
These are normally set in labwc's meson.build, but for some reason that
isn't working correctly with subproject().

Possibly related:
mesonbuild/meson#6728
jlindgren90 added a commit to jlindgren90/wlroots that referenced this issue Oct 25, 2023
These are normally set in labwc's meson.build, but for some reason that
isn't working correctly with subproject().

Possibly related:
mesonbuild/meson#6728
jlindgren90 added a commit to jlindgren90/wlroots that referenced this issue Oct 27, 2023
These are normally set in labwc's meson.build, but for some reason that
isn't working correctly with subproject().

Possibly related:
mesonbuild/meson#6728
jlindgren90 added a commit to jlindgren90/wlroots that referenced this issue Nov 27, 2023
These are normally set in labwc's meson.build, but for some reason that
isn't working correctly with subproject().

Possibly related:
mesonbuild/meson#6728
jlindgren90 added a commit to jlindgren90/wlroots that referenced this issue Nov 29, 2023
These are normally set in labwc's meson.build, but for some reason that
isn't working correctly with subproject().

Possibly related:
mesonbuild/meson#6728
jlindgren90 added a commit to jlindgren90/wlroots that referenced this issue Feb 14, 2024
These are normally set in labwc's meson.build, but for some reason that
isn't working correctly with subproject().

Possibly related:
mesonbuild/meson#6728
jlindgren90 added a commit to jlindgren90/wlroots that referenced this issue Feb 16, 2024
These are normally set in labwc's meson.build, but for some reason that
isn't working correctly with subproject().

Possibly related:
mesonbuild/meson#6728
jlindgren90 added a commit to jlindgren90/wlroots that referenced this issue Apr 8, 2024
These are normally set in labwc's meson.build, but for some reason that
isn't working correctly with subproject().

Possibly related:
mesonbuild/meson#6728
jlindgren90 added a commit to jlindgren90/wlroots that referenced this issue Apr 27, 2024
These are normally set in labwc's meson.build, but for some reason that
isn't working correctly with subproject().

Possibly related:
mesonbuild/meson#6728
jlindgren90 added a commit to jlindgren90/wlroots that referenced this issue Jul 6, 2024
These are normally set in labwc's meson.build, but for some reason that
isn't working correctly with subproject().

Possibly related:
mesonbuild/meson#6728
jlindgren90 added a commit to jlindgren90/wlroots that referenced this issue Jul 18, 2024
These are normally set in labwc's meson.build, but for some reason that
isn't working correctly with subproject().

Possibly related:
mesonbuild/meson#6728
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants