[CMake] Buils executable vs Installed executable

Nils Gladitz nilsgladitz at gmail.com
Fri Feb 13 05:28:49 EST 2015


On 02/12/2015 06:40 PM, Sergio Vera wrote:
> Dear CMake users,
>
> I'm developing an app using CMake in Fedora 20 and so far it's working
> properly in the build directory.
> However, I've recently added some Install target commands so I can
> prepare it for packaging with CPack.
> However, when I "make install" my app, the application no longer runs
> and complains about missing shared libraries.
>
> With ldd I can see that the binary in my build dir do references system
> libraries and my 3rd party dependencies, which I have built with cmake
> too (CTK and VTK)
>
> However my Install folder binary does  not list any shared library to my
> CTK or VTK libs.
>
> I'm a bit puzzled by this behavior... Copying the build binary to the
> install folder works, but still I would like to know what is missing here.

The default behavior on Linux is that CMake manages two sets of RPATHs; 
build time and install time.

The build time RPATHs are autogenerated to conveniently allow you to run 
your binaries from your build tree.

At installation time the build time RPATHs are replaced with 
installation time RPATHs (which per default are empty).

This is since when you deploy your applications you don't normally want 
RPATHs that refer to locations which are only valid on your own 
development system.

You can adjust the behavior with the CMake variables that have RPATH in 
their name [1].

Assuming you only intend to deploy locally and your shared libraries 
aren't being added to the installation itself 
INSTALL_RPATH_USE_LINK_PATH [2]  might be what you are looking for.

Nils

[1] http://www.cmake.org/cmake/help/v3.1/manual/cmake-variables.7.html

[2] 
http://www.cmake.org/cmake/help/v3.1/variable/CMAKE_INSTALL_RPATH_USE_LINK_PATH.html


More information about the CMake mailing list