MantisBT - CMake
View Issue Details
0010538CMakeCMakepublic2010-04-12 13:012013-11-04 09:33
Jonan 
Brad King 
normalminoralways
closedfixed 
CMake-2-8 
CMake 2.8.11CMake 2.8.11 
0010538: 'make clean' removes content in symbolic links
I have a folder with some files that are needed for my program to run, so I create a symbolic link in the build directory to that folder.

This works fine, but if a run 'make clean' the content inside that folder is erased, that means the original content in the source directory is gone too.
No tags attached.
has duplicate 0013911closed Brad King cmake uses REMOVE_RECURSE instead of REMOVE for symlinks 
Issue History
2010-04-12 13:01JonanNew Issue
2011-01-17 15:46David ColeAssigned To => David Cole
2011-01-17 15:46David ColeStatusnew => assigned
2011-01-17 15:47David ColeNote Added: 0024806
2011-01-17 15:47David ColeStatusassigned => resolved
2011-01-17 15:47David ColeFixed in Version => CMake 2.8.4
2011-01-17 15:47David ColeResolutionopen => unable to reproduce
2011-05-02 14:46David ColeNote Added: 0026350
2011-05-02 14:46David ColeStatusresolved => closed
2011-12-18 11:12JonanNote Added: 0028004
2011-12-18 11:12JonanStatusclosed => feedback
2011-12-18 11:12JonanResolutionunable to reproduce => reopened
2012-06-01 16:32David ColeAssigned ToDavid Cole =>
2012-06-01 16:43Brad KingNote Added: 0029596
2013-02-13 10:03Brad KingRelationship addedhas duplicate 0013911
2013-02-13 10:04Brad KingNote Added: 0032254
2013-02-13 10:04Brad KingAssigned To => Brad King
2013-02-13 10:04Brad KingStatusfeedback => resolved
2013-02-13 10:04Brad KingResolutionreopened => fixed
2013-02-13 10:04Brad KingFixed in VersionCMake 2.8.4 => CMake 2.8.11
2013-02-13 10:04Brad KingTarget Version => CMake 2.8.11
2013-11-04 09:33Robert MaynardNote Added: 0034370
2013-11-04 09:33Robert MaynardStatusresolved => closed

Notes
(0024806)
David Cole   
2011-01-17 15:47   
Cannot reproduce this here. Can you give more details or exact steps to follow to reproduce this problem here?
(0026350)
David Cole   
2011-05-02 14:46   
Closing resolved issues that have not been updated in more than 3 months.
(0028004)
Jonan   
2011-12-18 11:12   
This bug is still reproducible in 2.8.5.

In my project I have something like this:

add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/media
COMMAND ${CMAKE_COMMAND} -E create_symlink ${PROJECT_SOURCE_DIR}/media ${PROJECT_BINARY_DIR}/media
)

This way I don't have to copy the media files to every build directory.
When I run 'make clean' I expect the symbolic link to be deleted, but instead I find that the link is still there but all the files in the original folder are deleted.
(0029596)
Brad King   
2012-06-01 16:43   
Try this patch:

diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index d69431e..117c26e 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2405,7 +2405,8 @@ bool cmFileCommand::HandleRemove(std::vector<std::string> const& args,
       
fileName += "/" + *i;
       }
 
-    if(cmSystemTools::FileIsDirectory(fileName.c_str()) && recurse)
+    if(cmSystemTools::FileIsDirectory(fileName.c_str()) &&
+       !cmSystemTools::FileIsSymlink(fileName.c_str()) && recurse)
       {
       cmSystemTools::RemoveADirectory(fileName.c_str());
       }


It probably should have been done along with this change a long time ago:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eee2d2b0 [^]
(0032254)
Brad King   
2013-02-13 10:04   
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f1233672 [^]
(0034370)
Robert Maynard   
2013-11-04 09:33   
Closing resolved issues that have not been updated in more than 4 months.