Commit ffc0b5e4 authored by Andy Cedilnik's avatar Andy Cedilnik

BUG: Overwrite the symlink if it already exists. Close Bug #4418 - cmake...

BUG: Overwrite the symlink if it already exists. Close Bug #4418 - cmake -create-symlink doesn't overwrite existing symlinks
parent 7c72e03c
......@@ -1072,6 +1072,22 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
// supporting them.
else if (args[1] == "create_symlink" && args.size() == 4)
{
const char* destinationFileName = args[3].c_str();
if ( cmSystemTools::FileExists(destinationFileName) )
{
if ( cmSystemTools::FileIsSymlink(destinationFileName) )
{
if ( !cmSystemTools::RemoveFile(destinationFileName) ||
cmSystemTools::FileExists(destinationFileName) )
{
return 0;
}
}
else
{
return 0;
}
}
return cmSystemTools::CreateSymlink(args[2].c_str(),
args[3].c_str())? 0:1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment