目前我正在使用以下语法设置RPATH SET(CMAKE_INSTALL_RPATH“$ {CMAKE_INSTALL_RPATH}:$ ORIGIN /../ lib”) 它适用于使用cmake的二进制构建。 问题是它不适用于我使用自动配置脚本使用cmake构建的第三方二进制文件。我正在使用以下命令进行配置
add_custom_target(
third_party_bin ALL
COMMAND ./configure
--with-ld-opt=\"-Wl,-rpath,${CMAKE_INSTALL_RPATH}\"
--prefix=${CMAKE_INSTALL_PREFIX}
)
使第三条路径生成的文件配置看起来像 “-Wl,-rpath,':RIGIN /../ lib'-lddc ++”
我想我需要正确转义$ {CMAKE_INSTALL_RPATH}。 我也尝试过使用像
这样的选项add_custom_target(
third_party_bin ALL
COMMAND ./configure
--with-ld-opt=\"-Wl,-rpath,\$\$ORIGIN/../lib\"
--prefix=${CMAKE_INSTALL_PREFIX}
)
和
add_custom_target(
third_party_bin ALL
COMMAND ./configure
--with-ld-opt=\"-Wl,-rpath,\\$\$ORIGIN/../lib\"
--prefix=${CMAKE_INSTALL_PREFIX}
)
但没有任何作用。
逃避价值观的正确方法是什么?
答案 0 :(得分:0)
add_custom_target接受VERBATIM参数。根据文件:
If VERBATIM is given then all arguments to the commands will be
escaped properly for the build tool so that the invoked command
receives each argument unchanged. Note that one level of escapes is
still used by the CMake language processor before add_custom_target
even sees the arguments. Use of VERBATIM is recommended as it enables
correct behavior. When VERBATIM is not given the behavior is platform
specific because there is no protection of tool-specific special
characters.
答案 1 :(得分:-1)
如果我正确读取这个,你正在寻找逃避shell解释$ variables ...如果是这样,使用单引号(')而不是双精度(“)。shell不解释包含在中的变量单引号。