Piotr Zych
Piotr Zych

Reputation: 503

How to force meson to use only wrap subproject

I have a few subprojects defined in wrap files in the subprojects directory and declared in the meson.build file. Unfortunately I am forced to have some of the subprojects installed on my host system. Meson by default checks if a subproject is installed in the host os filesystem then eventually downloads and builds the subproject if it is unavailable. How to force meson to not use system libraries/headers but to always download/build subprojects independently in own build directory and link it during compilation?

subprojects/xyz.wrap:

[wrap-git]
url = https://github.com/bar/xyz.git
revision = HEAD

[provide]
xyz = xyz_dep

meson.build:

xyz = dependency('xyz')
...
deps = [
    ...
    xyz
    ...
]
executable(foo, dependencies: deps)

Upvotes: 3

Views: 3347

Answers (3)

Daniel C Jacobs
Daniel C Jacobs

Reputation: 751

The force-fallback option that @joshua-taylor-eppinette suggested is the correct option if you are building a meson project that someone else wrote.

If this is your own meson project (which seems to be the case), a better approach would be to not use dependency('xyz'), as by definition dependency will look in your installed system packages before falling back to a subproject.

If you want to always use the subproject dependency instead of a system package, replace dependency('xyz') with subproject.get_variable:

subproject('xyz').get_variable('xyz_dep')

Upvotes: 2

thomas
thomas

Reputation: 536

You can also force fallback of all dependencies with -Dwrap_mode=forcefallback.

See meson options : https://mesonbuild.com/Builtin-options.html#core-options

Upvotes: 0

You can force a dependency to fallback to its local subprojects version using --force-fallback-for=<dependency_name> during meson setup ....

For example, I have SDL2 installed as a system package, but I can use the WrapDB version with the following command:

meson setup build --force-fallback-for=sdl2

Reference:

Upvotes: 4

Related Questions