Skip to content

dependency(components: ) not ignored for fallback located with dependency_names #14979

Description

@bgilbert

Describe the bug
HarfBuzz has:

# pkg-config: icu-uc, cmake: ICU but with components
icu_dep = dependency('icu-uc', 'ICU',
                          version: icu_min_version,
                          components: 'uc',
                          required: get_option('icu'),
                          allow_fallback: true)

It obviously intends components to only be used in the CMake case, and the docs here and here strongly suggest that's the intended behavior. If the icu wrap has:

[provide]
icu-uc = icuuc_dep

this works. But if it has:

[provide]
dependency_names = icu-uc

setup fails with:

harfbuzz| WARNING: Subproject 'icu' did not override 'icu-uc' dependency and no variable name specified
harfbuzz| Dependency icu-uc from subproject subprojects/icu found: NO

subprojects/harfbuzz-11.4.5/meson.build:155:10: ERROR: Dependency 'icu-uc' is required but not found.

Note that ICU's meson.build calls meson.override_dependency('icu-uc', icuuc_dep) in both cases.

To Reproduce
meson.build:

project('a', 'c')
dependency('b', components: 'foo')

subprojects/b/meson.build:

project('b', 'c')
b_dep = declare_dependency()
meson.override_dependency('b', b_dep)

Fails if subprojects/b.wrap is missing (using the implicit provide for the wrap name) or if it contains:

[wrap-file]

[provide]
dependency_names = b

Succeeds if subprojects/b.wrap contains:

[wrap-file]

[provide]
b = b_dep

Expected behavior
components only affects library matching with CMake.

system parameters

  • Is this a cross build or just a plain native build (for the same computer)?
    native

  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.)
    macOS 15

  • what Python version are you using e.g. 3.8.0
    3.12.10

  • what meson --version
    1.9.0 (also 1.8.3)

  • what ninja --version if it's a Ninja build
    1.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions