# set interpreter path at install?

**URL:** <https://discourse.cmake.org/t/set-interpreter-path-at-install/4158>\
**Category:** Code\
**Created:** [September 28, 2021, 1:17pm UTC](https://discourse.cmake.org/t/set-interpreter-path-at-install/4158 "2021-09-28T13:17:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmak](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/c/eb8c5e/32.png) [@cmak](https://discourse.cmake.org/u/cmak)\
**Post date:** [September 28, 2021, 1:17pm UTC](https://discourse.cmake.org/t/set-interpreter-path-at-install/4158/1 "2021-09-28T13:17:05Z")

</div>

Is it possible to have cmake set the interpreter path at install step? I want to rewrite the interpreter path when installing. Currently I’m doing `patchelf --set-interpreter` to achieve this. There is a `CMAKE_INSTALL_RPATH` for fixing up rpath at install, but could not find interpreter path fixup.

---

<div class="post-metadata">

**Author:** ![cmak](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/c/eb8c5e/32.png) [@cmak](https://discourse.cmake.org/u/cmak)\
**Post date:** [September 29, 2021, 8:36am UTC](https://discourse.cmake.org/t/set-interpreter-path-at-install/4158/2 "2021-09-29T08:36:31Z")

</div>

I believe the linker flag that controls this is `--dynamic-linker`. In my case the ld.so path is pointing to `/opt/xxx/ld-linux-x86-64.so.2`, but for install I want it to point to `/lib/ld-linux-x86-64.so.2`. So essentially controlling the base name there for the ld.so.

If not possible to control with cmake install flag, is there a way to run a custom script when installing all binary targets?

---

<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:** [September 29, 2021, 5:45pm UTC](https://discourse.cmake.org/t/set-interpreter-path-at-install/4158/3 "2021-09-29T17:45:54Z")

</div>

CMake doesn’t have an abstraction for this, but you can add it to the link options for the targets you want using `target_link_options(tgt PRIVATE "LINK:--dynamic-linker /lib/ld-linux-x86-64.so.2")`.

---

<div class="post-metadata">

**Author:** ![cmak](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/c/eb8c5e/32.png) [@cmak](https://discourse.cmake.org/u/cmak)\
**Post date:** [October 1, 2021, 6:58am UTC](https://discourse.cmake.org/t/set-interpreter-path-at-install/4158/4 "2021-10-01T06:58:33Z")

</div>

Ok, thanks for confirming. It would be nice if cmake could add support for differentiating the interpreter path between build and install folders. Same way it is able to do it with rpath, so maybe a `CMAKE_INSTALL_DYNAMIC_LINKER_PATH` 🙂

---

<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:** [October 1, 2021, 11:43am UTC](https://discourse.cmake.org/t/set-interpreter-path-at-install/4158/5 "2021-10-01T11:43:22Z")

</div>

Please file [a feature request](https://gitlab.kitware.com/cmake/cmake/-/issues).
