From 2123b432d9806f8d3cebeeb897875f124f8c39c3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 6 Mar 2009 09:14:57 -0500 Subject: ENH: Teach file(REMOVE) how to use relative paths This teaches the command to interpret relative paths with respect to the location of the invoking CMakeLists.txt file. The convention is already used by most commands and won't change the behavior in script mode. --- Source/cmFileCommand.cxx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 78fc088..ab8edda 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2185,13 +2185,20 @@ bool cmFileCommand::HandleRemove(std::vector const& args, i++; // Get rid of subcommand for(;i != args.end(); ++i) { - if(cmSystemTools::FileIsDirectory(i->c_str()) && recurse) + std::string fileName = *i; + if(!cmsys::SystemTools::FileIsFullPath(fileName.c_str())) { - cmSystemTools::RemoveADirectory(i->c_str()); + fileName = this->Makefile->GetCurrentDirectory(); + fileName += "/" + *i; + } + + if(cmSystemTools::FileIsDirectory(fileName.c_str()) && recurse) + { + cmSystemTools::RemoveADirectory(fileName.c_str()); } else { - cmSystemTools::RemoveFile(i->c_str()); + cmSystemTools::RemoveFile(fileName.c_str()); } } return true; -- cgit v0.12