setup RPATH, bump cmake
authorkoda
Tue, 11 Jun 2013 19:17:52 +0200 (2013-06-11)
changeset 9198 48b92ff6238f
parent 9196 89d98f970de9
child 9200 37c37026f7ec
setup RPATH, bump cmake
CMakeLists.txt
QTfrontend/CMakeLists.txt
cmake_modules/paths.cmake
--- a/CMakeLists.txt	Tue Jun 11 18:35:28 2013 +0200
+++ b/CMakeLists.txt	Tue Jun 11 19:17:52 2013 +0200
@@ -1,7 +1,7 @@
 project(hedgewars)
 
 #initialise cmake environment
-cmake_minimum_required(VERSION 2.6.0)
+cmake_minimum_required(VERSION 2.6.4)
 foreach(hwpolicy CMP0003 CMP0012 CMP0017 CMP0018)
     if(POLICY ${hwpolicy})
         cmake_policy(SET ${hwpolicy} NEW)
--- a/QTfrontend/CMakeLists.txt	Tue Jun 11 18:35:28 2013 +0200
+++ b/QTfrontend/CMakeLists.txt	Tue Jun 11 19:17:52 2013 +0200
@@ -189,10 +189,6 @@
     ${hwfr_rez_src}
     )
 
-if((UNIX AND NOT APPLE) AND ${BUILD_ENGINE_LIBRARY})
-    set_target_properties(hedgewars PROPERTIES LINK_FLAGS "-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/${target_library_install_dir}")
-endif()
-
 list(APPEND HW_LINK_LIBS
     ${PHYSFS_LIBRARY}
     ${PHYSLAYER_LIBRARY}
--- a/cmake_modules/paths.cmake	Tue Jun 11 18:35:28 2013 +0200
+++ b/cmake_modules/paths.cmake	Tue Jun 11 19:17:52 2013 +0200
@@ -29,3 +29,33 @@
         link_directories("${EXECUTABLE_OUTPUT_PATH}" "${CMAKE_SOURCE_DIR}/misc/winutils/bin")
     endif()
 endif()
+
+
+#RPATH SETTINGS
+#necessary for dynamic libraries on UNIX, ignored elsewhere
+
+#use, i.e. don't skip the full RPATH for the build tree
+set(CMAKE_SKIP_BUILD_RPATH FALSE)
+set(CMAKE_SKIP_INSTALL_RPATH FALSE)
+
+#it's safe to use our RPATH because it is relative
+set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+
+#paths where to find libraries (final slash not optional):
+# - the first is relative to the executable
+# - the second is the same directory of the executable (so it runs in bin/)
+# - the third one is the full path of the system dir
+#source http://www.cmake.org/pipermail/cmake/2008-January/019290.html
+set(CMAKE_INSTALL_RPATH "$ORIGIN/../${target_library_install_dir}/:$ORIGIN/:${CMAKE_INSTALL_PREFIX}/${target_library_install_dir}/")
+set(CMAKE_INSTALL_RPATH_ESCAPED "$$ORIGIN/../${target_library_install_dir}/:$$ORIGIN/:${CMAKE_INSTALL_PREFIX}/${target_library_install_dir}/")
+
+if(UNIX AND NOT APPLE)
+    list(APPEND pascal_flags "-k-rpath" "-k'${CMAKE_INSTALL_RPATH_ESCAPED}'")
+    list(APPEND haskell_flags "-optl" "-Wl,-rpath,'${CMAKE_INSTALL_RPATH_ESCAPED}'")
+endif()
+
+#add the automatically determined parts of the RPATH
+#which point to directories outside the build tree to the install RPATH
+set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
+
+