diff options
author | Brad King <brad.king@kitware.com> | 2009-03-02 21:02:19 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-03-02 21:02:19 (GMT) |
commit | ed5e4d8be2aef9912b8fb7f3af8d9a963318879f (patch) | |
tree | db623d2ed8cc2670610ab22aa42215978ea87457 /Source/cmake.cxx | |
parent | 91a8569648aba920a4b168eb25e946ca012a93ba (diff) | |
download | CMake-ed5e4d8be2aef9912b8fb7f3af8d9a963318879f.zip CMake-ed5e4d8be2aef9912b8fb7f3af8d9a963318879f.tar.gz CMake-ed5e4d8be2aef9912b8fb7f3af8d9a963318879f.tar.bz2 |
BUG: Gracefully handle broken version symlinks
This teaches the helper commands 'cmake -E cmake_symlink_executable' and
'cmake -E cmake_symlink_library' to remove broken symlinks before
creating a symlink and report an error when the symlink cannot be
created. See issue #8654.
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 1df573e..9a81138 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1366,24 +1366,28 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) if(soName != realName) { std::string fname = cmSystemTools::GetFilenameName(realName); - if(cmSystemTools::FileExists(soName.c_str())) + if(cmSystemTools::FileExists(soName.c_str()) || + cmSystemTools::FileIsSymlink(soName.c_str())) { cmSystemTools::RemoveFile(soName.c_str()); } if(!cmSystemTools::CreateSymlink(fname.c_str(), soName.c_str())) { + cmSystemTools::ReportLastSystemError("cmake_symlink_library"); result = 1; } } if(name != soName) { std::string fname = cmSystemTools::GetFilenameName(soName); - if(cmSystemTools::FileExists(soName.c_str())) + if(cmSystemTools::FileExists(name.c_str()) || + cmSystemTools::FileIsSymlink(name.c_str())) { cmSystemTools::RemoveFile(name.c_str()); } if(!cmSystemTools::CreateSymlink(fname.c_str(), name.c_str())) { + cmSystemTools::ReportLastSystemError("cmake_symlink_library"); result = 1; } } @@ -1398,12 +1402,14 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) if(name != realName) { std::string fname = cmSystemTools::GetFilenameName(realName); - if(cmSystemTools::FileExists(realName.c_str())) + if(cmSystemTools::FileExists(name.c_str()) || + cmSystemTools::FileIsSymlink(name.c_str())) { cmSystemTools::RemoveFile(name.c_str()); } if(!cmSystemTools::CreateSymlink(fname.c_str(), name.c_str())) { + cmSystemTools::ReportLastSystemError("cmake_symlink_executable"); result = 1; } } |