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

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


Hi Brad,

On Wed, Jun 5, 2013 at 8:55 AM, Brad King <brad.king at kitware.com> wrote:
> On 06/05/2013 01:07 AM, Ondřej Čertík wrote:
>> -- 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"
>
> This is expected.  CMake builds with the rpath for the build tree
> and that is not valid for the install tree.

Ah I see. I found a very nice explanation here:

http://www.cmake.org/Wiki/CMake_RPATH_handling

>  If you want to set the
> rpath for the install tree for all targets then use
>
>  -DCMAKE_INSTALL_RPATH:STRING="/first/path:/second/path"
>
> Then instead of removing the rpath during install CMake will replace it
> with this value.  This should work for the python modules too.

I have added the following line into my cmake call:

-DCMAKE_INSTALL_RPATH:STRING="$ARTIFACT/lib;$MESA/lib;$PYTHON/lib" \

(I used ; instead of :, as that is what the man page says.) This fixes
it for all .so, except
Python modules. I think the reason is that the Python modules are
installed with setup.py.
I know there is an option VTK_INSTALL_PYTHON_USING_CMAKE, but I am not sure
if it still works, as the inside of the if statement is commented out:

https://github.com/Kitware/VTK/blob/df6856c48ba1429c11e78baf8d3b317b9e56fe56/Wrapping/Python/CMakeLists.txt#L354

So for the Python modules I just fix it using patchelf and things work
great. The only other way that I am aware of is to use
the CMAKE_BUILD_WITH_INSTALL_RPATH = TRUE, because then even the
Python modules should get the correct RPATH, but then the problem is
that I need to set LD_LIBRARY_PATH during the build, as at buildtime,
the libraries must still be able to load (I think I got build failures
otherwise). And that's a messy solution. Patchelf is a much cleaner
solution, until cmake or VTK buildsystem gets fixed to do the Python
modules automatically.

By reading the wiki above, I realized that the canonical way to handle
RPATH is actually to use the following options:

    -DCMAKE_INSTALL_RPATH:STRING="$ARTIFACT/lib" \
    -DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON \

Which is equivalent to my line above, but cmake handles the Mesa and
Python paths (and any other path that I might be using!)
automatically. I tried too it and it works.

Ondrej



More information about the vtkusers mailing list