[vtkusers] How to force cmake not to remove install rpath

Ondřej Čertík ondrej.certik at gmail.com
Wed Jun 5 01:07:32 EDT 2013


Hi,

I use VTK 6.0.0.rc2 and CMake 2.8.11. Here is how I install VTK:

$CMAKE/bin/cmake -DCMAKE_INSTALL_PREFIX:PATH="$ARTIFACT" \
    -DBUILD_TESTING:BOOL=OFF \
    -DBUILD_EXAMPLES:BOOL=OFF \
    -DOSMESA_LIBRARY:FILEPATH=$MESA/lib/libOSMesa.so \
    -DOSMESA_INCLUDE_DIR:PATH=$MESA/include \
    -DOPENGL_INCLUDE_DIR:PATH=$MESA/include \
    -DOPENGL_gl_LIBRARY:FILEPATH=$MESA/lib/libGL.so \
    -DPYTHON_EXECUTABLE:FILEPATH=$PYTHON/bin/python \
    -DPYTHON_INCLUDE_PATH:PATH=$PYTHON/include/python2.7 \
    -DPYTHON_LIBRARY:FILEPATH=$PYTHON/lib/libpython2.7.so \
    -DVTK_USE_X:BOOL=OFF \
    -DVTK_WRAP_PYTHON:BOOL=ON \
    -DVTK_USE_OFFSCREEN:BOOL=ON \
    -DVTK_OPENGL_HAS_OSMESA:BOOL=ON \
    .

make -j4
make install

and sometimes, cmake removes the install rpath as follows:

...
-- Installing: /auto/nest/nest/u/ondrej/repos/python-hpcmp2/opt/vtk/hfj6/lib/libvtkCommonDataModel-6.0.so
-- Removed runtime path from
"/auto/nest/nest/u/ondrej/repos/python-hpcmp2/opt/vtk/hfj6/lib/libvtkCommonDataModel-6.0.so.1"
...

from all dynamic libraries. I haven't yet figured out if this depends
on a cmake version or if it is a VTK issue (as it takes around 1h to
build vtk, so I can only do that many iterations).
One one machine it didn't remove the rpath paths and thus things work,
and on two other machines the paths get removed, and then the
libraries cannot be loaded at runtime (without LD_LIBRARY_PATH and
similar hacks). I *think* the only difference is the cmake version,
but maybe it is something else.

Is there a way to tell cmake to keep the install rpath in place?


My second question is about Python .so libraries --- those never have
the correct rpath setting. Is there a way to tell cmake to fix the
rpath for Python modules? Currently, I fix the rpath by hand as
follows:

find $ARTIFACT/$PYTHON_SITE_PACKAGES_REL/vtk/*.so | xargs -n1
$PATCHELF/bin/patchelf --set-rpath $ARTIFACT/lib:$MESA/lib:$PYTHON/lib

where I use the patchelf utility [1]. I can use this approach to fix
rpath for the C++ libraries as well, but it would be much better if
cmake did the right thing.

Many thanks for any tips.

Ondrej

[1] http://nixos.org/patchelf.html



More information about the vtkusers mailing list