CMake 3.17.5 cmake_policy(SET CMP0095 NEW) not working

Hi All,

In our project, the main CMakeLists.txt has the below two lines at the very beginning -
cmake_minimum_required(VERSION 3.16)
cmake_policy(SET CMP0095 NEW)

Also, we are setting CMAKE_INSTALL_RPATH


the cmake_install.cmake file has the below lines:
FILE “${file}”
OLD_RPATH “lib::::”

The final shared library that gets built also has the escape '' character

The escaping '' does not help. Can anyone help in understanding as to how we can have only “${ORIGIN}” without the ''

Does this work?


hey @ben.boeckel - thank you so much for a quick reply and apologies from me for being late in responding.

I did try your suggestion - but i still do not see the desired behaviour.

[root@d_server my_project_dir]# grep ORIGIN CMakeLists.txt
[root@d_server my_project_dir]# readelf -d /path/to/ | grep -i rpath
0x000000000000000f (RPATH) Library rpath: [:/…/…/]
[root@d_server pbspro_dev_oss]#


You need to escape the $ so that it doesn’t get expanded as a CMake variable (probably undefined, so therefore empty).

Hi Ben,

I have added the escape character “\” in my message and CMakeLists.txt - but it is not working.


This should be:


Note the removal of the {}. The $ORIGIN is meant for the linker to interpret, it is not substituted by CMake.

The linker supports both ${ORIGIN} and $ORIGIN.

I know some runtime loaders support ${ORIGIN}, but I’m not sure if that is universally supported on all unix systems where $ORIGIN is supported. It is very rare to see ${ORIGIN} used, the only place I’ve seen it mentioned is in the man page on Linux.

thank you @craig.scott and @ben.boeckel - using $ORIGIN (without the {}) works for me.

[root@d_server pbspro_dev_oss]# readelf -d /path/to/ | grep -i rpath
0x000000000000000f (RPATH) Library rpath: [$ORIGIN:$ORIGIN/…/lib/:$ORIGIN/…/…/]
[root@d_server pbspro_dev_oss]# grep -i rpath CMakeLists.txt
[root@d_server pbspro_dev_oss]#