简体   繁体   English

如何在cmake中指定linux二进制文件的rpath

[英]How to specify linux binary's rpath in cmake

I have a CMakeLists.txt file that contains such line of code: 我有一个CMakeLists.txt文件,其中包含以下代码行:

link_directories(dir_a dir_b dir_c)

When I build an executable and perform 当我生成可执行文件并执行

readelf -d

on it, I see RPATH with dir_a, dir_b dir_c. 在上面,我看到带有dir_a,dir_b dir_c的RPATH。

What can I do with cmake if I want to create 如果要创建cmake,该怎么办

  • Executable with empty RPATH? 可以用空RPATH执行吗?
  • Executable with some paths, but not specified in link_directories line? 可执行某些路径,但在link_directories行中未指定?

The executable is not supposed to be "installed". 该可执行文件不应该被“安装”。

From this cmake-documentation you can read that: 从该cmake文档中,您可以了解到:

  • you can use the variable CMAKE_SKIP_RPATH to have cmake not adding any RPATH to a binary ever and 您可以使用变量CMAKE_SKIP_RPATH来使cmake永远不会将任何RPATH添加到二进制文件中,
  • that with the SET_TARGET_PROPERTIES -functions RPATHs can be controlled individually on a per-target base. 使用SET_TARGET_PROPERTIES函数可以在每个目标的基础上分别控制RPATH。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM