Custom paths and search orders for find_library

681 views
Skip to first unread message

Axel Waggershauser

unread,
Jan 27, 2015, 8:58:02 PM1/27/15
to meson...@googlegroups.com
Hi Jussi,

I ran into a problem while converting a cmake project to meson: the cmake version of find_library allows for specifying a custom search path and also to inhibit searching the default library paths altogether. Looking at the meson code, I could not find a similar option. I also wondered if you deliberately chose to first look into /usr/lib* paths and only then into /usr/local/lib*, where I would have expected the latter to be preferred?

Is there a way to extend the list of meson search paths for libaries (or programs or includes or ...) that I overlooked? If not, how would that best be implemented?

My use case is the dependency on a modified libgphoto2 library that I can't install in a standard path where it would interfere with my normal desktop system but I would like to prevent the need to setup a full blown chroot environment or virtual machine for the build-step. This use case is probably some overlap with a cross-compile use case.

Regards,
  Axel

Jussi Pakkanen

unread,
Jan 28, 2015, 4:54:31 PM1/28/15
to Axel Waggershauser, meson...@googlegroups.com
On Wed, Jan 28, 2015 at 3:58 AM, Axel Waggershauser <awa...@gmail.com> wrote:
 
I ran into a problem while converting a cmake project to meson: the cmake version of find_library allows for specifying a custom search path and also to inhibit searching the default library paths altogether. Looking at the meson code, I could not find a similar option. I also wondered if you deliberately chose to first look into /usr/lib* paths and only then into /usr/local/lib*, where I would have expected the latter to be preferred?

Is there a way to extend the list of meson search paths for libaries (or programs or includes or ...) that I overlooked? If not, how would that best be implemented?

At the moment there is no way to specify your own search paths. This is something that we need to fix. However note that it is very much recommended to not use raw library finds unless you really need to. As an example in your case:
 
My use case is the dependency on a modified libgphoto2 library that I can't install in a standard path where it would interfere with my normal desktop system but I would like to prevent the need to setup a full blown chroot environment or virtual machine for the build-step. This use case is probably some overlap with a cross-compile use case.

I looked and gphoto2 provides a pkg-config file that should have all the correct compiler arguments for wherever you installed it. To use that you only need to tell pkg-config where to search for it. So something like this when first setting up your build:

PKG_CONFIG_PATH=/path/to/your/custom/gphoto/install meson ..

The raw library find calls should only be needed when dealing with libraries that don't provide pkg-config files or on platforms where pkg-config does not work (i.e. Windows, OSX without homebrew etc).

Jussi Pakkanen

unread,
Jan 28, 2015, 5:39:13 PM1/28/15
to Axel Waggershauser, meson...@googlegroups.com
On Wed, Jan 28, 2015 at 3:58 AM, Axel Waggershauser <awa...@gmail.com> wrote:
 
I also wondered if you deliberately chose to first look into /usr/lib* paths and only then into /usr/local/lib*, where I would have expected the latter to be preferred?

There is no particular reason. That's just the order in which I wrote them at the time. If there are reasons to alter the search order then it can be changed quite easily.

Axel Waggershauser

unread,
Jan 30, 2015, 7:52:31 AM1/30/15
to meson...@googlegroups.com, awa...@gmail.com
Thanks for the feedback on using PKG_CONFIG_PATH. It works and is indeed a lot cleaner than what I had in mind.

I just would expect to have stuff in /usr/local to be of higher priority, since as a devloper that is usually something I added manually and on purpose because the standard package was too old or something like that.

 - A

Jussi Pakkanen

unread,
Jan 30, 2015, 2:32:46 PM1/30/15
to Axel Waggershauser, meson...@googlegroups.com
On Fri, Jan 30, 2015 at 1:52 PM, Axel Waggershauser <awa...@gmail.com> wrote:
 
I just would expect to have stuff in /usr/local to be of higher priority, since as a devloper that is usually something I added manually and on purpose because the standard package was too old or something like that.

I fixed this but am currently in a network that blocks git pushes. Will push it out as soon as I get to a place with a decent net connection.
 
Reply all
Reply to author
Forward
0 new messages