[CMake] Alternatives to INSTALL_RPATH for linking to internal libraries on install

Clinton Stimpson clinton at elemtech.com
Fri May 14 11:56:21 EDT 2010


On 05/14/2010 09:14 AM, Sam Spilsbury wrote:
> Hi,
>
> I'm working for the Compiz project[1] and have just finished
> implementing a CMake buildsystem.
>
> Currently, we are linking "plugins" to an executable and various
> internal libraries by passing their paths within the build tree to
> library_dirs (). While this shows up in the linker command line
> correctly, it seems that the libraries don't actually link (upon
> inspection with ldd).
>
> The only solution I've found so far is to use something like:
>
> 	set_target_properties (
> 	    ${plugin} PROPERTIES
> 	    INSTALL_RPATH_USE_LINK_PATH 1
>              BUILD_WITH_INSTALL_RPATH 1
>              SKIP_BUILD_RPATH 0
> 	    COMPILE_FLAGS "${${_PLUGIN}_CFLAGSADD}"
> 	    LINK_FLAGS "${${_PLUGIN}_LDFLAGSADD}"
> 	)
>
> See [2]
>
> and
>
>      set_target_properties (
>        ${plugin} PROPERTIES
>        INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib
>      )
>
> See [3]
>
> Unfortunately, fedora and debian both strictly prohibit the use of
> rpath in their packaging guidelines. Is there any way I could get
> these libraries to link properly without the use of setting RPATH?
>
> Kind Regards,
>
> Sam.
>
> [1] www.compiz.org
> [2] http://git.compiz.org/compiz/core/tree/cmake/CompizPlugin.cmake#n384
> [3] http://git.compiz.org/compiz/core/tree/plugins/decor/CMakeLists.txt#n7
>
>    

Linux distributions typically use ld.so.conf or manual methods instead 
of rpaths.  For plugins, it could be manual by doing a dlopen() with an 
absolute path.  But I'm curious if they also disallow using $ORIGIN in 
the rpath.
You could let cmake do normal rpath stuff in your build directory, then 
use a non-rpath solution when installed.

Clint



More information about the CMake mailing list