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


  when parsing string


  Invalid escape sequence \{

I need to set this rpath which I was using in Makefile:


How to do it in cmake?


  • Following works for me on 3.14


    This is what Craig Scott recommended in his CppCon 2019 talk Deep CMake for Library Authors (Slide 100/110)