[CMake] cmake install and rpath

James Bigler bigler at cs.utah.edu
Wed Oct 17 09:57:46 EDT 2007


I tried digging through through the mailing list and experimenting on  
my own, but I don't seem to be able to figure this out.

I have a toy project that has a shared library and an executable.   
I've set it up, so that it can be installed to what ever the  
CMAKE_INTALL_PREFIX is which works fine.  The installed executable is  
relinked before installing to have the correct RPATH.

I tried to use CPack with the TGZ target and it created a tar ball  
with bin and lib, but the executable still had $ 
{CMAKE_INSTALL_PREFIX}/lib linked.  I would have assumed that  
something would have relinked my executable to contain a relative  
path to the library based on the CMAKE_INSTALL_PREFIX.

I'm using CMake 2.4.6 on Linux.

Thanks,
James

This is the CMakeLists.txt file I'm using:

PROJECT (Narf)

SET(BUILD_SHARED_LIBS ON CACHE BOOL "Building shared or static  
libraries")

MESSAGE("CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")
MESSAGE("INSTALL_RPATH = ${INSTALL_RPATH}")

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})

ADD_LIBRARY(narfencode encode.cc encode.h)

ADD_EXECUTABLE(narf main.cc)
TARGET_LINK_LIBRARIES(narf narfencode)

SET_TARGET_PROPERTIES(narf
   PROPERTIES BUILD_WITH_INSTALL_RPATH OFF
   INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib
   INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/bin
   )

INSTALL(TARGETS narf narfencode
   RUNTIME DESTINATION bin
   LIBRARY DESTINATION lib
   ARCHIVE DESTINATION lib
   )

INCLUDE(CPack)



More information about the CMake mailing list