View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005835CMakeCMakepublic2007-10-08 15:262011-05-02 14:46
ReporterBrandon Van Every 
Assigned ToDavid Cole 
PrioritynormalSeverityfeatureReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product Version 
Target VersionFixed in VersionCMake 2.8.4 
Summary0005835: define TRUE and FALSE constants
DescriptionTRUE and FALSE are not constants, as the following code illustrates:

SET(FALSE "whatever")
IF(FALSE)
  MESSAGE("FALSE is a variable")
ELSE(FALSE)
  MESSAGE("You'll never see this")
ENDIF(FALSE)
IF(TRUE)
  MESSAGE("You'll never see this")
ELSE(TRUE)
  MESSAGE("TRUE is an uninitialized variable")
ENDIF(TRUE)

C:\devel\src\cbugs\trueorfalse>cmake -P trueorfalse.cmake
FALSE is a variable
TRUE is an uninitialized variable

The documentation says, "IF(variable) - True if the variable's value is not empty, 0, N, NO, OFF, FALSE, NOTFOUND, or <variable>-NOTFOUND." They also mention TRUE in conjunction with some Find* functions. This can mislead the programmer into believing that TRUE and FALSE are available as constants, and that the statement IF(TRUE) does what you'd expect.

Defining TRUE and FALSE to be constants would be safer. Compatibility issues probably wouldn't happen in practice, because people probably aren't using TRUE or FALSE as variables.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0010352)
Brandon Van Every (reporter)
2008-01-31 04:14

Perhaps YES, NO, ON, and OFF should be defined as constants as well.

I don't think Y and N should be. Actually I think treatment of "Y" and "N" as true/false values should be removed from CMake. A regex match of a single character can be "N".
(0025127)
David Cole (manager)
2011-01-28 11:13

The IF command documentation has been improved since this report was filed.

Once a CMake developer gets used to the way IF stuff evaluates... this issue is not so critical. I do not see a lot of added value to adding "constants" into the mix.

Please feel free to re-open this issue and discuss things further if you strongly disagree.

Thanks,
David
(0026380)
David Cole (manager)
2011-05-02 14:46

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

 Issue History
Date Modified Username Field Change
2007-10-08 15:26 Brandon Van Every New Issue
2007-10-12 09:40 Bill Hoffman Status new => assigned
2007-10-12 09:40 Bill Hoffman Assigned To => Ken Martin
2008-01-31 04:14 Brandon Van Every Note Added: 0010352
2010-12-14 11:30 David Cole Assigned To Ken Martin => David Cole
2011-01-28 11:13 David Cole Note Added: 0025127
2011-01-28 11:13 David Cole Status assigned => resolved
2011-01-28 11:13 David Cole Fixed in Version => CMake 2.8.4
2011-01-28 11:13 David Cole Resolution open => no change required
2011-05-02 14:46 David Cole Note Added: 0026380
2011-05-02 14:46 David Cole Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team