[Orxonox-commit 3633] r8318 - in code/branches/kicklib2: cmake cmake/tools src

rgrieder at orxonox.net rgrieder at orxonox.net
Sun Apr 24 05:48:53 CEST 2011


Author: rgrieder
Date: 2011-04-24 05:48:53 +0200 (Sun, 24 Apr 2011)
New Revision: 8318

Modified:
   code/branches/kicklib2/cmake/InstallConfig.cmake
   code/branches/kicklib2/cmake/tools/TargetUtilities.cmake
   code/branches/kicklib2/src/OrxonoxConfig.cmake
Log:
RPATH handling was broken in certain cases, esp. for "turn-key" (INSTALL_COPYABLE) installations.
Fixed by using the "$ORIGIN" token and distinguishing between executable, library and module when setting the RPATH.

Modified: code/branches/kicklib2/cmake/InstallConfig.cmake
===================================================================
--- code/branches/kicklib2/cmake/InstallConfig.cmake	2011-04-24 03:46:26 UTC (rev 8317)
+++ code/branches/kicklib2/cmake/InstallConfig.cmake	2011-04-24 03:48:53 UTC (rev 8318)
@@ -70,15 +70,27 @@
 
 ################## Unix rpath ###################
 
+# Use, i.e. don't skip the full RPATH for the build tree
+SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
+
 # When building, don't use the install RPATH already
 # (but later on when installing)
 SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
 
 # The RPATH to be used when installing
 IF(INSTALL_COPYABLE)
-  SET(CMAKE_INSTALL_RPATH ${DEFAULT_LIBRARY_PATH})
+  # Get relative paths from run to lib and from module to lib directory.
+  FILE(RELATIVE_PATH _runtime_rpath "/${RUNTIME_INSTALL_DIRECTORY}" "/${LIBRARY_INSTALL_DIRECTORY}")
+  FILE(RELATIVE_PATH _module_rpath  "/${MODULE_INSTALL_DIRECTORY}" "/${LIBRARY_INSTALL_DIRECTORY}")
+  # $ORIGIN (with $ escaped) refers to the actual location of the library
+  # The UNIX loader recognises this special variable
+  SET(RUNTIME_RPATH "\$ORIGIN/${_runtime_rpath}")
+  SET(LIBRARY_RPATH "\$ORIGIN")
+  SET(MODULE_RPATH  "\$ORIGIN:\$ORIGIN/${_module_rpath}")
 ELSE()
-  SET(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIRECTORY})
+  SET(RUNTIME_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIRECTORY}")
+  SET(LIBRARY_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIRECTORY}")
+  SET(MODULE_RPATH  "${LIBRARY_RPATH}:${CMAKE_INSTALL_PREFIX}/${MODULE_INSTALL_DIRECTORY}")
 ENDIF()
 
 # Add the automatically determined parts of the RPATH

Modified: code/branches/kicklib2/cmake/tools/TargetUtilities.cmake
===================================================================
--- code/branches/kicklib2/cmake/tools/TargetUtilities.cmake	2011-04-24 03:46:26 UTC (rev 8317)
+++ code/branches/kicklib2/cmake/tools/TargetUtilities.cmake	2011-04-24 03:48:53 UTC (rev 8318)
@@ -287,13 +287,16 @@
   ENDIF()
 
   # RPATH settings for the installation
-  IF(UNIX)
-    SET(_rpath ${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIRECTORY})
+  IF(_target_type STREQUAL "LIBRARY")
     IF(_arg_MODULE)
-      LIST(APPEND _rpath ${CMAKE_INSTALL_PREFIX}/${MODULE_INSTALL_DIRECTORY})
+      SET(_rpath "${MODULE_RPATH}")
+    ELSE()
+      SET(_rpath "${LIBRARY_RPATH}")
     ENDIF()
-    SET_TARGET_PROPERTIES(${_target_name} PROPERTIES INSTALL_RPATH "${_rpath}")
+  ELSE()
+    SET(_rpath "${RUNTIME_RPATH}")
   ENDIF()
+  SET_TARGET_PROPERTIES(${_target_name} PROPERTIES INSTALL_RPATH "${_rpath}")
 
   # DEFINE_SYMBOL
   IF(_arg_DEFINE_SYMBOL)

Modified: code/branches/kicklib2/src/OrxonoxConfig.cmake
===================================================================
--- code/branches/kicklib2/src/OrxonoxConfig.cmake	2011-04-24 03:46:26 UTC (rev 8317)
+++ code/branches/kicklib2/src/OrxonoxConfig.cmake	2011-04-24 03:48:53 UTC (rev 8318)
@@ -27,9 +27,6 @@
 
 #################### Options ####################
 
-# Use, i.e. don't skip the full RPATH for the build tree
-SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
-
 # Global switch to disable Precompiled Header Files
 # Note: PCH temporarily disabled on Mac because of severe problems
 IF(PCH_COMPILER_SUPPORT AND NOT APPLE)




More information about the Orxonox-commit mailing list