[cmake-developers] [CMake 0015335]: if () evaluates to FALSE for quoted constants/variables where the contents are non-null and not defined constants

Mantis Bug Tracker mantis at public.kitware.com
Sun Jan 4 21:19:40 EST 2015


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=15335 
====================================================================== 
Reported By:                Brian Chojnowski
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15335
Category:                   CMake
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2015-01-04 21:19 EST
Last Modified:              2015-01-04 21:19 EST
====================================================================== 
Summary:                    if () evaluates to FALSE for quoted
constants/variables where the contents are non-null and not defined constants
Description: 
An if statement should evaluate to TRUE if the variable is not-null and is not a
defined false constant.

>From the documentation:

if(<constant>)
True if the constant is 1, ON, YES, TRUE, Y, or a non-zero number. False if the
constant is 0, OFF, NO, FALSE, N, IGNORE, NOTFOUND, the empty string, or ends in
the suffix -NOTFOUND. Named boolean constants are case-insensitive. If the
argument is not one of these constants, it is treated as a variable.
if(<variable>)
True if the variable is defined to a value that is not a false constant. False
otherwise. (Note macro arguments are not variables.)

Steps to Reproduce: 
set(myvar "not a false constant")
message(STATUS "myvar=${myvar}")
if(myvar)
    message(STATUS "un quoted variable name = TRUE")
endif()
if(${myvar})
    message(STATUS "un quoted variable contents = TRUE")
endif()
if("${myvar}")
    message(STATUS "quoted variable = TRUE")
endif()

Output:

Eclipse version is set to 4.4 (). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
myvar=test string
un quoted variable name = TRUE
Configuring done
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2015-01-04 21:19 Brian ChojnowskiNew Issue                                    
======================================================================



More information about the cmake-developers mailing list