[CMake] RPATH for external library

Patrick Boettcher patrick.boettcher at posteo.de
Wed May 17 05:55:24 EDT 2017


On Tue, 16 May 2017 12:32:11 -0700
Pawel Veselov <pawel.veselov at gmail.com> wrote:

> > I was once in a situation where I could have used pkg-config with a
> > custom path to have pkg-config look for the .pc-file. I then
> > switched to find_library with the custom-path slightly adapted and
> > it worked at least as good as with pkg-config, if not better. For
> > my case.  
> 
> Right. My reason of preferring pkg-config is because it may have all
> other kind of stuff in it that the maintainer thought is necessary.
> I'd imagine some .pc files export a boatload of flags for all 3
> stages, and I rather not ignored them. It is also quite important
> when there are chained dependencies. 

Understandable. 

If I understand things correctly, pkg-config does not return the
RPATH-arguments necessary to link with. IOW, if used in a GNU
Makefile you would also need to add these by yourself, right? So your
problem is not a cmake-problem.

If this is the case, what you're looking for is a macro/script which
transforms -l and -L-arguments to the fully-qualified filename. That
should be doable with a combination of string(SUBSTRING) and
find_library() - if you dare ;-) .

> AFAIU, find_library() is not
> capable of tracking down dependencies.

No, find_library only returns the (complete) filename of a library
found via its arguments.

--
Patrick.


More information about the CMake mailing list