Avi Shukron
Avi Shukron

Reputation: 6118

How can I tell meson in which directories to look for dependencies?

I am coming from CMake to meson. I like to work in isolated environments using conda. This way I can control which packages are installed for each project.

Now, In cmake I would pass -DCMAKE_FIND_ROOT_PATH=$CONDA_PREFIX in order to root the search process on a different directory (In my case - the conda env)

So my question is how do I do achieve the same effect on meson?

This is my small meson.build for reference:

project('foo', 'cpp')

cpp = meson.get_compiler('cpp')
spdlog = cpp.find_library('spdlog')

executable('foo',
  'src/fact.cpp',
  dependencies : [spdlog])

Upvotes: 4

Views: 1630

Answers (2)

kpeace
kpeace

Reputation: 11

meson receives the parameter

--pkg-config-path path

which will add path to the pkg-config search path.

Adding

spdlog = dependency('spdlog')

Will find spdlog as long as the .pc file is in path

Upvotes: 1

Avi Shukron
Avi Shukron

Reputation: 6118

meson is smart enough to find packages inside conda env, assuming that you have pkg-config or cmake installed in said env.

Also - the correct way to add external dependency is using dependency('spdlog') and not find_library.

So the fixed meson.build should look like:

project('foo', 'cpp')

spdlog = dependency('spdlog')

executable('foo',
  'src/fact.cpp',
  dependencies : [spdlog])

Upvotes: 2

Related Questions