使用CMake创建二进制文件会删除运行时路径 [英] Creating binary with CMake removes runtime path
问题描述
我正在使用CMake在Linux上构建程序.该程序成功编译并从项目构建目录运行.该程序与目录${HOME}/build/lib
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
我的安装阶段包括:
install(TARGETS ProgName RUNTIME DESTINATION bin)
当我运行make install
时,程序会放置在正确的位置,但是cmake
安装程序会从二进制文件中删除运行时路径.
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*"
我在互联网上读过一些文章,讨论了对LD_LIBRARY_PATH
变量的滥用,因此,我希望尽可能将我的信息限制在系统库的位置.我不是sysadmin,所以也无法将位置添加到默认链接程序搜索路径.
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?
欢呼
推荐答案
您应该查看set_target_properties命令和属性BUILD_WITH_INSTALL_RPATH
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
这篇关于使用CMake创建二进制文件会删除运行时路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!