使用 CMake 创建二进制文件会删除运行时路径
我正在使用 CMake 在 Linux 上构建程序。程序编译成功并从项目构建目录运行。该程序与目录 ${HOME}/build/lib
中的自定义库链接,
我有一个安装阶段:
install(TARGETS ProgName RUNTIME DESTINATION bin)
当我运行 make install
时,程序将被放入正确的位置,但 cmake
安装程序从二进制文件中删除了运行时路径。
-- Install configuration: "Debug"
-- Installing: *binary name*
-- Removed runtime path from "*binary name*"
我在互联网上阅读过讨论 LD_LIBRARY_PATH 变量滥用的文章,因此如果可能的话,我希望将我的变量限制在系统库位置。我不是系统管理员,因此我也无法将该位置添加到默认链接器搜索路径。
有谁知道如何在安装或至少自定义将哪些路径添加到运行时时保留开发时链接路径?
干杯
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
注意:如果您不想修改
cmake
脚本本身,请设置属性,您可以使用要求不删除运行时路径的指令来启动cmake
:< br>请参阅“控制构建的变量”,其中包含变量:“
CMAKE_SKIP_RPATH
”如果交付已经包含正确的运行时路径,则该指令将避免 cmake 对所述交付中包含的当前运行时路径进行任何修改。
Note: if you don't want to modify the
cmake
scripts themselves, setting property around, you can launch youcmake
with a directive asking to not remove the runtime path:See "Variables that Control the Build", with variable: "
CMAKE_SKIP_RPATH
"If the deliveries already contained the right runtime path, that directive will avoid
cmake
to do any modification to the current runtime path included in said deliveries.您应该查看 set_target_properties 命令和属性 BUILD_WITH_INSTALL_RPATH
http ://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:set_target_properties
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 2.8,
其中
foo
是您之前定义的目标:之前
之后
This works for CMake 2.8
where
foo
is the target you defined earlier:Before
After