# CMake 3.17.5 cmake\_policy(SET CMP0095 NEW) not working

**URL:** <https://discourse.cmake.org/t/cmake-3-17-5-cmake-policy-set-cmp0095-new-not-working/6767>\
**Category:** Code\
**Tags:** os:linux\
**Created:** [November 1, 2022, 3:55pm UTC](https://discourse.cmake.org/t/cmake-3-17-5-cmake-policy-set-cmp0095-new-not-working/6767 "2022-11-01T15:55:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![prakashcv13](https://discourse.cmake.org/user_avatar/discourse.cmake.org/prakashcv13/32/1320_2.png) [@prakashcv13](https://discourse.cmake.org/u/prakashcv13)\
**Post date:** [November 1, 2022, 3:55pm UTC](https://discourse.cmake.org/t/cmake-3-17-5-cmake-policy-set-cmp0095-new-not-working/6767/1 "2022-11-01T15:55:57Z")

</div>

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

set(CMAKE\_INSTALL\_RPATH “${ORIGIN}”)

the cmake\_install.cmake file has the below lines:  
file(RPATH\_CHANGE  
FILE “${file}”  
OLD\_RPATH “lib::::”  
NEW\_RPATH “$ORIGIN”)

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 ''

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [November 1, 2022, 8:09pm UTC](https://discourse.cmake.org/t/cmake-3-17-5-cmake-policy-set-cmp0095-new-not-working/6767/2 "2022-11-01T20:09:50Z")

</div>

Does this work?

```cmake
set(CMAKE_INSTALL_RPATH “\${ORIGIN}”)

```

---

<div class="post-metadata">

**Author:** ![prakashcv13](https://discourse.cmake.org/user_avatar/discourse.cmake.org/prakashcv13/32/1320_2.png) [@prakashcv13](https://discourse.cmake.org/u/prakashcv13)\
**Post date:** [November 5, 2022, 8:27am UTC](https://discourse.cmake.org/t/cmake-3-17-5-cmake-policy-set-cmp0095-new-not-working/6767/3 "2022-11-05T08:27:45Z")

</div>

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  
set(CMAKE\_INSTALL\_RPATH “${ORIGIN};${ORIGIN}/…/…/”)  
[root@d\_server my\_project\_dir]# readelf -d /path/to/mylibrary.so | grep -i rpath  
0x000000000000000f (RPATH) Library rpath: [:/…/…/]  
[root@d\_server pbspro\_dev\_oss]#

Thanks,  
Prakash

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [November 5, 2022, 3:07pm UTC](https://discourse.cmake.org/t/cmake-3-17-5-cmake-policy-set-cmp0095-new-not-working/6767/4 "2022-11-05T15:07:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![prakashcv13](https://discourse.cmake.org/user_avatar/discourse.cmake.org/prakashcv13/32/1320_2.png) [@prakashcv13](https://discourse.cmake.org/u/prakashcv13)\
**Post date:** [November 5, 2022, 9:15pm UTC](https://discourse.cmake.org/t/cmake-3-17-5-cmake-policy-set-cmp0095-new-not-working/6767/5 "2022-11-05T21:15:40Z")

</div>

Hi Ben,

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

Thanks,  
Prakash

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [November 5, 2022, 10:00pm UTC](https://discourse.cmake.org/t/cmake-3-17-5-cmake-policy-set-cmp0095-new-not-working/6767/6 "2022-11-05T22:00:27Z")

</div>

> [@prakashcv13](#):
>
> set(CMAKE\_INSTALL\_RPATH “${ORIGIN};${ORIGIN}/…/…/”)

This should be:

```cmake
set(CMAKE_INSTALL_RPATH $ORIGIN $ORIGIN/…/…)

```

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

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [November 6, 2022, 1:01pm UTC](https://discourse.cmake.org/t/cmake-3-17-5-cmake-policy-set-cmp0095-new-not-working/6767/7 "2022-11-06T13:01:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [November 6, 2022, 7:52pm UTC](https://discourse.cmake.org/t/cmake-3-17-5-cmake-policy-set-cmp0095-new-not-working/6767/8 "2022-11-06T19:52:47Z")

</div>

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 `ld.so` man page on Linux.

---

<div class="post-metadata">

**Author:** ![prakashcv13](https://discourse.cmake.org/user_avatar/discourse.cmake.org/prakashcv13/32/1320_2.png) [@prakashcv13](https://discourse.cmake.org/u/prakashcv13)\
**Post date:** [November 7, 2022, 12:54pm UTC](https://discourse.cmake.org/t/cmake-3-17-5-cmake-policy-set-cmp0095-new-not-working/6767/9 "2022-11-07T12:54:41Z")

</div>

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

[root@d\_server pbspro\_dev\_oss]# readelf -d /path/to/mylib.so.0.0.0 | grep -i rpath  
0x000000000000000f (RPATH) Library rpath: [$ORIGIN:$ORIGIN/…/lib/:$ORIGIN/…/…/]  
[root@d\_server pbspro\_dev\_oss]# grep -i rpath CMakeLists.txt  
set(CMAKE\_INSTALL\_RPATH “$ORIGIN;$ORIGIN/…/lib/;$ORIGIN/…/…/”)  
[root@d\_server pbspro\_dev\_oss]#
