Issue
I found Cmake: How to set rpath to ${ORIGIN} with cmake but my cmake does not have target_link_options.
I'm not installing the binary, I'm only "installing" it with RUNTIME_OUTPUT_DIRECTORY
, so I don't think CMAKE_INSTALL_RPATH
will work. Even though, I tried SET(CMAKE_INSTALL_RPATH "$\{ORIGIN\}")
as suggested in the question, but I got
Syntax error in cmake code at
.../CMakeLists.txt:25
when parsing string
$\{ORIGIN\}
Invalid escape sequence \{
I need to set this rpath which I was using in Makefile:
-rpath=\$$ORIGIN/lib
How to do it in cmake?
Solution
Following works for me on 3.14
set(CMAKE_INSTALL_RPATH $ORIGIN)
This is what Craig Scott recommended in his CppCon 2019 talk Deep CMake for Library Authors (Slide 100/110)
Answered By - itanium Answer Checked By - Clifford M. (WPSolving Volunteer)