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 path is pointing to /opt/xxx/, but for install I want it to point to /lib/ So essentially controlling the base name there for the

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

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.