From: Modestas Vainius <modax@debian.org>, Felix Geyer <debfx-pkg@fobos.de>
Subject: Do not set install RPATH to /usr/lib by default
Forwarded: no
Origin: vendor
Last-Update: 2012-03-07

Use proper code in order to avoid setting INSTALL_RPATH to /usr/lib. It is
disallowed on Debian systems and is a bad practise in general. We also need
to ensure LIB_INSTALL_DIR is absolute before checking.

--- a/cmake/FindPhononInternal.cmake
+++ b/cmake/FindPhononInternal.cmake
@@ -123,7 +123,16 @@ endif(APPLE)
 # RPATH directories outside the current CMAKE_BINARY_DIR and also the library 
 # install directory. Alex
 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH  TRUE)
-set(CMAKE_INSTALL_RPATH "${LIB_INSTALL_DIR}")
+if (IS_ABSOLUTE "${LIB_INSTALL_DIR}")
+    set(_rpath_abs_lib_install_dir "${LIB_INSTALL_DIR}")
+else()
+    set(_rpath_abs_lib_install_dir "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}")
+endif()
+list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${_rpath_abs_lib_install_dir}" _isSystemPlatformLibDir)
+list(FIND CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "${_rpath_abs_lib_install_dir}" _isSystemCxxLibDir)
+if("${_isSystemPlatformLibDir}" STREQUAL "-1" AND "${_isSystemCxxLibDir}" STREQUAL "-1")
+   set(CMAKE_INSTALL_RPATH "${_rpath_abs_lib_install_dir}")
+endif("${_isSystemPlatformLibDir}" STREQUAL "-1" AND "${_isSystemCxxLibDir}" STREQUAL "-1")
 
 
 # Uninstall Target
