Merge topic 'add-extra-boolean-comparisons'

02d177c9 Add additional <= and >= comparison operators
This commit is contained in:
Brad King 2016-08-10 11:15:47 -04:00 committed by CMake Topic Stage
commit 4887640b7a
18 changed files with 703 additions and 89 deletions

View File

@ -30,10 +30,12 @@ else and endif clause is optional. Long expressions can be used and
there is a traditional order of precedence. Parenthetical expressions there is a traditional order of precedence. Parenthetical expressions
are evaluated first followed by unary tests such as ``EXISTS``, are evaluated first followed by unary tests such as ``EXISTS``,
``COMMAND``, and ``DEFINED``. Then any binary tests such as ``COMMAND``, and ``DEFINED``. Then any binary tests such as
``EQUAL``, ``LESS``, ``GREATER``, ``STRLESS``, ``STRGREATER``, ``EQUAL``, ``LESS``, ``LESS_EQUAL, ``GREATER``, ``GREATER_EQUAL``,
``STREQUAL``, and ``MATCHES`` will be evaluated. Then boolean ``NOT`` ``STREQUAL``, ``STRLESS``, ``STRLESS_EQUAL``, ``STRGREATER``,
operators and finally boolean ``AND`` and then ``OR`` operators will ``STRGREATER_EQUAL``, ``VERSION_EQUAL``, ``VERSION_LESS``,
be evaluated. ``VERSION_LESS_EQUAL``, ``VERSION_GREATER``, ``VERSION_GREATER_EQUAL``,
and ``MATCHES`` will be evaluated. Then boolean ``NOT`` operators and
finally boolean ``AND`` and then ``OR`` operators will be evaluated.
Possible expressions are: Possible expressions are:
@ -115,6 +117,14 @@ Possible expressions are:
True if the given string or variable's value is a valid number and equal True if the given string or variable's value is a valid number and equal
to that on the right. to that on the right.
``if(<variable|string> LESS_EQUAL <variable|string>)``
True if the given string or variable's value is a valid number and less
than or equal to that on the right.
``if(<variable|string> GREATER_EQUAL <variable|string>)``
True if the given string or variable's value is a valid number and greater
than or equal to that on the right.
``if(<variable|string> STRLESS <variable|string>)`` ``if(<variable|string> STRLESS <variable|string>)``
True if the given string or variable's value is lexicographically less True if the given string or variable's value is lexicographically less
than the string or variable on the right. than the string or variable on the right.
@ -127,15 +137,31 @@ Possible expressions are:
True if the given string or variable's value is lexicographically equal True if the given string or variable's value is lexicographically equal
to the string or variable on the right. to the string or variable on the right.
``if(<variable|string> STRLESS_EQUAL <variable|string>)``
True if the given string or variable's value is lexicographically less
than or equal to the string or variable on the right.
``if(<variable|string> STRGREATER_EQUAL <variable|string>)``
True if the given string or variable's value is lexicographically greater
than or equal to the string or variable on the right.
``if(<variable|string> VERSION_LESS <variable|string>)`` ``if(<variable|string> VERSION_LESS <variable|string>)``
Component-wise integer version number comparison (version format is Component-wise integer version number comparison (version format is
``major[.minor[.patch[.tweak]]]``). ``major[.minor[.patch[.tweak]]]``).
``if(<variable|string> VERSION_GREATER <variable|string>)``
Component-wise integer version number comparison (version format is
``major[.minor[.patch[.tweak]]]``).
``if(<variable|string> VERSION_EQUAL <variable|string>)`` ``if(<variable|string> VERSION_EQUAL <variable|string>)``
Component-wise integer version number comparison (version format is Component-wise integer version number comparison (version format is
``major[.minor[.patch[.tweak]]]``). ``major[.minor[.patch[.tweak]]]``).
``if(<variable|string> VERSION_GREATER <variable|string>)`` ``if(<variable|string> VERSION_LESS_EQUAL <variable|string>)``
Component-wise integer version number comparison (version format is
``major[.minor[.patch[.tweak]]]``).
``if(<variable|string> VERSION_GREATER_EQUAL <variable|string>)``
Component-wise integer version number comparison (version format is Component-wise integer version number comparison (version format is
``major[.minor[.patch[.tweak]]]``). ``major[.minor[.patch[.tweak]]]``).
@ -186,20 +212,21 @@ above-documented signature accepts ``<variable|string>``:
* If the left hand argument to ``MATCHES`` is missing it returns false * If the left hand argument to ``MATCHES`` is missing it returns false
without error without error
* Both left and right hand arguments to ``LESS``, ``GREATER``, and * Both left and right hand arguments to ``LESS``, ``GREATER``, ``EQUAL``,
``EQUAL`` are independently tested to see if they are defined ``LESS_EQUAL``, and ``GREATER_EQUAL``, are independently tested to see if
variables, if so their defined values are used otherwise the original they are defined variables, if so their defined values are used otherwise
value is used. the original value is used.
* Both left and right hand arguments to ``STRLESS``, ``STREQUAL``, and * Both left and right hand arguments to ``STRLESS``, ``STRGREATER``,
``STRGREATER`` are independently tested to see if they are defined ``STREQUAL``, ``STRLESS_EQUAL``, and ``STRGREATER_EQUAL`` are independently
variables, if so their defined values are used otherwise the original tested to see if they are defined variables, if so their defined values are
value is used. used otherwise the original value is used.
* Both left and right hand arguments to ``VERSION_LESS``, * Both left and right hand arguments to ``VERSION_LESS``,
``VERSION_EQUAL``, and ``VERSION_GREATER`` are independently tested ``VERSION_GREATER``, ``VERSION_EQUAL``, ``VERSION_LESS_EQUAL``, and
to see if they are defined variables, if so their defined values are ``VERSION_GREATER_EQUAL`` are independently tested to see if they are defined
used otherwise the original value is used. variables, if so their defined values are used otherwise the original value
is used.
* The right hand argument to ``NOT`` is tested to see if it is a boolean * The right hand argument to ``NOT`` is tested to see if it is a boolean
constant, if so the value is used, otherwise it is assumed to be a constant, if so the value is used, otherwise it is assumed to be a

View File

@ -197,10 +197,12 @@ Comparison
:: ::
string(COMPARE EQUAL <string1> <string2> <output variable>)
string(COMPARE NOTEQUAL <string1> <string2> <output variable>)
string(COMPARE LESS <string1> <string2> <output variable>) string(COMPARE LESS <string1> <string2> <output variable>)
string(COMPARE GREATER <string1> <string2> <output variable>) string(COMPARE GREATER <string1> <string2> <output variable>)
string(COMPARE EQUAL <string1> <string2> <output variable>)
string(COMPARE NOTEQUAL <string1> <string2> <output variable>)
string(COMPARE LESS_EQUAL <string1> <string2> <output variable>)
string(COMPARE GREATER_EQUAL <string1> <string2> <output variable>)
Compare the strings and store true or false in the output variable. Compare the strings and store true or false in the output variable.

View File

@ -66,12 +66,16 @@ Available logical expressions are:
``1`` if the CMake-id of the C compiler matches ``comp``, otherwise ``0``. ``1`` if the CMake-id of the C compiler matches ``comp``, otherwise ``0``.
``$<CXX_COMPILER_ID:comp>`` ``$<CXX_COMPILER_ID:comp>``
``1`` if the CMake-id of the CXX compiler matches ``comp``, otherwise ``0``. ``1`` if the CMake-id of the CXX compiler matches ``comp``, otherwise ``0``.
``$<VERSION_GREATER:v1,v2>``
``1`` if ``v1`` is a version greater than ``v2``, else ``0``.
``$<VERSION_LESS:v1,v2>`` ``$<VERSION_LESS:v1,v2>``
``1`` if ``v1`` is a version less than ``v2``, else ``0``. ``1`` if ``v1`` is a version less than ``v2``, else ``0``.
``$<VERSION_GREATER:v1,v2>``
``1`` if ``v1`` is a version greater than ``v2``, else ``0``.
``$<VERSION_EQUAL:v1,v2>`` ``$<VERSION_EQUAL:v1,v2>``
``1`` if ``v1`` is the same version as ``v2``, else ``0``. ``1`` if ``v1`` is the same version as ``v2``, else ``0``.
``$<VERSION_LESS_EQUAL:v1,v2>``
``1`` if ``v1`` is a version less than or equal to ``v2``, else ``0``.
``$<VERSION_GREATER_EQUAL:v1,v2>``
``1`` if ``v1`` is a version greater than or equal to ``v2``, else ``0``.
``$<C_COMPILER_VERSION:ver>`` ``$<C_COMPILER_VERSION:ver>``
``1`` if the version of the C compiler matches ``ver``, otherwise ``0``. ``1`` if the version of the C compiler matches ``ver``, otherwise ``0``.
``$<CXX_COMPILER_VERSION:ver>`` ``$<CXX_COMPILER_VERSION:ver>``

View File

@ -0,0 +1,6 @@
add-extra-boolean-comparisons
-----------------------------
* The :command:`if` command gained new boolean comparison operations
``LESS_EQUAL``, ``GREATER_EQUAL``, ``STRLESS_EQUAL``, ``STRGREATER_EQUAL``,
``VERSION_LESS_EQUAL``, and ``VERSION_GREATER_EQUAL``.

View File

@ -26,11 +26,11 @@ Individual component values are also available in variables:
* :variable:`CMAKE_PATCH_VERSION` * :variable:`CMAKE_PATCH_VERSION`
* :variable:`CMAKE_TWEAK_VERSION` * :variable:`CMAKE_TWEAK_VERSION`
Use the :command:`if` command ``VERSION_LESS``, ``VERSION_EQUAL``, or Use the :command:`if` command ``VERSION_LESS``, ``VERSION_GREATER``,
``VERSION_GREATER`` operators to compare version string values against ``VERSION_EQUAL``, ``VERSION_LESS_EQUAL``, or ``VERSION_GREATER_EQUAL``
``CMAKE_VERSION`` using a component-wise test. Version component operators to compare version string values against ``CMAKE_VERSION`` using a
values may be 10 or larger so do not attempt to compare version component-wise test. Version component values may be 10 or larger so do not
strings as floating-point numbers. attempt to compare version strings as floating-point numbers.
.. note:: .. note::

View File

@ -366,11 +366,8 @@ bool cmCTest::ShouldCompressTestOutput()
if (!this->ComputedCompressTestOutput) { if (!this->ComputedCompressTestOutput) {
std::string cdashVersion = this->GetCDashVersion(); std::string cdashVersion = this->GetCDashVersion();
// version >= 1.6? // version >= 1.6?
bool cdashSupportsGzip = bool cdashSupportsGzip = cmSystemTools::VersionCompare(
cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER, cmSystemTools::OP_GREATER_EQUAL, cdashVersion.c_str(), "1.6");
cdashVersion.c_str(), "1.6") ||
cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
cdashVersion.c_str(), "1.6");
this->CompressTestOutput &= cdashSupportsGzip; this->CompressTestOutput &= cdashSupportsGzip;
this->ComputedCompressTestOutput = true; this->ComputedCompressTestOutput = true;
} }

View File

@ -21,12 +21,14 @@ static std::string const keyDEFINED = "DEFINED";
static std::string const keyEQUAL = "EQUAL"; static std::string const keyEQUAL = "EQUAL";
static std::string const keyEXISTS = "EXISTS"; static std::string const keyEXISTS = "EXISTS";
static std::string const keyGREATER = "GREATER"; static std::string const keyGREATER = "GREATER";
static std::string const keyGREATER_EQUAL = "GREATER_EQUAL";
static std::string const keyIN_LIST = "IN_LIST"; static std::string const keyIN_LIST = "IN_LIST";
static std::string const keyIS_ABSOLUTE = "IS_ABSOLUTE"; static std::string const keyIS_ABSOLUTE = "IS_ABSOLUTE";
static std::string const keyIS_DIRECTORY = "IS_DIRECTORY"; static std::string const keyIS_DIRECTORY = "IS_DIRECTORY";
static std::string const keyIS_NEWER_THAN = "IS_NEWER_THAN"; static std::string const keyIS_NEWER_THAN = "IS_NEWER_THAN";
static std::string const keyIS_SYMLINK = "IS_SYMLINK"; static std::string const keyIS_SYMLINK = "IS_SYMLINK";
static std::string const keyLESS = "LESS"; static std::string const keyLESS = "LESS";
static std::string const keyLESS_EQUAL = "LESS_EQUAL";
static std::string const keyMATCHES = "MATCHES"; static std::string const keyMATCHES = "MATCHES";
static std::string const keyNOT = "NOT"; static std::string const keyNOT = "NOT";
static std::string const keyOR = "OR"; static std::string const keyOR = "OR";
@ -35,12 +37,16 @@ static std::string const keyParenR = ")";
static std::string const keyPOLICY = "POLICY"; static std::string const keyPOLICY = "POLICY";
static std::string const keySTREQUAL = "STREQUAL"; static std::string const keySTREQUAL = "STREQUAL";
static std::string const keySTRGREATER = "STRGREATER"; static std::string const keySTRGREATER = "STRGREATER";
static std::string const keySTRGREATER_EQUAL = "STRGREATER_EQUAL";
static std::string const keySTRLESS = "STRLESS"; static std::string const keySTRLESS = "STRLESS";
static std::string const keySTRLESS_EQUAL = "STRLESS_EQUAL";
static std::string const keyTARGET = "TARGET"; static std::string const keyTARGET = "TARGET";
static std::string const keyTEST = "TEST"; static std::string const keyTEST = "TEST";
static std::string const keyVERSION_EQUAL = "VERSION_EQUAL"; static std::string const keyVERSION_EQUAL = "VERSION_EQUAL";
static std::string const keyVERSION_GREATER = "VERSION_GREATER"; static std::string const keyVERSION_GREATER = "VERSION_GREATER";
static std::string const keyVERSION_GREATER_EQUAL = "VERSION_GREATER_EQUAL";
static std::string const keyVERSION_LESS = "VERSION_LESS"; static std::string const keyVERSION_LESS = "VERSION_LESS";
static std::string const keyVERSION_LESS_EQUAL = "VERSION_LESS_EQUAL";
cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile, cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile,
const cmListFileContext& context, const cmListFileContext& context,
@ -559,7 +565,9 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs,
if (argP1 != newArgs.end() && argP2 != newArgs.end() && if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
(this->IsKeyword(keyLESS, *argP1) || (this->IsKeyword(keyLESS, *argP1) ||
this->IsKeyword(keyLESS_EQUAL, *argP1) ||
this->IsKeyword(keyGREATER, *argP1) || this->IsKeyword(keyGREATER, *argP1) ||
this->IsKeyword(keyGREATER_EQUAL, *argP1) ||
this->IsKeyword(keyEQUAL, *argP1))) { this->IsKeyword(keyEQUAL, *argP1))) {
def = this->GetVariableOrString(*arg); def = this->GetVariableOrString(*arg);
def2 = this->GetVariableOrString(*argP2); def2 = this->GetVariableOrString(*argP2);
@ -570,8 +578,12 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs,
result = false; result = false;
} else if (*(argP1) == keyLESS) { } else if (*(argP1) == keyLESS) {
result = (lhs < rhs); result = (lhs < rhs);
} else if (*(argP1) == keyLESS_EQUAL) {
result = (lhs <= rhs);
} else if (*(argP1) == keyGREATER) { } else if (*(argP1) == keyGREATER) {
result = (lhs > rhs); result = (lhs > rhs);
} else if (*(argP1) == keyGREATER_EQUAL) {
result = (lhs >= rhs);
} else { } else {
result = (lhs == rhs); result = (lhs == rhs);
} }
@ -580,16 +592,22 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs,
if (argP1 != newArgs.end() && argP2 != newArgs.end() && if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
(this->IsKeyword(keySTRLESS, *argP1) || (this->IsKeyword(keySTRLESS, *argP1) ||
this->IsKeyword(keySTREQUAL, *argP1) || this->IsKeyword(keySTRLESS_EQUAL, *argP1) ||
this->IsKeyword(keySTRGREATER, *argP1))) { this->IsKeyword(keySTRGREATER, *argP1) ||
this->IsKeyword(keySTRGREATER_EQUAL, *argP1) ||
this->IsKeyword(keySTREQUAL, *argP1))) {
def = this->GetVariableOrString(*arg); def = this->GetVariableOrString(*arg);
def2 = this->GetVariableOrString(*argP2); def2 = this->GetVariableOrString(*argP2);
int val = strcmp(def, def2); int val = strcmp(def, def2);
bool result; bool result;
if (*(argP1) == keySTRLESS) { if (*(argP1) == keySTRLESS) {
result = (val < 0); result = (val < 0);
} else if (*(argP1) == keySTRLESS_EQUAL) {
result = (val <= 0);
} else if (*(argP1) == keySTRGREATER) { } else if (*(argP1) == keySTRGREATER) {
result = (val > 0); result = (val > 0);
} else if (*(argP1) == keySTRGREATER_EQUAL) {
result = (val >= 0);
} else // strequal } else // strequal
{ {
result = (val == 0); result = (val == 0);
@ -599,15 +617,23 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs,
if (argP1 != newArgs.end() && argP2 != newArgs.end() && if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
(this->IsKeyword(keyVERSION_LESS, *argP1) || (this->IsKeyword(keyVERSION_LESS, *argP1) ||
this->IsKeyword(keyVERSION_LESS_EQUAL, *argP1) ||
this->IsKeyword(keyVERSION_GREATER, *argP1) || this->IsKeyword(keyVERSION_GREATER, *argP1) ||
this->IsKeyword(keyVERSION_GREATER_EQUAL, *argP1) ||
this->IsKeyword(keyVERSION_EQUAL, *argP1))) { this->IsKeyword(keyVERSION_EQUAL, *argP1))) {
def = this->GetVariableOrString(*arg); def = this->GetVariableOrString(*arg);
def2 = this->GetVariableOrString(*argP2); def2 = this->GetVariableOrString(*argP2);
cmSystemTools::CompareOp op = cmSystemTools::OP_EQUAL; cmSystemTools::CompareOp op;
if (*argP1 == keyVERSION_LESS) { if (*argP1 == keyVERSION_LESS) {
op = cmSystemTools::OP_LESS; op = cmSystemTools::OP_LESS;
} else if (*argP1 == keyVERSION_LESS_EQUAL) {
op = cmSystemTools::OP_LESS_EQUAL;
} else if (*argP1 == keyVERSION_GREATER) { } else if (*argP1 == keyVERSION_GREATER) {
op = cmSystemTools::OP_GREATER; op = cmSystemTools::OP_GREATER;
} else if (*argP1 == keyVERSION_GREATER_EQUAL) {
op = cmSystemTools::OP_GREATER_EQUAL;
} else { // version_equal
op = cmSystemTools::OP_EQUAL;
} }
bool result = cmSystemTools::VersionCompare(op, def, def2); bool result = cmSystemTools::VersionCompare(op, def, def2);
this->HandleBinaryOp(result, reducible, arg, newArgs, argP1, argP2); this->HandleBinaryOp(result, reducible, arg, newArgs, argP1, argP2);

View File

@ -545,6 +545,25 @@ static const struct VersionGreaterNode : public cmGeneratorExpressionNode
} }
} versionGreaterNode; } versionGreaterNode;
static const struct VersionGreaterEqNode : public cmGeneratorExpressionNode
{
VersionGreaterEqNode() {}
int NumExpectedParameters() const CM_OVERRIDE { return 2; }
std::string Evaluate(const std::vector<std::string>& parameters,
cmGeneratorExpressionContext*,
const GeneratorExpressionContent*,
cmGeneratorExpressionDAGChecker*) const CM_OVERRIDE
{
return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER_EQUAL,
parameters.front().c_str(),
parameters[1].c_str())
? "1"
: "0";
}
} versionGreaterEqNode;
static const struct VersionLessNode : public cmGeneratorExpressionNode static const struct VersionLessNode : public cmGeneratorExpressionNode
{ {
VersionLessNode() {} VersionLessNode() {}
@ -564,6 +583,25 @@ static const struct VersionLessNode : public cmGeneratorExpressionNode
} }
} versionLessNode; } versionLessNode;
static const struct VersionLessEqNode : public cmGeneratorExpressionNode
{
VersionLessEqNode() {}
int NumExpectedParameters() const CM_OVERRIDE { return 2; }
std::string Evaluate(const std::vector<std::string>& parameters,
cmGeneratorExpressionContext*,
const GeneratorExpressionContent*,
cmGeneratorExpressionDAGChecker*) const CM_OVERRIDE
{
return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS_EQUAL,
parameters.front().c_str(),
parameters[1].c_str())
? "1"
: "0";
}
} versionLessEqNode;
static const struct VersionEqualNode : public cmGeneratorExpressionNode static const struct VersionEqualNode : public cmGeneratorExpressionNode
{ {
VersionEqualNode() {} VersionEqualNode() {}
@ -1641,7 +1679,9 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode(
nodeMap["C_COMPILER_ID"] = &cCompilerIdNode; nodeMap["C_COMPILER_ID"] = &cCompilerIdNode;
nodeMap["CXX_COMPILER_ID"] = &cxxCompilerIdNode; nodeMap["CXX_COMPILER_ID"] = &cxxCompilerIdNode;
nodeMap["VERSION_GREATER"] = &versionGreaterNode; nodeMap["VERSION_GREATER"] = &versionGreaterNode;
nodeMap["VERSION_GREATER_EQUAL"] = &versionGreaterEqNode;
nodeMap["VERSION_LESS"] = &versionLessNode; nodeMap["VERSION_LESS"] = &versionLessNode;
nodeMap["VERSION_LESS_EQUAL"] = &versionLessEqNode;
nodeMap["VERSION_EQUAL"] = &versionEqualNode; nodeMap["VERSION_EQUAL"] = &versionEqualNode;
nodeMap["C_COMPILER_VERSION"] = &cCompilerVersionNode; nodeMap["C_COMPILER_VERSION"] = &cCompilerVersionNode;
nodeMap["CXX_COMPILER_VERSION"] = &cxxCompilerVersionNode; nodeMap["CXX_COMPILER_VERSION"] = &cxxCompilerVersionNode;

View File

@ -485,7 +485,8 @@ bool cmStringCommand::HandleCompareCommand(
} }
std::string mode = args[1]; std::string mode = args[1];
if ((mode == "EQUAL") || (mode == "NOTEQUAL") || (mode == "LESS") || if ((mode == "EQUAL") || (mode == "NOTEQUAL") || (mode == "LESS") ||
(mode == "GREATER")) { (mode == "LESS_EQUAL") || (mode == "GREATER") ||
(mode == "GREATER_EQUAL")) {
if (args.size() < 5) { if (args.size() < 5) {
std::string e = "sub-command COMPARE, mode "; std::string e = "sub-command COMPARE, mode ";
e += mode; e += mode;
@ -500,8 +501,12 @@ bool cmStringCommand::HandleCompareCommand(
bool result; bool result;
if (mode == "LESS") { if (mode == "LESS") {
result = (left < right); result = (left < right);
} else if (mode == "LESS_EQUAL") {
result = (left <= right);
} else if (mode == "GREATER") { } else if (mode == "GREATER") {
result = (left > right); result = (left > right);
} else if (mode == "GREATER_EQUAL") {
result = (left >= right);
} else if (mode == "EQUAL") { } else if (mode == "EQUAL") {
result = (left == right); result = (left == right);
} else // if(mode == "NOTEQUAL") } else // if(mode == "NOTEQUAL")

View File

@ -2380,10 +2380,10 @@ bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op,
if (lhs < rhs) { if (lhs < rhs) {
// lhs < rhs, so true if operation is LESS // lhs < rhs, so true if operation is LESS
return op == cmSystemTools::OP_LESS; return (op & cmSystemTools::OP_LESS) != 0;
} else if (lhs > rhs) { } else if (lhs > rhs) {
// lhs > rhs, so true if operation is GREATER // lhs > rhs, so true if operation is GREATER
return op == cmSystemTools::OP_GREATER; return (op & cmSystemTools::OP_GREATER) != 0;
} }
if (*endr == '.') { if (*endr == '.') {
@ -2395,7 +2395,7 @@ bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op,
} }
} }
// lhs == rhs, so true if operation is EQUAL // lhs == rhs, so true if operation is EQUAL
return op == cmSystemTools::OP_EQUAL; return (op & cmSystemTools::OP_EQUAL) != 0;
} }
bool cmSystemTools::VersionCompareEqual(std::string const& lhs, bool cmSystemTools::VersionCompareEqual(std::string const& lhs,
@ -2412,6 +2412,13 @@ bool cmSystemTools::VersionCompareGreater(std::string const& lhs,
rhs.c_str()); rhs.c_str());
} }
bool cmSystemTools::VersionCompareGreaterEq(std::string const& lhs,
std::string const& rhs)
{
return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER_EQUAL,
lhs.c_str(), rhs.c_str());
}
bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg, bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg,
bool* removed) bool* removed)
{ {

View File

@ -284,9 +284,11 @@ public:
enum CompareOp enum CompareOp
{ {
OP_LESS, OP_EQUAL = 1,
OP_GREATER, OP_LESS = 2,
OP_EQUAL OP_GREATER = 4,
OP_LESS_EQUAL = OP_LESS | OP_EQUAL,
OP_GREATER_EQUAL = OP_GREATER | OP_EQUAL
}; };
/** /**
@ -297,6 +299,8 @@ public:
std::string const& rhs); std::string const& rhs);
static bool VersionCompareGreater(std::string const& lhs, static bool VersionCompareGreater(std::string const& lhs,
std::string const& rhs); std::string const& rhs);
static bool VersionCompareGreaterEq(std::string const& lhs,
std::string const& rhs);
/** /**
* Determine the file type based on the extension * Determine the file type based on the extension

View File

@ -83,10 +83,24 @@ foreach(v IN LISTS LESSV)
message(FATAL_ERROR "${CMAKE_MATCH_2} is less than ${CMAKE_MATCH_1}?") message(FATAL_ERROR "${CMAKE_MATCH_2} is less than ${CMAKE_MATCH_1}?")
endif() endif()
# check greater or equal (same as less negative)
if(CMAKE_MATCH_2 VERSION_GREATER_EQUAL CMAKE_MATCH_1)
message(STATUS "${CMAKE_MATCH_2} is not less than ${CMAKE_MATCH_1}")
else()
message(FATAL_ERROR "${CMAKE_MATCH_2} is less than ${CMAKE_MATCH_1}?")
endif()
# check greater negative case # check greater negative case
if(NOT CMAKE_MATCH_1 VERSION_GREATER CMAKE_MATCH_2) if(NOT CMAKE_MATCH_1 VERSION_GREATER CMAKE_MATCH_2)
message(STATUS "${CMAKE_MATCH_1} is not greater than ${CMAKE_MATCH_2}") message(STATUS "${CMAKE_MATCH_1} is not greater than ${CMAKE_MATCH_2}")
else() else()
message(FATAL_ERROR "${CMAKE_MATCH_1} is greater than ${CMAKE_MATCH_2}?") message(FATAL_ERROR "${CMAKE_MATCH_1} is greater than ${CMAKE_MATCH_2}?")
endif() endif()
# check less or equal (same as greater negative) case
if(CMAKE_MATCH_1 VERSION_LESS_EQUAL CMAKE_MATCH_2)
message(STATUS "${CMAKE_MATCH_1} is not greater than ${CMAKE_MATCH_2}")
else()
message(FATAL_ERROR "${CMAKE_MATCH_1} is greater than ${CMAKE_MATCH_2}?")
endif()
endforeach() endforeach()

View File

@ -106,11 +106,11 @@ macro(ADD_SECONDS sec)
set(new_min ${${GD_PREFIX}MINUTE}) set(new_min ${${GD_PREFIX}MINUTE})
set(new_hr ${${GD_PREFIX}HOUR}) set(new_hr ${${GD_PREFIX}HOUR})
math(EXPR new_sec "${sec} + ${${GD_PREFIX}SECOND}") math(EXPR new_sec "${sec} + ${${GD_PREFIX}SECOND}")
while(${new_sec} GREATER 60 OR ${new_sec} EQUAL 60) while(${new_sec} GREATER_EQUAL 60)
math(EXPR new_sec "${new_sec} - 60") math(EXPR new_sec "${new_sec} - 60")
math(EXPR new_min "${${GD_PREFIX}MINUTE} + 1") math(EXPR new_min "${${GD_PREFIX}MINUTE} + 1")
endwhile() endwhile()
while(${new_min} GREATER 60 OR ${new_min} EQUAL 60) while(${new_min} GREATER_EQUAL 60)
math(EXPR new_min "${new_min} - 60") math(EXPR new_min "${new_min} - 60")
math(EXPR new_hr "${${GD_PREFIX}HOUR} + 1") math(EXPR new_hr "${${GD_PREFIX}HOUR} + 1")
endwhile() endwhile()

View File

@ -92,6 +92,12 @@ endif()
if(NOT 2.4 EQUAL 2.4) if(NOT 2.4 EQUAL 2.4)
message(FATAL_ERROR "Failed: NOT 2.4 EQUAL 2.4") message(FATAL_ERROR "Failed: NOT 2.4 EQUAL 2.4")
endif() endif()
if(NOT 2.4 LESS_EQUAL 2.4)
message(FATAL_ERROR "Failed: NOT 2.4 LESS_EQUAL 2.4")
endif()
if(NOT 2.4 GREATER_EQUAL 2.4)
message(FATAL_ERROR "Failed: NOT 2.4 GREATER_EQUAL 2.4")
endif()
if(CMAKE_SYSTEM MATCHES "OSF1-V") if(CMAKE_SYSTEM MATCHES "OSF1-V")
if(NOT CMAKE_COMPILER_IS_GNUCXX) if(NOT CMAKE_COMPILER_IS_GNUCXX)

View File

@ -455,7 +455,7 @@ int main()
#endif #endif
#ifndef SHOULD_BE_DEFINED_LESS #ifndef SHOULD_BE_DEFINED_LESS
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_LESS is not defined.\n"); cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_LESS is not defined.");
#else #else
cmPassed("SHOULD_BE_DEFINED_LESS is defined."); cmPassed("SHOULD_BE_DEFINED_LESS is defined.");
#endif #endif
@ -467,7 +467,7 @@ int main()
#endif #endif
#ifndef SHOULD_BE_DEFINED_LESS2 #ifndef SHOULD_BE_DEFINED_LESS2
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_LESS2 is not defined.\n"); cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_LESS2 is not defined.");
#else #else
cmPassed("SHOULD_BE_DEFINED_LESS2 is defined."); cmPassed("SHOULD_BE_DEFINED_LESS2 is defined.");
#endif #endif
@ -478,20 +478,8 @@ int main()
cmPassed("SHOULD_NOT_BE_DEFINED_GREATER is not defined."); cmPassed("SHOULD_NOT_BE_DEFINED_GREATER is not defined.");
#endif #endif
#ifdef SHOULD_NOT_BE_DEFINED_EQUAL
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_EQUAL is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_EQUAL is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_EQUAL
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_EQUAL is not defined.\n");
#else
cmPassed("SHOULD_BE_DEFINED_EQUAL is defined.");
#endif
#ifndef SHOULD_BE_DEFINED_GREATER #ifndef SHOULD_BE_DEFINED_GREATER
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_GREATER is not defined.\n"); cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_GREATER is not defined.");
#else #else
cmPassed("SHOULD_BE_DEFINED_GREATER is defined."); cmPassed("SHOULD_BE_DEFINED_GREATER is defined.");
#endif #endif
@ -503,12 +491,107 @@ int main()
#endif #endif
#ifndef SHOULD_BE_DEFINED_GREATER2 #ifndef SHOULD_BE_DEFINED_GREATER2
cmFailed( cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_GREATER2 is not defined.");
"IF or SET is broken, SHOULD_BE_DEFINED_GREATER2 is not defined.\n");
#else #else
cmPassed("SHOULD_BE_DEFINED_GREATER2 is defined."); cmPassed("SHOULD_BE_DEFINED_GREATER2 is defined.");
#endif #endif
#ifdef SHOULD_NOT_BE_DEFINED_EQUAL
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_EQUAL is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_EQUAL is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_EQUAL
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_EQUAL is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_EQUAL is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_LESS_EQUAL
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_LESS_EQUAL is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_LESS_EQUAL is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_LESS_EQUAL
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_LESS_EQUAL is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_LESS_EQUAL is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_LESS_EQUAL2
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_LESS_EQUAL2 is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_LESS_EQUAL2 is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_LESS_EQUAL2
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_LESS_EQUAL2 is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_LESS_EQUAL2 is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_LESS_EQUAL3
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_LESS_EQUAL3 is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_LESS_EQUAL3 is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_LESS_EQUAL3
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_LESS_EQUAL3 is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_LESS_EQUAL3 is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_GREATER_EQUAL
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_GREATER_EQUAL is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_GREATER_EQUAL is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_GREATER_EQUAL
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_GREATER_EQUAL is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_GREATER_EQUAL is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_GREATER_EQUAL2
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_GREATER_EQUAL2 is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_GREATER_EQUAL2 is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_GREATER_EQUAL2
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_GREATER_EQUAL2 is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_GREATER_EQUAL2 is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_GREATER_EQUAL3
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_GREATER_EQUAL3 is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_GREATER_EQUAL3 is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_GREATER_EQUAL3
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_GREATER_EQUAL3 is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_GREATER_EQUAL3 is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_STRLESS #ifdef SHOULD_NOT_BE_DEFINED_STRLESS
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS is defined."); cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS is defined.");
#else #else
@ -516,7 +599,7 @@ int main()
#endif #endif
#ifndef SHOULD_BE_DEFINED_STRLESS #ifndef SHOULD_BE_DEFINED_STRLESS
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRLESS is not defined.\n"); cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRLESS is not defined.");
#else #else
cmPassed("SHOULD_BE_DEFINED_STRLESS is defined."); cmPassed("SHOULD_BE_DEFINED_STRLESS is defined.");
#endif #endif
@ -528,8 +611,7 @@ int main()
#endif #endif
#ifndef SHOULD_BE_DEFINED_STRLESS2 #ifndef SHOULD_BE_DEFINED_STRLESS2
cmFailed( cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRLESS2 is not defined.");
"IF or SET is broken, SHOULD_BE_DEFINED_STRLESS2 is not defined.\n");
#else #else
cmPassed("SHOULD_BE_DEFINED_STRLESS2 is defined."); cmPassed("SHOULD_BE_DEFINED_STRLESS2 is defined.");
#endif #endif
@ -543,7 +625,7 @@ int main()
#ifndef SHOULD_BE_DEFINED_STRGREATER #ifndef SHOULD_BE_DEFINED_STRGREATER
cmFailed( cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER is not defined.\n"); "IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER is not defined.");
#else #else
cmPassed("SHOULD_BE_DEFINED_STRGREATER is defined."); cmPassed("SHOULD_BE_DEFINED_STRGREATER is defined.");
#endif #endif
@ -557,11 +639,95 @@ int main()
#ifndef SHOULD_BE_DEFINED_STRGREATER2 #ifndef SHOULD_BE_DEFINED_STRGREATER2
cmFailed( cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER2 is not defined.\n"); "IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER2 is not defined.");
#else #else
cmPassed("SHOULD_BE_DEFINED_STRGREATER2 is defined."); cmPassed("SHOULD_BE_DEFINED_STRGREATER2 is defined.");
#endif #endif
#ifdef SHOULD_NOT_BE_DEFINED_STRLESS_EQUAL
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS_EQUAL is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_STRLESS_EQUAL is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_STRLESS_EQUAL
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_STRLESS_EQUAL is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_STRLESS_EQUAL is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_STRLESS_EQUAL2
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS_EQUAL2 is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_STRLESS_EQUAL2 is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_STRLESS_EQUAL2
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_STRLESS_EQUAL2 is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_STRLESS_EQUAL2 is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_STRLESS_EQUAL3
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS_EQUAL3 is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_STRLESS_EQUAL3 is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_STRLESS_EQUAL3
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_STRLESS_EQUAL3 is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_STRLESS_EQUAL3 is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_STRGREATER_EQUAL
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER_EQUAL is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_STRGREATER_EQUAL is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL2
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL2 is "
"defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL2 is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_STRGREATER_EQUAL2
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER_EQUAL2 is not "
"defined.");
#else
cmPassed("SHOULD_BE_DEFINED_STRGREATER_EQUAL2 is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL3
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL3 is "
"defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL3 is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_STRGREATER_EQUAL3
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER_EQUAL3 is not "
"defined.");
#else
cmPassed("SHOULD_BE_DEFINED_STRGREATER_EQUAL3 is defined.");
#endif
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Test FOREACH // Test FOREACH

View File

@ -126,6 +126,12 @@ else ()
add_definitions(-DSHOULD_NOT_BE_DEFINED_GREATER) add_definitions(-DSHOULD_NOT_BE_DEFINED_GREATER)
endif () endif ()
if (SNUM1_VAR GREATER SNUM2_VAR)
add_definitions(-DSHOULD_NOT_BE_DEFINED_GREATER2)
else ()
add_definitions(-DSHOULD_BE_DEFINED_GREATER2)
endif ()
if (SNUM2_VAR EQUAL SNUM1_VAR) if (SNUM2_VAR EQUAL SNUM1_VAR)
add_definitions(-DSHOULD_NOT_BE_DEFINED_EQUAL) add_definitions(-DSHOULD_NOT_BE_DEFINED_EQUAL)
else () else ()
@ -138,10 +144,40 @@ else ()
add_definitions(-DSHOULD_NOT_BE_DEFINED_EQUAL) add_definitions(-DSHOULD_NOT_BE_DEFINED_EQUAL)
endif () endif ()
if (SNUM1_VAR GREATER SNUM2_VAR) if (SNUM1_VAR LESS_EQUAL SNUM2_VAR)
add_definitions(-DSHOULD_NOT_BE_DEFINED_GREATER2) add_definitions(-DSHOULD_BE_DEFINED_LESS_EQUAL)
else () else ()
add_definitions(-DSHOULD_BE_DEFINED_GREATER2) add_definitions(-DSHOULD_NOT_BE_DEFINED_LESS_EQUAL)
endif ()
if (SNUM2_VAR LESS_EQUAL SNUM1_VAR)
add_definitions(-DSHOULD_NOT_BE_DEFINED_LESS_EQUAL2)
else ()
add_definitions(-DSHOULD_BE_DEFINED_LESS_EQUAL2)
endif ()
if (SNUM1_VAR LESS_EQUAL SNUM3_VAR)
add_definitions(-DSHOULD_BE_DEFINED_LESS_EQUAL3)
else ()
add_definitions(-DSHOULD_BE_DEFINED_LESS_EQUAL3)
endif ()
if (SNUM2_VAR GREATER_EQUAL SNUM1_VAR)
add_definitions(-DSHOULD_BE_DEFINED_GREATER_EQUAL)
else ()
add_definitions(-DSHOULD_NOT_BE_DEFINED_GREATER_EQUAL)
endif ()
if (SNUM1_VAR GREATER_EQUAL SNUM2_VAR)
add_definitions(-DSHOULD_NOT_BE_DEFINED_GREATER_EQUAL2)
else ()
add_definitions(-DSHOULD_BE_DEFINED_GREATER_EQUAL2)
endif ()
if (SNUM1_VAR GREATER_EQUAL SNUM3_VAR)
add_definitions(-DSHOULD_BE_DEFINED_GREATER_EQUAL3)
else ()
add_definitions(-DSHOULD_NOT_BE_DEFINED_GREATER_EQUAL3)
endif () endif ()
set (SSTR1_VAR "abc") set (SSTR1_VAR "abc")
@ -171,6 +207,42 @@ else ()
add_definitions(-DSHOULD_BE_DEFINED_STRGREATER2) add_definitions(-DSHOULD_BE_DEFINED_STRGREATER2)
endif () endif ()
if (SSTR1_VAR STRLESS_EQUAL SSTR2_VAR)
add_definitions(-DSHOULD_BE_DEFINED_STRLESS_EQUAL)
else ()
add_definitions(-DSHOULD_NOT_BE_DEFINED_STRLESS_EQUAL)
endif ()
if (SSTR2_VAR STRLESS_EQUAL SSTR1_VAR)
add_definitions(-DSHOULD_NOT_BE_DEFINED_STRLESS_EQUAL2)
else ()
add_definitions(-DSHOULD_BE_DEFINED_STRLESS_EQUAL2)
endif ()
if (SSTR1_VAR STRLESS_EQUAL SSTR1_VAR)
add_definitions(-DSHOULD_BE_DEFINED_STRLESS_EQUAL3)
else ()
add_definitions(-DSHOULD_NOT_BE_DEFINED_STRLESS_EQUAL3)
endif ()
if (SSTR2_VAR STRGREATER_EQUAL SSTR1_VAR)
add_definitions(-DSHOULD_BE_DEFINED_STRGREATER_EQUAL)
else ()
add_definitions(-DSHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL)
endif ()
if (SSTR1_VAR STRGREATER_EQUAL SSTR2_VAR)
add_definitions(-DSHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL2)
else ()
add_definitions(-DSHOULD_BE_DEFINED_STRGREATER_EQUAL2)
endif ()
if (SSTR1_VAR STRGREATER_EQUAL SSTR1_VAR)
add_definitions(-DSHOULD_BE_DEFINED_STRGREATER_EQUAL3)
else ()
add_definitions(-DSHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL3)
endif ()
# #
# Test FOREACH # Test FOREACH
# #

View File

@ -478,18 +478,6 @@ int main()
cmPassed("SHOULD_NOT_BE_DEFINED_GREATER is not defined."); cmPassed("SHOULD_NOT_BE_DEFINED_GREATER is not defined.");
#endif #endif
#ifdef SHOULD_NOT_BE_DEFINED_EQUAL
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_EQUAL is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_EQUAL is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_EQUAL
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_EQUAL is not defined.\n");
#else
cmPassed("SHOULD_BE_DEFINED_EQUAL is defined.");
#endif
#ifndef SHOULD_BE_DEFINED_GREATER #ifndef SHOULD_BE_DEFINED_GREATER
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_GREATER is not defined.\n"); cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_GREATER is not defined.\n");
#else #else
@ -503,12 +491,107 @@ int main()
#endif #endif
#ifndef SHOULD_BE_DEFINED_GREATER2 #ifndef SHOULD_BE_DEFINED_GREATER2
cmFailed( cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_GREATER2 is not defined.");
"IF or SET is broken, SHOULD_BE_DEFINED_GREATER2 is not defined.\n");
#else #else
cmPassed("SHOULD_BE_DEFINED_GREATER2 is defined."); cmPassed("SHOULD_BE_DEFINED_GREATER2 is defined.");
#endif #endif
#ifdef SHOULD_NOT_BE_DEFINED_EQUAL
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_EQUAL is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_EQUAL is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_EQUAL
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_EQUAL is not defined.\n");
#else
cmPassed("SHOULD_BE_DEFINED_EQUAL is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_LESS_EQUAL
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_LESS_EQUAL is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_LESS_EQUAL is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_LESS_EQUAL
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_LESS_EQUAL is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_LESS_EQUAL is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_LESS_EQUAL2
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_LESS_EQUAL2 is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_LESS_EQUAL2 is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_LESS_EQUAL2
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_LESS_EQUAL2 is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_LESS_EQUAL2 is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_LESS_EQUAL3
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_LESS_EQUAL3 is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_LESS_EQUAL3 is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_LESS_EQUAL3
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_LESS_EQUAL3 is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_LESS_EQUAL3 is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_GREATER_EQUAL
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_GREATER_EQUAL is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_GREATER_EQUAL is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_GREATER_EQUAL
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_GREATER_EQUAL is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_GREATER_EQUAL is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_GREATER_EQUAL2
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_GREATER_EQUAL2 is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_GREATER_EQUAL2 is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_GREATER_EQUAL2
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_GREATER_EQUAL2 is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_GREATER_EQUAL2 is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_GREATER_EQUAL3
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_GREATER_EQUAL3 is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_GREATER_EQUAL3 is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_GREATER_EQUAL3
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_GREATER_EQUAL3 is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_GREATER_EQUAL3 is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_STRLESS #ifdef SHOULD_NOT_BE_DEFINED_STRLESS
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS is defined."); cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS is defined.");
#else #else
@ -516,7 +599,7 @@ int main()
#endif #endif
#ifndef SHOULD_BE_DEFINED_STRLESS #ifndef SHOULD_BE_DEFINED_STRLESS
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRLESS is not defined.\n"); cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRLESS is not defined.");
#else #else
cmPassed("SHOULD_BE_DEFINED_STRLESS is defined."); cmPassed("SHOULD_BE_DEFINED_STRLESS is defined.");
#endif #endif
@ -528,8 +611,7 @@ int main()
#endif #endif
#ifndef SHOULD_BE_DEFINED_STRLESS2 #ifndef SHOULD_BE_DEFINED_STRLESS2
cmFailed( cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRLESS2 is not defined.");
"IF or SET is broken, SHOULD_BE_DEFINED_STRLESS2 is not defined.\n");
#else #else
cmPassed("SHOULD_BE_DEFINED_STRLESS2 is defined."); cmPassed("SHOULD_BE_DEFINED_STRLESS2 is defined.");
#endif #endif
@ -543,7 +625,7 @@ int main()
#ifndef SHOULD_BE_DEFINED_STRGREATER #ifndef SHOULD_BE_DEFINED_STRGREATER
cmFailed( cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER is not defined.\n"); "IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER is not defined.");
#else #else
cmPassed("SHOULD_BE_DEFINED_STRGREATER is defined."); cmPassed("SHOULD_BE_DEFINED_STRGREATER is defined.");
#endif #endif
@ -557,11 +639,95 @@ int main()
#ifndef SHOULD_BE_DEFINED_STRGREATER2 #ifndef SHOULD_BE_DEFINED_STRGREATER2
cmFailed( cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER2 is not defined.\n"); "IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER2 is not defined.");
#else #else
cmPassed("SHOULD_BE_DEFINED_STRGREATER2 is defined."); cmPassed("SHOULD_BE_DEFINED_STRGREATER2 is defined.");
#endif #endif
#ifdef SHOULD_NOT_BE_DEFINED_STRLESS_EQUAL
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS_EQUAL is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_STRLESS_EQUAL is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_STRLESS_EQUAL
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_STRLESS_EQUAL is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_STRLESS_EQUAL is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_STRLESS_EQUAL2
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS_EQUAL2 is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_STRLESS_EQUAL2 is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_STRLESS_EQUAL2
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_STRLESS_EQUAL2 is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_STRLESS_EQUAL2 is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_STRLESS_EQUAL3
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS_EQUAL3 is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_STRLESS_EQUAL3 is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_STRLESS_EQUAL3
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_STRLESS_EQUAL3 is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_STRLESS_EQUAL3 is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL
cmFailed(
"IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL is defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_STRGREATER_EQUAL
cmFailed(
"IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER_EQUAL is not defined.");
#else
cmPassed("SHOULD_BE_DEFINED_STRGREATER_EQUAL is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL2
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL2 is "
"defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL2 is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_STRGREATER_EQUAL2
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER_EQUAL2 is not "
"defined.");
#else
cmPassed("SHOULD_BE_DEFINED_STRGREATER_EQUAL2 is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL3
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL3 is "
"defined.");
#else
cmPassed("SHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL3 is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_STRGREATER_EQUAL3
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER_EQUAL3 is not "
"defined.");
#else
cmPassed("SHOULD_BE_DEFINED_STRGREATER_EQUAL3 is defined.");
#endif
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Test FOREACH // Test FOREACH

View File

@ -126,6 +126,12 @@ else ()
add_definitions(-DSHOULD_NOT_BE_DEFINED_GREATER) add_definitions(-DSHOULD_NOT_BE_DEFINED_GREATER)
endif () endif ()
if (SNUM1_VAR GREATER SNUM2_VAR)
add_definitions(-DSHOULD_NOT_BE_DEFINED_GREATER2)
else ()
add_definitions(-DSHOULD_BE_DEFINED_GREATER2)
endif ()
if (SNUM2_VAR EQUAL SNUM1_VAR) if (SNUM2_VAR EQUAL SNUM1_VAR)
add_definitions(-DSHOULD_NOT_BE_DEFINED_EQUAL) add_definitions(-DSHOULD_NOT_BE_DEFINED_EQUAL)
else () else ()
@ -138,10 +144,40 @@ else ()
add_definitions(-DSHOULD_NOT_BE_DEFINED_EQUAL) add_definitions(-DSHOULD_NOT_BE_DEFINED_EQUAL)
endif () endif ()
if (SNUM1_VAR GREATER SNUM2_VAR) if (SNUM1_VAR LESS_EQUAL SNUM2_VAR)
add_definitions(-DSHOULD_NOT_BE_DEFINED_GREATER2) add_definitions(-DSHOULD_BE_DEFINED_LESS_EQUAL)
else () else ()
add_definitions(-DSHOULD_BE_DEFINED_GREATER2) add_definitions(-DSHOULD_NOT_BE_DEFINED_LESS_EQUAL)
endif ()
if (SNUM2_VAR LESS_EQUAL SNUM1_VAR)
add_definitions(-DSHOULD_NOT_BE_DEFINED_LESS_EQUAL2)
else ()
add_definitions(-DSHOULD_BE_DEFINED_LESS_EQUAL2)
endif ()
if (SNUM1_VAR LESS_EQUAL SNUM3_VAR)
add_definitions(-DSHOULD_BE_DEFINED_LESS_EQUAL3)
else ()
add_definitions(-DSHOULD_NOT_BE_DEFINED_LESS_EQUAL3)
endif ()
if (SNUM2_VAR GREATER_EQUAL SNUM1_VAR)
add_definitions(-DSHOULD_BE_DEFINED_GREATER_EQUAL)
else ()
add_definitions(-DSHOULD_NOT_BE_DEFINED_GREATER_EQUAL)
endif ()
if (SNUM1_VAR GREATER_EQUAL SNUM2_VAR)
add_definitions(-DSHOULD_NOT_BE_DEFINED_GREATER_EQUAL2)
else ()
add_definitions(-DSHOULD_BE_DEFINED_GREATER_EQUAL2)
endif ()
if (SNUM1_VAR GREATER_EQUAL SNUM3_VAR)
add_definitions(-DSHOULD_BE_DEFINED_GREATER_EQUAL3)
else ()
add_definitions(-DSHOULD_NOT_BE_DEFINED_GREATER_EQUAL3)
endif () endif ()
set (SSTR1_VAR "abc") set (SSTR1_VAR "abc")
@ -171,6 +207,42 @@ else ()
add_definitions(-DSHOULD_BE_DEFINED_STRGREATER2) add_definitions(-DSHOULD_BE_DEFINED_STRGREATER2)
endif () endif ()
if (SSTR1_VAR STRLESS_EQUAL SSTR2_VAR)
add_definitions(-DSHOULD_BE_DEFINED_STRLESS_EQUAL)
else ()
add_definitions(-DSHOULD_NOT_BE_DEFINED_STRLESS_EQUAL)
endif ()
if (SSTR2_VAR STRLESS_EQUAL SSTR1_VAR)
add_definitions(-DSHOULD_NOT_BE_DEFINED_STRLESS_EQUAL2)
else ()
add_definitions(-DSHOULD_BE_DEFINED_STRLESS_EQUAL2)
endif ()
if (SSTR1_VAR STRLESS_EQUAL SSTR1_VAR)
add_definitions(-DSHOULD_BE_DEFINED_STRLESS_EQUAL3)
else ()
add_definitions(-DSHOULD_NOT_BE_DEFINED_STRLESS_EQUAL3)
endif ()
if (SSTR2_VAR STRGREATER_EQUAL SSTR1_VAR)
add_definitions(-DSHOULD_BE_DEFINED_STRGREATER_EQUAL)
else ()
add_definitions(-DSHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL)
endif ()
if (SSTR1_VAR STRGREATER_EQUAL SSTR2_VAR)
add_definitions(-DSHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL2)
else ()
add_definitions(-DSHOULD_BE_DEFINED_STRGREATER_EQUAL2)
endif ()
if (SSTR1_VAR STRGREATER_EQUAL SSTR1_VAR)
add_definitions(-DSHOULD_BE_DEFINED_STRGREATER_EQUAL3)
else ()
add_definitions(-DSHOULD_NOT_BE_DEFINED_STRGREATER_EQUAL3)
endif ()
# #
# Test FOREACH # Test FOREACH
# #