set interpreter path at install?

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.

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?

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").

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 :slight_smile:

Please file a feature request.