【问题标题】:How to set rpath origin in cmake?如何在 cmake 中设置 rpath 原点?
【发布时间】:2020-02-10 02:49:28
【问题描述】:

我找到了Cmake: How to set rpath to ${ORIGIN} with cmake,但我的 cmake 没有 target_link_options。

我没有安装二进制文件,我只是用RUNTIME_OUTPUT_DIRECTORY“安装”它,所以我认为CMAKE_INSTALL_RPATH 不会起作用。尽管如此,我按照问题中的建议尝试了SET(CMAKE_INSTALL_RPATH "$\{ORIGIN\}"),但我得到了

  Syntax error in cmake code at

  .../CMakeLists.txt:25

  when parsing string

    $\{ORIGIN\}

  Invalid escape sequence \{

我需要设置我在 Makefile 中使用的这个 rpath:

-rpath=\$$ORIGIN/lib

在cmake中怎么做?

【问题讨论】:

  • 你使用的是什么版本的 CMake?

标签: cmake linker shared-libraries


【解决方案1】:

以下作品在 3.14 上为我工作

  set(CMAKE_INSTALL_RPATH $ORIGIN)

这是 Craig Scott 在他的 CppCon 2019 演讲 Deep CMake for Library Authors(幻灯片 100/110)中推荐的内容

【讨论】:

  • 根据幻灯片,在 add_executable 之前添加该行很重要
猜你喜欢
  • 1970-01-01
  • 2020-10-04
  • 2017-03-01
  • 2022-10-16
  • 1970-01-01
  • 2016-06-17
  • 2018-08-15
  • 2011-10-06
  • 1970-01-01
相关资源
最近更新 更多