[CMake] Macro to turn list of librarys into list of dirs?

Jeremy Selan jeremy.selan at gmail.com
Wed Jan 26 22:08:25 EST 2011


Hello!

I have a real newbie question here.  It's possible this was already
answered, but I tried searching the archives and could not find
anything.

I have an application that links to a few libraries, some of which are
in the system install locations and some of which aren't.
I would like the rpath for some of the targets, when installed, to
include only the non-system installed paths.

I played around with using INSTALL_RPATH_USE_LINK_PATH, which almost
does what I need but also includes things in the system path. I then
looked into filtering this rpath based on
CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES, but based on other threads
this appears to be ill advised.

As an alternative, it now seems sensible to explicitly craft the
INSTALL_RPATH with just the locations I want to include, but
unfortunately I dont have the directory names.  Instead, I only a
string containint the list of .so library locations.

Does anyone know a macro (or builtin function), that given a variable
with a list of full library paths, will return a list of directories?
The implementation of INSTALL_RPATH_USE_LINK_PATH must be doing the
equivalent internally...

(python psedocode):
mylibraries = [ "/a/b/c/d", "/x/y"]
mydirs = [os.path.dirname(s) for s in mylibraries]

If I'm going about this the wrong way and anyone has suggestions on
how to make the process simpler, please let me know as well.

Thanks!

-- Jeremy


More information about the CMake mailing list