ENH: Patch from Alex to provide nicer syntax for FILE_IS_NEWER. Using name IS_NEWER_THAN so old syntax will continue to work.
This commit is contained in:
parent
0c52510f21
commit
d1a9c93119
@ -493,6 +493,29 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
|
|||||||
reducible = 1;
|
reducible = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// is file A newer than file B
|
||||||
|
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
|
||||||
|
*(argP1) == "IS_NEWER_THAN")
|
||||||
|
{
|
||||||
|
int fileIsNewer=0;
|
||||||
|
bool success=cmSystemTools::FileTimeCompare(arg->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;
|
||||||
|
}
|
||||||
|
|
||||||
++arg;
|
++arg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,6 +130,7 @@ public:
|
|||||||
"True if the named file or directory exists. "
|
"True if the named file or directory exists. "
|
||||||
"Behavior is well-defined only for full paths.\n"
|
"Behavior is well-defined only for full paths.\n"
|
||||||
" IF(FILE_IS_NEWER file1 file2)\n"
|
" IF(FILE_IS_NEWER file1 file2)\n"
|
||||||
|
" IF(file1 IS_NEWER_THAN file2)\n"
|
||||||
"True if file1 is newer than file2 or if one of the two files "
|
"True if file1 is newer than file2 or if one of the two files "
|
||||||
"doesn't exist. "
|
"doesn't exist. "
|
||||||
"Behavior is well-defined only for full paths.\n"
|
"Behavior is well-defined only for full paths.\n"
|
||||||
|
@ -79,6 +79,9 @@ ENDFOREACH(var)
|
|||||||
IF(NOT FILE_IS_NEWER "${file}" "${CMAKE_CURRENT_SOURCE_DIR}/InputFile.h.in")
|
IF(NOT FILE_IS_NEWER "${file}" "${CMAKE_CURRENT_SOURCE_DIR}/InputFile.h.in")
|
||||||
MESSAGE(FATAL_ERROR "IF(FILE_IS_NEWER) does not seem to work.")
|
MESSAGE(FATAL_ERROR "IF(FILE_IS_NEWER) does not seem to work.")
|
||||||
ENDIF(NOT FILE_IS_NEWER "${file}" "${CMAKE_CURRENT_SOURCE_DIR}/InputFile.h.in")
|
ENDIF(NOT FILE_IS_NEWER "${file}" "${CMAKE_CURRENT_SOURCE_DIR}/InputFile.h.in")
|
||||||
|
IF(NOT "${file}" IS_NEWER_THAN "${CMAKE_CURRENT_SOURCE_DIR}/InputFile.h.in")
|
||||||
|
MESSAGE(FATAL_ERROR "IF(FILE_IS_NEWER) does not seem to work.")
|
||||||
|
ENDIF(NOT "${file}" IS_NEWER_THAN "${CMAKE_CURRENT_SOURCE_DIR}/InputFile.h.in")
|
||||||
|
|
||||||
# Test configuration of the string
|
# Test configuration of the string
|
||||||
SET(TEST_DEFINED 123)
|
SET(TEST_DEFINED 123)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user