diff options
author | Brad King <brad.king@kitware.com> | 2013-03-12 17:46:51 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2013-03-12 17:46:51 (GMT) |
commit | 556ae30717e6d20399d32634d4593f583e46424c (patch) | |
tree | d0cca1fadaab29d9d18b0406ca0c3a386b0b8ec4 /Source | |
parent | 32fb1f2371d7cfe5ba1952d25182adf55058d812 (diff) | |
parent | 0c727b906ac943583fcfb1eb5cf3ea92d2ea030c (diff) | |
download | CMake-556ae30717e6d20399d32634d4593f583e46424c.zip CMake-556ae30717e6d20399d32634d4593f583e46424c.tar.gz CMake-556ae30717e6d20399d32634d4593f583e46424c.tar.bz2 |
Merge topic 'install-export-usr-move'
0c727b9 install(EXPORT): Force absolute paths for usr-move
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmExportInstallFileGenerator.cxx | 36 | ||||
-rw-r--r-- | Source/cmInstallExportGenerator.h | 2 |
2 files changed, 29 insertions, 9 deletions
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index b6600f0..8b8b846 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -74,17 +74,35 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) 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 --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index ee92906..7aff731 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -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: |