[PATCH v2 1/1] Add RPATH if not installing to system dir

Jan Vesely jan.vesely at rutgers.edu
Thu Dec 19 07:20:25 PST 2013


From: Jan Vesely <jan.vesely at cs.rutgers.edu>

v2: Use $ORIGIN relative path

Based on:
http://www.cmake.org/Wiki/CMake_RPATH_handling#CMake_and_the_RPATH

Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
Hi,

this patch  uses the $ORIGIN idea. It still checks whether the target dir is
among system lib dirs. Another approach would be to add $ORIGIN/../lib rpath
unconditionally, and let CMAKE_SKIP_INSTALL_RPATH decide if it's used.

regards,
Jan


 CMakeLists.txt | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4674338..9f437c3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -410,6 +410,13 @@ configure_file(
 set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR} )
 set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib )
 set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib )
+set( CMAKE_LIBRARY_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib )
+
+list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
+	"${CMAKE_LIBRARY_INSTALL_DIRECTORY}" _isSystemLibDir)
+if("${_isSystemLibDir}" STREQUAL "-1")
+	set(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib")
+endif("${_isSystemLibDir}" STREQUAL "-1")
 
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 
-- 
1.8.3.1




More information about the llvm-commits mailing list