views:

116

answers:

1

Hi,

I am using CMake to build a program on linux. The program compiles successfully and runs from the project build directory. The program is linked with a custom library in the directory ${HOME}/build/lib

I have an install stage with:

install(TARGETS ProgName RUNTIME DESTINATION bin)

When I run make install the program gets put in the correct place, but the cmake installer removes the runtime path from the binary.

-- Install configuration: "Debug"
-- Installing: *binary name*
-- Removed runtime path from "*binary name*"

I have read articles on the internet discussing the misuse of the LD_LIBRARY_PATH variable so I like to keep mine limited to system library locations if possible. I am not sysadmin so I cannot add the location to the default linker search path either.

Does anyone know how I can keep the development-time linking paths when installing or at least customising which paths are added to the runtime?

Cheers

+1  A: 

You should look at set_target_properties command and the property BUILD_WITH_INSTALL_RPATH

http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:set_target_properties

RobertJMaynard
Thanks for this, managed to get it working with the line `set_property(TARGET *binary* PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)` which sets the runtime path to the build linking path. Cheers
Simon Walker