[CMake] CMake, RPATH and installs for distribution of a commercial tool

gga ggarra at advancedsl.com.ar
Thu Jul 5 11:29:31 EDT 2007


I have a commercial application I'm developing and one feature of cmake
is throwing me off.  Or, put another way, I'm not quite sure how I can
take advantage of it to make it work the way I want.

Basically, by default cmake creates executables using the -rpath
directive.  This is great if you are going to do a local install later
on, like when you do make install.  That will force a relinking.

However, for deploying a commercial application, I really cannot rely on
 make install.  At the same time, to avoid users' confusions and
potential library conflicts, I want to distribute the libraries used by
my executable into its own platform/lib directory and then just set the
LD_LIBRARY_PATH appropriately with a wrapper script, so that the libs I
distribute are picked first.  At the same time, I do need to copy all
the libs I'm using into my own libs directory for distribution.
A similar issue with this is the current lack of cmake to allow linking
some libraries statically, while others are linked dynamically (which
I'd also like to also avoid having to dist so many .so files).

Now, the problem with make install and cpack, from what I saw, is that
they seem to assume a very simple install a la GNU (and lack some of the
features I need).  My application requires a somewhat more complex
distribution of files as some are cross platform and some are not.  As
such, I'm using a third party tool for the packaging of the files for
installation (installjammer, which is cross platform).
I do need to copy all the stuff from my build or development dirs onto a
clean preinstall/prepackage location for the third party packaging tool,
which I'm currently doing with some special cmake targets.

My problem is:
	- If I leave rpath on, my executable in the build directory is linked
against incorrect paths of libraries (some are in /usr/local or
development directories), so I cannot just copy it.
	- If I turn off rpath with CMAKE_SKIP_RPATH, I obtain more or less the
behavior I want.  However, the link libraries (as shown by ldd) are
versioned (which is good), but I have to specifically copy the version
of the library like libfoo.5, instead of just copying the symlink for
libfoo.  This seems also error prone, as RPATH already fixes all that
stuff for you to make sure no wrong library is used, and I really don't
want to write my own code to figure out what version of the library
should be copied for distribution.

So... I'm figuring I'm missing something pretty obvious here, as this
should be much easier than this.

-- 
Gonzalo Garramuño
ggarra at advancedsl.com.ar

AMD4400 - ASUS48N-E
GeForce7300GT
Kubuntu Edgy


More information about the CMake mailing list