diff -up cmake-2.8.10.2/Source/cmExportInstallFileGenerator.cxx.usrmove cmake-2.8.10.2/Source/cmExportInstallFileGenerator.cxx --- cmake-2.8.10.2/Source/cmExportInstallFileGenerator.cxx.usrmove 2012-11-27 06:26:33.000000000 -0700 +++ cmake-2.8.10.2/Source/cmExportInstallFileGenerator.cxx 2013-03-13 14:13:56.554281710 -0600 @@ -149,17 +149,35 @@ cmExportInstallFileGenerator const char* installDest = this->IEGen->GetDestination(); if(!cmSystemTools::FileIsFullPath(installDest)) { - std::string dest = installDest; - os << "# Compute the installation prefix relative to this file.\n" - << "GET_FILENAME_COMPONENT(_IMPORT_PREFIX " - << "\"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"; - while(!dest.empty()) + std::string installPrefix = + this->IEGen->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); + std::string absDest = installPrefix + "/" + installDest + "/"; + if(strncmp(absDest.c_str(), "/lib/", 5) == 0 || + strncmp(absDest.c_str(), "/lib64/", 7) == 0 || + strncmp(absDest.c_str(), "/usr/lib/", 9) == 0 || + strncmp(absDest.c_str(), "/usr/lib64/", 11) == 0) { - os << - "GET_FILENAME_COMPONENT(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n"; - dest = cmSystemTools::GetFilenamePath(dest); + // Assume this is a build for system package installation rather than a + // relocatable distribution. Use an absolute prefix because some Linux + // distros symlink /lib to /usr/lib which confuses the relative path + // computation below if we generate for /lib under one prefix and but the + // file is loaded from another. + os << "set(_IMPORT_PREFIX \"" << installPrefix << "\")\n"; + } + else + { + std::string dest = installDest; + os << "# Compute the installation prefix relative to this file.\n" + << "get_filename_component(_IMPORT_PREFIX " + << "\"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"; + while(!dest.empty()) + { + os << + "get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n"; + dest = cmSystemTools::GetFilenamePath(dest); + } + os << "\n"; } - os << "\n"; // Import location properties may reference this variable. this->ImportPrefix = "${_IMPORT_PREFIX}/"; diff -up cmake-2.8.10.2/Source/cmInstallExportGenerator.h.usrmove cmake-2.8.10.2/Source/cmInstallExportGenerator.h --- cmake-2.8.10.2/Source/cmInstallExportGenerator.h.usrmove 2012-11-27 06:26:33.000000000 -0700 +++ cmake-2.8.10.2/Source/cmInstallExportGenerator.h 2013-03-13 14:11:17.972077264 -0600 @@ -36,6 +36,8 @@ public: cmExportSet* GetExportSet() {return this->ExportSet;} + cmMakefile* GetMakefile() const { return this->Makefile; } + const std::string& GetNamespace() const { return this->Namespace; } protected: