From 523288fa71bba2bb223e7ffbc68f5ebe55118ebd Mon Sep 17 00:00:00 2001 From: Harald Sitter Date: Wed, 28 May 2014 16:22:58 +0200 Subject: [PATCH] import relative dir resolution workaround from CMakePackageConfigHelpers this prevents the install path resolution from going wrong when symlinks are involved in /usr/lib* (e.g. the case on Fedora). the result of not having this workaround is that the install dir will be resolved as '/' resulting in bogus paths for cmake config users (e.g. include dir would be set to //include/$soname) note: this was not actually tested on an affected system, weeh --- CMakeLists.txt | 19 +++++++++++++++++++ PhononConfig.cmake.in | 1 + 2 files changed, 20 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d7f0d9..6130885 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,6 +225,25 @@ set(CMAKECONFIG_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/${PHONON_LIB_SONAME} ) # runtime different from the chosen CMAKE_INSTALL_PREFIX if under Windows the package was installed anywhere) # This relative path will be configured into the PhononConfig.cmake file(RELATIVE_PATH relInstallDir ${CMAKE_INSTALL_PREFIX}/${CMAKECONFIG_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX} ) +make_abs_install_path(absInstallDir ${CMAKECONFIG_INSTALL_DIR}) + +# Exciting code copy from CMakePackageConfigHelpers to avoid the pain from porting +# to it for the 4.x series. +# The set variable is used by the PhononConfig.cmake.in to use a refined rootDir +# resolution when installed to /usr/lib +if("${absInstallDir}" MATCHES "^(/usr)?/lib(64)?/.+") + # Handle "/usr move" symlinks created by some Linux distros. + set(USR_SYMLINK_RESOLVER " + # Use original install prefix when loaded through a \"/usr move\" + # cross-prefix symbolic link such as /lib -> /usr/lib. + get_filename_component(_realCurr \"\${CMAKE_CURRENT_LIST_DIR}\" REALPATH) + get_filename_component(_realOrig \"${absInstallDir}\" REALPATH) + if(_realCurr STREQUAL _realOrig) + set(rootDir \"${CMAKE_INSTALL_PREFIX}\") + endif() + unset(_realOrig) + unset(_realCurr)") +endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/PhononConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PHONON_LIB_SONAME_CAMEL}Config.cmake @ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/PhononConfigVersion.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PHONON_LIB_SONAME_CAMEL}ConfigVersion.cmake @ONLY) diff --git a/PhononConfig.cmake.in b/PhononConfig.cmake.in index f3962cb..f1f3e7c 100644 --- a/PhononConfig.cmake.in +++ b/PhononConfig.cmake.in @@ -5,6 +5,7 @@ set(PHONON_VERSION "@PHONON_LIB_MAJOR_VERSION@.@PHONON_LIB_MINOR_VERSION@.@PHONO get_filename_component(currentDir ${CMAKE_CURRENT_LIST_FILE} PATH) # get the directory where I myself am get_filename_component(rootDir ${currentDir}/@relInstallDir@ ABSOLUTE) # get the chosen install prefix +@USR_SYMLINK_RESOLVER@ set(PHONON_NO_GRAPHICSVIEW @PHONON_NO_GRAPHICSVIEW@) set(PHONON_PULSESUPPORT @PHONON_PULSESUPPORT@) -- 1.9.3