CPack: Fix packaging of source tarballs with symbolic links

When staging the package installation, if the first file in a directory
happens to be a symbolic link, make sure we create the directory before
trying to create the link.
This commit is contained in:
Bill Hoffman 2015-01-29 11:52:30 -05:00 committed by Brad King
parent 57622bd19d
commit 4dc5acee63
1 changed files with 12 additions and 0 deletions

View File

@ -437,6 +437,18 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Will create a symlink: "
<< symlinkedIt->second << "--> "
<< symlinkedIt->first << std::endl);
// make sure directory exists for symlink
std::string destDir =
cmSystemTools::GetFilenamePath(symlinkedIt->second);
if(!destDir.empty() && !cmSystemTools::MakeDirectory(destDir))
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create dir: "
<< destDir
<< "\nTrying to create symlink: "
<< symlinkedIt->second << "--> "
<< symlinkedIt->first
<< std::endl);
}
if (!cmSystemTools::CreateSymlink((symlinkedIt->first).c_str(),
(symlinkedIt->second).c_str()))
{