English 中文(简体)
Cmake: How to setrpath to${ORIGIN} with triake
原标题:Cmake: How to set rpath to ${ORIGIN} with cmake
问题回答

As you already noticed, you should use CMAKE_INSTALL_RPATH or INSTALL_RPATH. INSTALL_RPATH sets the rpath when installing a specific target. CMAKE_INSTALL_RPATH is the global variant, doing the same for all targets.

I also struggled, how to escape $ORIGIN. But, for me it works without escaping it at all:

set_target_properties(<target> PROPERTIES INSTALL_RPATH "$ORIGIN")

它不仅仅为我设置了<条码>CMAKE_INSTALL_RPATH(cmake版本3.20.2, 3.7.2):

I ve set CMAKE_INSTALL_RPATH in a high level CMakeLists. txt file:

set(CMAKE_INSTALL_RPATH "${LIB_INSTALL_PATH}:$ORIGIN")

这个例子还增加了另一个途径,从一个变数I生成的LIB_INSTALL_PATH

关于目标分子,我有:

 set_target_properties(mytarget
   PROPERTIES
      BUILD_WITH_INSTALL_RPATH true
      LINK_OPTIONS "-Wl,--disable-new-dtags"
)

The --disable-new-dtags was need to use RPATH instead of RUNPATH (the new default) which apparently has issues.

Not adding anything to the target CMakeLists.txt file results in RPATH set to the build path:

 0x000000000000000f (RPATH)              Library rpath: [/home/brookbot/workspace/my_project/build/tgt/stuff:/home/brookbot/workspace/my_project/build/tgt]

But adding the property BUILD_WITH_INSTALL_RPATH true to the target gives me the desired result:

0x000000000000000f (RPATH)              Library rpath: [/my/install/path:$ORIGIN]

I m using readelf -d to examine the results.

I ve还核实了这一工程的基数版本3.7.2,并警告说,它生成了RUNPATH而不是RPATH。 (如-OPTIONS property is not work),但它在目标上仍为我 runs:

 0x000000000000001d (RUNPATH)            Library runpath: [/my/install/path:$ORIGIN] 




相关问题
How do I escape a string for a shell command in node?

In nodejs, the only way to execute external commands is via sys.exec(cmd). I d like to call an external command and give it data via stdin. In nodejs there does yet not appear to be a way to open a ...

Do I need to escape this?

It might be a bit unusual, but I need to echo <?php. However, I think that PHP treats it as an actual <?php and starts executing code instead of treating it as a string. How can I escape <?...

热门标签