From 843da9240584edd3eda63ae637891593ae8c729f Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Thu, 23 May 2002 10:32:28 -0400 Subject: adde less greater --- Source/cmElseCommand.cxx | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ Source/cmIfCommand.cxx | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ Source/cmIfCommand.h | 5 ++++- 3 files changed, 116 insertions(+), 1 deletion(-) diff --git a/Source/cmElseCommand.cxx b/Source/cmElseCommand.cxx index 046fa88..5451004 100644 --- a/Source/cmElseCommand.cxx +++ b/Source/cmElseCommand.cxx @@ -86,6 +86,62 @@ bool cmElseCommand::InitialPass(std::vector const& args) } } + if (args.size() == 3 && (args[1] == "LESS")) + { + def = m_Makefile->GetDefinition(args[0].c_str()); + def2 = m_Makefile->GetDefinition(args[2].c_str()); + if (!def) + { + def = args[0].c_str(); + } + if (!def2) + { + def2 = args[2].c_str(); + } + if(atof(def) < atof(def2)) + { + f = new cmIfFunctionBlocker(); + } + } + + if (args.size() == 3 && (args[1] == "GREATER")) + { + def = m_Makefile->GetDefinition(args[0].c_str()); + def2 = m_Makefile->GetDefinition(args[2].c_str()); + if (!def) + { + def = args[0].c_str(); + } + if (!def2) + { + def2 = args[2].c_str(); + } + if(atof(def) > atof(def2)) + { + f = new cmIfFunctionBlocker(); + } + } + + if (args.size() == 3 && (args[1] == "STRLESS")) + { + def = m_Makefile->GetDefinition(args[0].c_str()); + def2 = m_Makefile->GetDefinition(args[2].c_str()); + if(strcmp(def,def2) < 0) + { + f = new cmIfFunctionBlocker(); + } + } + + if (args.size() == 3 && (args[1] == "STRGREATER")) + { + def = m_Makefile->GetDefinition(args[0].c_str()); + def2 = m_Makefile->GetDefinition(args[2].c_str()); + if(strcmp(def,def2) > 0) + { + f = new cmIfFunctionBlocker(); + } + } + if (args.size() == 3 && (args[1] == "MATCHES")) { def = m_Makefile->GetDefinition(args[0].c_str()); diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 2146a5e..85cb98d 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -149,6 +149,62 @@ bool cmIfCommand::InitialPass(std::vector const& args) } } + if (args.size() == 3 && (args[1] == "LESS")) + { + def = m_Makefile->GetDefinition(args[0].c_str()); + def2 = m_Makefile->GetDefinition(args[2].c_str()); + if (!def) + { + def = args[0].c_str(); + } + if (!def2) + { + def2 = args[2].c_str(); + } + if(atof(def) >= atof(def2)) + { + f = new cmIfFunctionBlocker(); + } + } + + if (args.size() == 3 && (args[1] == "GREATER")) + { + def = m_Makefile->GetDefinition(args[0].c_str()); + def2 = m_Makefile->GetDefinition(args[2].c_str()); + if (!def) + { + def = args[0].c_str(); + } + if (!def2) + { + def2 = args[2].c_str(); + } + if(atof(def) <= atof(def2)) + { + f = new cmIfFunctionBlocker(); + } + } + + if (args.size() == 3 && (args[1] == "STRLESS")) + { + def = m_Makefile->GetDefinition(args[0].c_str()); + def2 = m_Makefile->GetDefinition(args[2].c_str()); + if(strcmp(def,def2) >= 0) + { + f = new cmIfFunctionBlocker(); + } + } + + if (args.size() == 3 && (args[1] == "STRGREATER")) + { + def = m_Makefile->GetDefinition(args[0].c_str()); + def2 = m_Makefile->GetDefinition(args[2].c_str()); + if(strcmp(def,def2) <= 0) + { + f = new cmIfFunctionBlocker(); + } + } + // if we created a function blocker then set its args if (f) { diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h index 164c5c5..2453c3c 100644 --- a/Source/cmIfCommand.h +++ b/Source/cmIfCommand.h @@ -93,7 +93,10 @@ public: "using (NOT define) (def AND def2) (def OR def2) (def MATCHES def2) " "(COMMAND cmd) (EXISTS file) MATCHES checks if def matches the " "regular expression def2. COMMAND checks if the cmake command cmd " - "is in this cmake executable. EXISTS file checks if file exists"; + "is in this cmake executable. EXISTS file checks if file exists." + "Additionally you can do comparisons using LESS GREATER STRLESS " + "and STRGREATER. LESS and GREATER do numeric comparison while " + "STRLESS and STRGREATER do string comparisons."; } cmTypeMacro(cmIfCommand, cmCommand); -- cgit v0.12