summaryrefslogtreecommitdiffstats
path: root/Source/cmFileCommand.cxx
diff options
context:
space:
mode:
authorTushar Maheshwari <tushar27192@gmail.com>2019-01-15 15:04:46 (GMT)
committerBrad King <brad.king@kitware.com>2019-01-16 15:03:35 (GMT)
commit0f08ed89362d207e18b06e806f127cd683b79141 (patch)
tree890884ead135d0000f4cce22b5970d178ffd5411 /Source/cmFileCommand.cxx
parent593d986470ce1938436da312e0c93e3c9c07017e (diff)
downloadCMake-0f08ed89362d207e18b06e806f127cd683b79141.zip
CMake-0f08ed89362d207e18b06e806f127cd683b79141.tar.gz
CMake-0f08ed89362d207e18b06e806f127cd683b79141.tar.bz2
cmSystemTools: Silence CreateLink and CreateSymlink errors
If provided, report errors to a std::string. This allows "silent" fallback to another flow, like COPY_ON_ERROR.
Diffstat (limited to 'Source/cmFileCommand.cxx')
-rw-r--r--Source/cmFileCommand.cxx28
1 files changed, 13 insertions, 15 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 2cdf827..999af54 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -3760,34 +3760,32 @@ bool cmFileCommand::HandleCreateLinkCommand(
// Check if the command requires a symbolic link.
if (symbolicArg.IsEnabled()) {
- completed = cmSystemTools::CreateSymlink(fileName, newFileName);
+ completed = cmSystemTools::CreateSymlink(fileName, newFileName, &result);
} else {
- completed = cmSystemTools::CreateLink(fileName, newFileName);
+ completed = cmSystemTools::CreateLink(fileName, newFileName, &result);
}
- if (!completed) {
- // The link method did not succeed. Get the error message.
- result = "Link failed: " + cmSystemTools::GetLastSystemError();
-
- // Check if copy-on-error is enabled in the arguments.
- if (copyOnErrorArg.IsEnabled()) {
- completed =
- cmSystemTools::cmCopyFile(fileName.c_str(), newFileName.c_str());
- if (!completed) {
- result = "Copy failed: " + cmSystemTools::GetLastSystemError();
- }
+ // Check if copy-on-error is enabled in the arguments.
+ if (!completed && copyOnErrorArg.IsEnabled()) {
+ completed =
+ cmSystemTools::cmCopyFile(fileName.c_str(), newFileName.c_str());
+ if (!completed) {
+ result = "Copy failed: " + cmSystemTools::GetLastSystemError();
}
}
// Check if the operation was successful.
if (completed) {
result = "0";
+ } else if (resultVar.empty()) {
+ // The operation failed and the result is not reported in a variable.
+ this->SetError(result);
+ return false;
}
if (!resultVar.empty()) {
this->Makefile->AddDefinition(resultVar, result.c_str());
- return true;
}
- return completed;
+ return true;
}