diff options
author | Brad King <brad.king@kitware.com> | 2013-04-04 18:20:21 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2013-04-04 18:20:21 (GMT) |
commit | 9cccd2c29cccaa480f6b16bdd96b2621b6544baf (patch) | |
tree | 91f287e037c17e5ae271816809c940aa8d29281c /Source | |
parent | af79291fb45933ac126d5f5882c70eb75c2c17b8 (diff) | |
parent | 6c613b433c45efb0bb013a6bd668cbb8ac740259 (diff) | |
download | CMake-9cccd2c29cccaa480f6b16bdd96b2621b6544baf.zip CMake-9cccd2c29cccaa480f6b16bdd96b2621b6544baf.tar.gz CMake-9cccd2c29cccaa480f6b16bdd96b2621b6544baf.tar.bz2 |
Merge topic 'usr-move-relocatable'
6c613b4 Handle usr-move without forcing absolute paths (#14041)
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmExportInstallFileGenerator.cxx | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 746b0c8..ad12b5a 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -76,33 +76,36 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) { 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) + std::string absDest = installPrefix + "/" + installDest; + std::string absDestS = absDest + "/"; + os << "# Compute the installation prefix relative to this file.\n" + << "get_filename_component(_IMPORT_PREFIX" + << " \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"; + if(strncmp(absDestS.c_str(), "/lib/", 5) == 0 || + strncmp(absDestS.c_str(), "/lib64/", 7) == 0 || + strncmp(absDestS.c_str(), "/usr/lib/", 9) == 0 || + strncmp(absDestS.c_str(), "/usr/lib64/", 11) == 0) { - // 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"; + // Handle "/usr move" symlinks created by some Linux distros. + os << + "# Use original install prefix when loaded through a\n" + "# cross-prefix symbolic link such as /lib -> /usr/lib.\n" + "get_filename_component(_realCurr \"${_IMPORT_PREFIX}\" REALPATH)\n" + "get_filename_component(_realOrig \"" << absDest << "\" REALPATH)\n" + "if(_realCurr STREQUAL _realOrig)\n" + " set(_IMPORT_PREFIX \"" << absDest << "\")\n" + "endif()\n" + "unset(_realOrig)\n" + "unset(_realCurr)\n"; } - else + std::string dest = installDest; + while(!dest.empty()) { - 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 << + "get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n"; + dest = cmSystemTools::GetFilenamePath(dest); } + os << "\n"; // Import location properties may reference this variable. this->ImportPrefix = "${_IMPORT_PREFIX}/"; |