summaryrefslogtreecommitdiffstats
path: root/Source/cmFileCommand.cxx
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2005-10-17 13:10:20 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2005-10-17 13:10:20 (GMT)
commit6e5cdd6de72de0d9d8f91c9971f0c13e10511c73 (patch)
tree03b8912732fb9070de978fc883cfb8e70ade305d /Source/cmFileCommand.cxx
parent33ac18891ff73863b088ca3f373eb90620637c11 (diff)
downloadCMake-6e5cdd6de72de0d9d8f91c9971f0c13e10511c73.zip
CMake-6e5cdd6de72de0d9d8f91c9971f0c13e10511c73.tar.gz
CMake-6e5cdd6de72de0d9d8f91c9971f0c13e10511c73.tar.bz2
ENH: Add regular string replace (not regex), and relative path command. Also add tests
Diffstat (limited to 'Source/cmFileCommand.cxx')
-rw-r--r--Source/cmFileCommand.cxx39
1 files changed, 39 insertions, 0 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 8b9daa2..4a06cb4 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -58,6 +58,10 @@ bool cmFileCommand::InitialPass(std::vector<std::string> const& args)
{
return this->HandleInstallCommand(args);
}
+ else if ( subCommand == "RELATIVE_PATH" )
+ {
+ return this->HandleRelativePathCommand(args);
+ }
std::string e = "does not recognize sub-command "+subCommand;
this->SetError(e.c_str());
@@ -696,3 +700,38 @@ bool cmFileCommand::HandleInstallCommand(
return true;
}
+
+//----------------------------------------------------------------------------
+bool cmFileCommand::HandleRelativePathCommand(
+ std::vector<std::string> const& args)
+{
+ if(args.size() != 4 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+
+ const std::string& outVar = args[1];
+ const std::string& directoryName = args[2];
+ const std::string& fileName = args[3];
+
+ if(!cmSystemTools::FileIsFullPath(directoryName.c_str()))
+ {
+ std::string errstring = "RelativePath must be passed a full path to the directory: " + directoryName;
+ this->SetError(errstring.c_str());
+ return false;
+ }
+ if(!cmSystemTools::FileIsFullPath(fileName.c_str()))
+ {
+ std::string errstring = "RelativePath must be passed a full path to the directory: " + directoryName;
+ this->SetError(errstring.c_str());
+ return false;
+ }
+
+ std::string res = cmSystemTools::RelativePath(directoryName.c_str(), fileName.c_str());
+ m_Makefile->AddDefinition(outVar.c_str(),
+ res.c_str());
+ return true;
+}
+
+