summaryrefslogtreecommitdiffstats
path: root/Source/CPack
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2010-09-08 15:07:38 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2010-09-08 15:07:38 (GMT)
commitc9b0e1da5cf449ad54f873bc2b4d45df9197efb5 (patch)
treeed47161153522cb4108e5a616c9e001f782830d5 /Source/CPack
parent711c6103143fd55d029dace11cb14c2187c9d153 (diff)
parent013e0039eeb7e8bf213c3851161ce9a18f7b940d (diff)
downloadCMake-c9b0e1da5cf449ad54f873bc2b4d45df9197efb5.zip
CMake-c9b0e1da5cf449ad54f873bc2b4d45df9197efb5.tar.gz
CMake-c9b0e1da5cf449ad54f873bc2b4d45df9197efb5.tar.bz2
Merge topic 'CPack-PreserveSymlinksInInstalledDirs-v2'
013e003 CPack handle symlinks in CPACK_INSTALLED_DIRECTORIES fix for bug5430
Diffstat (limited to 'Source/CPack')
-rw-r--r--Source/CPack/cmCPackGenerator.cxx44
1 files changed, 43 insertions, 1 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index 0abb0ff..7c3ff1d 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -330,6 +330,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
it != installDirectoriesVector.end();
++it )
{
+ std::list<std::pair<std::string,std::string> > symlinkedFiles;
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl);
cmsys::Glob gl;
std::string top = it->c_str();
@@ -373,7 +374,18 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
+ cmSystemTools::RelativePath(top.c_str(), gfit->c_str());
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: "
<< inFile.c_str() << " -> " << filePath.c_str() << std::endl);
- if ( !cmSystemTools::CopyFileIfDifferent(inFile.c_str(),
+ /* If the file is a symlink we will have to re-create it */
+ if ( cmSystemTools::FileIsSymlink(inFile.c_str()))
+ {
+ std::string targetFile;
+ std::string inFileRelative =
+ cmSystemTools::RelativePath(top.c_str(),inFile.c_str());
+ cmSystemTools::ReadSymlink(inFile.c_str(),targetFile);
+ symlinkedFiles.push_back(std::pair<std::string,
+ std::string>(targetFile,inFileRelative));
+ }
+ /* If it is not a symlink then do a plain copy */
+ else if ( !cmSystemTools::CopyFileIfDifferent(inFile.c_str(),
filePath.c_str()) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: "
@@ -381,6 +393,36 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
return 0;
}
}
+ /* rebuild symlinks in the installed tree */
+ if (symlinkedFiles.size()>0)
+ {
+ std::list< std::pair<std::string,std::string> >::iterator symlinkedIt;
+ std::string curDir = cmSystemTools::GetCurrentWorkingDirectory();
+ std::string goToDir = tempDir;
+ goToDir += "/"+subdir;
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "Change dir to: " << goToDir <<std::endl);
+ cmSystemTools::ChangeDirectory(goToDir.c_str());
+ for (symlinkedIt=symlinkedFiles.begin();
+ symlinkedIt != symlinkedFiles.end();
+ ++symlinkedIt)
+ {
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Will create a symlink: "
+ << symlinkedIt->second << "--> "
+ << symlinkedIt->first << std::endl);
+ if (!cmSystemTools::CreateSymlink((symlinkedIt->first).c_str(),
+ (symlinkedIt->second).c_str()))
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create symlink: "
+ << symlinkedIt->second << "--> "
+ << symlinkedIt->first << std::endl);
+ return 0;
+ }
+ }
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Going back to: "
+ << curDir <<std::endl);
+ cmSystemTools::ChangeDirectory(curDir.c_str());
+ }
}
}
return 1;