Skip to content

override_dependency does not check linked lib's type #15371

@mochaaP

Description

@mochaaP

Describe the bug
When overriding a dependency as static/shared only, it does not check if all the linked library target are static/shared.

To Reproduce

project('static-test', 'c')

lib = shared_library('shared', 'test.c')

meson.override_dependency(
    'dep',
    declare_dependency(link_with: lib, compile_args: '-DSHARED'),
    static: false,
)
meson.override_dependency(
    'dep',
    declare_dependency(link_with: lib, compile_args: '-DSTATIC'),
    static: true,
)

exe = executable('exe', 'main.c', dependencies: dependency('dep', static: true))

Expected behavior
second override_dependency will fail silently (as if the passed lib was a disabler), and the dependency call fails.
this behavior enables exporting targets with different linkage settings (e.g. __declspec(dllexport/dllimport)) under the same name, which is required by many projects on Windows.

system parameters
reproducible on all

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions