diff options
author | Brad King <brad.king@kitware.com> | 2021-04-15 16:39:57 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-04-15 16:40:37 (GMT) |
commit | 79a2f1e22a4ff95d7d96478d579a7f52b3c289da (patch) | |
tree | 664981235332ac590cafa4d3ff5518893f40fdd0 /Source | |
parent | 7f89053953f81aaa3d0283ba4b8d8b29ce234292 (diff) | |
download | CMake-79a2f1e22a4ff95d7d96478d579a7f52b3c289da.zip CMake-79a2f1e22a4ff95d7d96478d579a7f52b3c289da.tar.gz CMake-79a2f1e22a4ff95d7d96478d579a7f52b3c289da.tar.bz2 |
cmcmd: Improve error message from cmake_symlink_{library,executable}
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmcmd.cxx | 23 | ||||
-rw-r--r-- | Source/cmcmd.h | 6 |
2 files changed, 19 insertions, 10 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index a47eccd..928435e 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1601,14 +1601,18 @@ int cmcmd::SymlinkLibrary(std::vector<std::string> const& args) cmSystemTools::ConvertToUnixSlashes(soName); cmSystemTools::ConvertToUnixSlashes(name); if (soName != realName) { - if (!cmcmd::SymlinkInternal(realName, soName)) { - cmSystemTools::ReportLastSystemError("cmake_symlink_library"); + cmsys::Status status = cmcmd::SymlinkInternal(realName, soName); + if (!status) { + cmSystemTools::Error( + cmStrCat("cmake_symlink_library: System Error: ", status.GetString())); result = 1; } } if (name != soName) { - if (!cmcmd::SymlinkInternal(soName, name)) { - cmSystemTools::ReportLastSystemError("cmake_symlink_library"); + cmsys::Status status = cmcmd::SymlinkInternal(soName, name); + if (!status) { + cmSystemTools::Error( + cmStrCat("cmake_symlink_library: System Error: ", status.GetString())); result = 1; } } @@ -1621,21 +1625,24 @@ int cmcmd::SymlinkExecutable(std::vector<std::string> const& args) std::string const& realName = args[2]; std::string const& name = args[3]; if (name != realName) { - if (!cmcmd::SymlinkInternal(realName, name)) { - cmSystemTools::ReportLastSystemError("cmake_symlink_executable"); + cmsys::Status status = cmcmd::SymlinkInternal(realName, name); + if (!status) { + cmSystemTools::Error(cmStrCat("cmake_symlink_executable: System Error: ", + status.GetString())); result = 1; } } return result; } -bool cmcmd::SymlinkInternal(std::string const& file, std::string const& link) +cmsys::Status cmcmd::SymlinkInternal(std::string const& file, + std::string const& link) { if (cmSystemTools::FileExists(link) || cmSystemTools::FileIsSymlink(link)) { cmSystemTools::RemoveFile(link); } #if defined(_WIN32) && !defined(__CYGWIN__) - return static_cast<bool>(cmSystemTools::CopyFileAlways(file, link)); + return cmSystemTools::CopyFileAlways(file, link); #else std::string linktext = cmSystemTools::GetFilenameName(file); return cmSystemTools::CreateSymlink(linktext, link); diff --git a/Source/cmcmd.h b/Source/cmcmd.h index a2e0b1e..ba78edb 100644 --- a/Source/cmcmd.h +++ b/Source/cmcmd.h @@ -8,6 +8,8 @@ #include <string> #include <vector> +#include "cmsys/Status.hxx" + #include "cmCryptoHash.h" class cmConsoleBuf; @@ -28,8 +30,8 @@ protected: cmCryptoHash::Algo algo); static int SymlinkLibrary(std::vector<std::string> const& args); static int SymlinkExecutable(std::vector<std::string> const& args); - static bool SymlinkInternal(std::string const& file, - std::string const& link); + static cmsys::Status SymlinkInternal(std::string const& file, + std::string const& link); static int ExecuteEchoColor(std::vector<std::string> const& args); static int ExecuteLinkScript(std::vector<std::string> const& args); static int WindowsCEEnvironment(const char* version, |