CMake should automatically set RPATH for installed artifacts
Right now, setting RPATH for an installed artifact that references another installed artifact (i.e. built by the same project) requires manually setting
CMAKE_INSTALL_RPATH. But CMake knows where the library is being installed. It would be helpful, especially for superbuilds where setting a custom path per external or modifying the external sources is not desirable, if CMake could compute the appropriate RPATH.
It seems this should be possible. For each binary being installed, test if it links to other libraries that are also being installed. If so, add to that binary's RPATH the install location of each such library. (In case a library is installed to more than one location, it should be sufficient to simply pick one location, e.g. the first. A more sophisticated algorithm could attempt to minimize the number of RPATH entries.)
This feature would be controlled by a new variable, likely
CMAKE_INSTALL_RPATH_<something>, which would of course be
OFF by default.