Search code examples
meson-build

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)

Solution

  • 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: