Skip to content

RPATH: Add option for using $ORIGIN in build tree

Peter Wu requested to merge Lekensteyn/cmake:relative-rpath into master

This PR addresses #18413 (closed) by making build RPATHs relative using the $ORIGIN token. It does not add support for macOS since that platform has quite some unusual characteristics.

TODO:

  • Document CMAKE_BUILD_RPATH_USE_ORIGIN option
  • Enable CMAKE_BUILD_RPATH_USE_ORIGIN by default (allowing the user/project to override it). Deferred.
  • Introduce a new policy that disables this new feature. Deferred.
  • New test case: check that an external library outside the build dir does not become relative. Not sure how to do this, can I just link to m or z (zlib)?

Tested on Linux only. OpenBSD and DragonFly BSD would be interesting test cases due to the CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG override.

Edited by Brad King

Merge request reports