cmake -E cmake_symlink_library fails without error message

Brad King brad.king at kitware.com
Mon Mar 2 22:36:30 CET 2009


David Faure wrote:
> On Monday 02 March 2009, Brad King wrote:
>> Alexander Neundorf wrote:
>>> On Monday 02 March 2009, you wrote:
>>>> On Monday 02 March 2009, Alexander Neundorf wrote:
>>>>> Can you please put this in the cmake bug tracker so it doesn't get lost ?
>>>> I was hoping for a quick fix :-)
>>>>
>>>> Oh well -- http://public.kitware.com:80/Bug/view.php?id=8654
>>> Well, I'm leaving for Cebit tomorrow in the morning and won't be back before 
>>> sunday...
>> I've fixed/closed the issue.
>  
> That was quick indeed, thanks a lot ;)
> 
> I will test the fix once it's backported to CMake-2-6 branch
> (which seems planned but not done yet).

Only Bill Hoffman can commit to the 2.6 branch.  He commits to it only in
batches to create release candidates.  I keep my changes in a private git
repo on a 2.6 tracking branch and send him patches when he does RCs.
My patch against 2.6 is below.

-Brad

commit e0a8bff0e2f278749c183debab4f25ba7191b0f0
Author: Brad King <brad.king at kitware.com>
Date:   Mon Mar 2 15:57:35 2009 -0500

     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.

diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 697eca6..d4a4f65 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -1363,24 +1363,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;
            }
          }
@@ -1395,12 +1399,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;
            }
          }



More information about the Kde-buildsystem mailing list