Currently I am setting RPATH using following syntax:
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:$ORIGIN/../lib")
It is working for the binary build using CMake. The problem is that it is not working for a third party binary I am building using CMake using their auto-configure script. I am using the following command for configure:
add_custom_target(
third_party_bin ALL
COMMAND ./configure
--with-ld-opt=\"-Wl,-rpath,${CMAKE_INSTALL_RPATH}\"
--prefix=${CMAKE_INSTALL_PREFIX}
)
The Makefile generated by third path configure look like:
" -Wl,-rpath,':RIGIN/../lib' -lstdc++"
I think I need to escape ${CMAKE_INSTALL_RPATH} correctly.
I also tried using options like:
add_custom_target(
third_party_bin ALL
COMMAND ./configure
--with-ld-opt=\"-Wl,-rpath,\$\$ORIGIN/../lib\"
--prefix=${CMAKE_INSTALL_PREFIX}
)
and
add_custom_target(
third_party_bin ALL
COMMAND ./configure
--with-ld-opt=\"-Wl,-rpath,\\$\$ORIGIN/../lib\"
--prefix=${CMAKE_INSTALL_PREFIX}
)
but nothing works.
What is the correct way to escape values?
add_custom_target accepts a VERBATIM argument. According to the documentation:
If
VERBATIMis 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 beforeadd_custom_targeteven sees the arguments. Use ofVERBATIMis recommended as it enables correct behavior. WhenVERBATIMis not given the behavior is platform specific because there is no protection of tool-specific special characters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With