Search code examples
cmakepkg-configmeson-buildbuild-dependenciesmpv

How do I tell meson setup about the location of a dependency?


I'm trying to build celluloid, which uses meson. I ran meson, but it failed to find an appropriate version of mpv:

Determining dependency 'mpv' with pkg-config executable '/usr/bin/pkg-config'
Called `/usr/bin/pkg-config --modversion mpv` -> 1

Found CMake: /usr/bin/cmake (3.13.4)

Determining dependency 'mpv' with CMake executable '/usr/bin/cmake'
Try CMake generator: auto
Called `/usr/bin/cmake --trace-expand -DNAME=mpv .` in /tmp/celluloid-0.20/build/meson-private/cmake_mpv -> 0
Dependency mpv found: NO (tried pkgconfig and cmake)

src/meson.build:125:0: ERROR:  Dependency "mpv" not found, tried pkgconfig and cmake

so I downloaded and built the latest mpv release (0.33.0), built and installed it at /opt/mpv.

Now - how do I tell meson to take mpv from this new path?

Note: The relevant snippet of the meson files seems to be:

executable('celluloid', sources,
  dependencies: [
    libgtk,
    libgio,
    meson.get_compiler('c').find_library('m', required: false),
    dependency('mpv', version: '>= 1.107'),
    dependency('epoxy')
  ],
  link_with: extra_libs,
  include_directories: includes,
  c_args: cflags,
  install: true
)

Solution

  • You tell meson about your dependency by letting pkgconfig know about your dependency...

    and that can be done by adding your dependency's path to the PKG_CONFIG_PATH environment variable; it is delimited by colons, just like PATH, e.g. /opt/foo:/opt/extra/baz.

    Remember that you may also need to add associated paths to LD_LIBRARY_PATH after building and installing with a custom-built directory.