From cd75cb4ae32c46c84cef9a9c78b42174f22ed0ac Mon Sep 17 00:00:00 2001 From: Arnaud Botella Date: Thu, 11 Jul 2024 11:23:25 -0700 Subject: PR #1709: Handle RPATH CMake configuration Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1709 When depending on a compiled abseil code, abseil libraries cannot find each other even if they are all located in the same directory. One fix is to edit the LD_LIBRARY_PATH, but it is not always that simple in a development environment. Another way is to add the current location into the RPATH so all libraries can find each other. CMake provides simple command to control this at project scale. Merge caa92e67426784b1537009a24abeaeccba1ca8d4 into cd7f66cab520e99531979b3fd727a25616a1ccbb Merging this change closes #1709 COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1709 from Geode-solutions:master caa92e67426784b1537009a24abeaeccba1ca8d4 PiperOrigin-RevId: 651476097 Change-Id: Ib3f214ac17adabefedfb562127f2b1de413ce437 --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 650ed70e..85e0ec3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,10 @@ else() option(ABSL_ENABLE_INSTALL "Enable install rule" ON) endif() +set(CMAKE_INSTALL_RPATH "$ORIGIN") +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) +set(CMAKE_BUILD_RPATH_USE_ORIGIN ON) + option(ABSL_PROPAGATE_CXX_STD "Use CMake C++ standard meta features (e.g. cxx_std_14) that propagate to targets that link to Abseil" OFF) # TODO: Default to ON for CMake 3.8 and greater. -- cgit v1.2.3