summaryrefslogtreecommitdiffstats
path: root/Source/cmIfCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2006-08-25 20:31:07 (GMT)
committerBrad King <brad.king@kitware.com>2006-08-25 20:31:07 (GMT)
commit6449089436d16406f35f1ee9aef33c07ca89785e (patch)
tree8886177e6b9e0e1fab6cde440fe97a1eb7064986 /Source/cmIfCommand.cxx
parentebf532b106fed4bb4c2993be43e3ec2a42573f6b (diff)
downloadCMake-6449089436d16406f35f1ee9aef33c07ca89785e.zip
CMake-6449089436d16406f35f1ee9aef33c07ca89785e.tar.gz
CMake-6449089436d16406f35f1ee9aef33c07ca89785e.tar.bz2
ENH: Patch from Alex for adding IF(FILE_IS_NEWER). I also added a test.
Diffstat (limited to 'Source/cmIfCommand.cxx')
-rw-r--r--Source/cmIfCommand.cxx23
1 files changed, 22 insertions, 1 deletions
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index e745735..c9a6c08 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -226,7 +226,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
IncrementArguments(newArgs,argP1,argP2);
reducible = 1;
}
- // does a file exist
+ // does a directory with this name exist
if (*arg == "IS_DIRECTORY" && argP1 != newArgs.end())
{
if(cmSystemTools::FileIsDirectory((argP1)->c_str()))
@@ -242,6 +242,27 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
IncrementArguments(newArgs,argP1,argP2);
reducible = 1;
}
+ // is file A newer than file B
+ if (*arg == "FILE_IS_NEWER" && argP1 != newArgs.end() && argP2 != newArgs.end())
+ {
+ int fileIsNewer=0;
+ bool success=cmSystemTools::FileTimeCompare((argP1)->c_str(), (argP2)->c_str(),
+ &fileIsNewer);
+ if(success==false || fileIsNewer==1 || fileIsNewer==0)
+ {
+ *arg = "1";
+ }
+ else
+ {
+ *arg = "0";
+ }
+
+ newArgs.erase(argP2);
+ newArgs.erase(argP1);
+ argP1 = arg;
+ IncrementArguments(newArgs,argP1,argP2);
+ reducible = 1;
+ }
// does a command exist
if (*arg == "COMMAND" && argP1 != newArgs.end())
{