Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set rpath origin in cmake?

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?

like image 918
Guerlando OCs Avatar asked Oct 13 '19 04:10

Guerlando OCs


1 Answers

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)

like image 95
itanium Avatar answered Oct 10 '22 17:10

itanium