Skip to content

Enable RPATH for CMake's own binaries by default

Brad King requested to merge brad.king/cmake:cmake-self-rpath into master

Reconcile the changes made by:

  • commit ae62f660 (ENH: CMake does not need RPATHs at all for its own executables, 2006-03-01, v2.4.0~380)
  • commit a056cffc (COMP: enable RPATH if any of the CMAKE_USE_SYSTEM_XXX variables is enabled, 2007-08-28, v2.6.0~1183)
  • commit c0108d1e (COMP: use RPATH is building QtDialog and the Qt libs are not in /lib or /usr/lib, 2007-11-05, v2.6.0~915)

The overall goal of those changes was to get the RPATH set for external libraries when needed and also to avoid re-linking or other RPATH editing on installation. We can use a simpler approach to satisfy both goals: always use RPATH entries for libraries found externally. If there are no such libraries we will get no RPATH. If there are such libraries that are not in standard paths we will get a RPATH that points at them. This will work for running either from the build tree or the install tree, so we can use the same for both to avoid editing on installation.

Fixes: #20185 (closed)

Merge request reports