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.
This commit is contained in:
Brad King 2009-03-06 09:14:57 -05:00
parent 73bea67fd3
commit 2123b432d9
1 changed files with 10 additions and 3 deletions

View File

@ -2185,13 +2185,20 @@ bool cmFileCommand::HandleRemove(std::vector<std::string> 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;