From f73e9c02b3b7d624c454b2ab096e11ce6171a972 Mon Sep 17 00:00:00 2001 From: matlabbe Date: Sun, 25 Aug 2024 20:48:27 -0700 Subject: [PATCH] Added cmake option BUILD_WITH_RPATH_NOT_RUNPATH to use old RPATH behavior on build tree (#1308) --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ec8020ee4..e0305cc615 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,6 +227,7 @@ option(PCL_OMP "With PCL OMP implementations" OFF) ELSE() option(PCL_OMP "With PCL OMP implementations" ON) ENDIF() +option(BUILD_WITH_RPATH_NOT_RUNPATH "Explicitly disable usage of RUNPATH for the build tree on linux systems by adding --disable-new-dtags to linker (using old RPATH behavior instead)" OFF) set(RTABMAP_QT_VERSION AUTO CACHE STRING "Force a specific Qt version.") set_property(CACHE RTABMAP_QT_VERSION PROPERTY STRINGS AUTO 4 5 6) @@ -806,6 +807,11 @@ IF(WITH_ORB_SLAM AND NOT G2O_FOUND) ENDIF(ORB_SLAM_FOUND) ENDIF(WITH_ORB_SLAM AND NOT G2O_FOUND) +SET(DISABLE_NEW_DTAGS_FLAG "--disable-new-dtags") +IF(NOT (APPLE OR WIN32) AND BUILD_WITH_RPATH_NOT_RUNPATH) + ADD_LINK_OPTIONS(LINKER:${DISABLE_NEW_DTAGS_FLAG}) +ENDIF() + IF(NOT MSVC) IF(Qt6_FOUND OR (G2O_FOUND AND G2O_CPP11 EQUAL 1) OR TORCH_FOUND) # Qt6 requires c++17 @@ -1304,6 +1310,9 @@ IF(APPLE OR WIN32) MESSAGE(STATUS " BUILD_AS_BUNDLE = ${BUILD_AS_BUNDLE}") ENDIF(APPLE OR WIN32) MESSAGE(STATUS " CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}") +IF(NOT (APPLE OR WIN32) AND BUILD_WITH_RPATH_NOT_RUNPATH) +MESSAGE(STATUS " LINKER FLAGS = ${DISABLE_NEW_DTAGS_FLAG}") +ENDIF() MESSAGE(STATUS " FLANN_KDTREE_MEM_OPT = ${FLANN_KDTREE_MEM_OPT}") MESSAGE(STATUS " PCL_DEFINITIONS = ${PCL_DEFINITIONS}") MESSAGE(STATUS " PCL_VERSION = ${PCL_VERSION}")