4

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])
Avi Shukron
  • 6,088
  • 8
  • 50
  • 84

2 Answers2

2

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])
Avi Shukron
  • 6,088
  • 8
  • 50
  • 84
  • Should be noted this won't work for every `conda` package, because some package doesn't provide a `.pc` file. – tmms Jun 04 '20 at 14:26
1

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

kpeace
  • 11
  • 2