View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008222CMakeCMakepublic2008-12-04 02:012011-04-04 12:00
ReporterPhilip Lowman 
Assigned ToDavid Cole 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusclosedResolutionwon't fix 
PlatformOSOS Version
Product VersionCMake-2-6 
Target VersionFixed in VersionCMake 2.8.4 
Summary0008222: [PATCH] Support for >= and <= operators in IF() conditional
DescriptionThe patch includes support for the following operators:

GREATER_OR_EQUAL
LESS_OR_EQUAL
VERSION_GREATER_OR_EQUAL
VERSION_LESS_OR_EQUAL

Basically this is just a nice-to-have for CMake scripters so they can avoid writing ugly code like this:

IF(${CMAKE_MAJOR_VERSION} GREATER 1 AND
   ${CMAKE_MINOR_VERSION} GREATER 5) # CMake >= 2.6

# and start writing code like this:

IF(${CMAKE_MAJOR_VERSION} GREATER_OR_EQUAL 2 AND
   ${CMAKE_MINOR_VERSION} GREATER_OR_EQUAL 6) # CMake >2.6

# or better yet, in the case of a version number, code like this:

SET(ver ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
IF(ver VERSION_GREATER_OR_EQUAL 2.6)
   MESSAGE("HOORAY!")
ENDIF()
TagsNo tags attached.
Attached Filespatch file icon or_equal.patch [^] (22,838 bytes) 2008-12-04 02:01 [Show Content]

 Relationships

  Notes
(0014300)
Philip Lowman (developer)
2008-12-04 22:21

Sorry about the poor example of the uglyness of using GREATER instead of GREATER_OR_EQUAL with:

IF(${CMAKE_MAJOR_VERSION} GREATER 1 AND
   ${CMAKE_MINOR_VERSION} GREATER 5) # CMake >= 2.6

This is false when CMake == 3.0 (woops). The point was to illustrate that code is much more readable with >= and <=. My blunder above is a nice justification for VERSION_GREATER_OR_EQUAL.

IF(${version} VERSION_GREATER 2.6 OR ${version} VERSION_EQUAL 2.6) stinks compared to:
IF(${version} VERSION_GREATER_OR_EQUAL 2.6)
(0017110)
Philip Lowman (developer)
2009-08-13 00:28

Hi, Just reviewing my open patches.

I see less merit in this patch than I did 8 months ago as the added operators could confuse users into thinking the feature was there since 2.6.

If it is merged in it probably should have a "Since 2.8" added to the documentation. Otherwise just dump it.
(0020003)
Lysius (reporter)
2010-03-24 18:45

I'm also missing this feature.

The more I dig into cmake the more I get the impression that it is not yet ripe for usage. But when I see this bug (including a patch) open for more than a year, I fear that it will never become really usable.
(0024129)
David Cole (manager)
2010-12-15 07:01

This patch adds needless complexity to the choices available for IF comparisons. And, as you say, people will start using it when introduced, and then wonder why it doesn't work in prior versions...

Additionally,

if("${x}" GREATER_OR_EQUAL "${y}")

  is logically the same as

if(NOT "${x}" LESS "${y}")

and similarly for LESS_OR_EQUAL and NOT GREATER...

I understand that it makes for harder to read logic statements in CMakeLists.txt files when you have to invert logic, but the IF command is already quirky enough without throwing other monkey wrenches into the works at this point.

Please add additional comments, or convince me to change my mind if you disagree.
(0026052)
David Cole (manager)
2011-04-04 12:00

Closing resolved issues that have not been updated in more than 3 months.

 Issue History
Date Modified Username Field Change
2008-12-04 02:01 Philip Lowman New Issue
2008-12-04 02:01 Philip Lowman File Added: or_equal.patch
2008-12-04 22:21 Philip Lowman Note Added: 0014300
2008-12-15 10:39 Bill Hoffman Status new => assigned
2008-12-15 10:39 Bill Hoffman Assigned To => Ken Martin
2009-08-13 00:28 Philip Lowman Note Added: 0017110
2010-03-24 18:45 Lysius Note Added: 0020003
2010-12-14 11:09 David Cole Assigned To Ken Martin =>
2010-12-15 06:54 David Cole Assigned To => David Cole
2010-12-15 07:01 David Cole Note Added: 0024129
2010-12-15 07:01 David Cole Status assigned => resolved
2010-12-15 07:01 David Cole Fixed in Version => CMake 2.8.4
2010-12-15 07:01 David Cole Resolution open => won't fix
2011-04-04 12:00 David Cole Note Added: 0026052
2011-04-04 12:00 David Cole Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team