[CMake] BOOL type

James Bigler bigler at cs.utah.edu
Tue Dec 18 09:36:14 EST 2007


>> Alexander Neundorf wrote:
>>> On Monday 17 December 2007, Brandon Van Every wrote:
>>>> I propose the addition of a BOOL type to the CMake language.
>>>>
>>>>   bool(variable [value])
>>>>
>>>> would declare a variable of type BOOL, with an optional value
>>>> supplied.  Any SET commands performed on the variable in its scope
>>>> would be subject to boolean type constraint.  A BOOL can take on  
>>>> the
>>>> following values.  Any other assignment is an error.
>>>>
>>>>   "TRUE" class - TRUE, 1, Y, Yes, YES, y, yes, ON
>>>>   "FALSE" class - FALSE, 0, N, n, No, NO, OFF, <empty>
>>> Attached is a patch which removes "Y" and "N" from the recognized  
>>> values for true/false.
>>> This patch may break stuff. I don't know if there are many people  
>>> who rely on "N" and "Y".
>>
>> I am sure it will break something....  I don't think we can change  
>> it now.
>>
>> -Bill
>>
>
> I might kindly disagree. There are many instances where backward  
> compatibility was broken in order to clean things up and move on.
> Vtk 4.x to 5.x was one of those. My code broke with the 5.x release  
> BUT it was for the better. And more importantly I was given plenty  
> of notice that it was coming. The jump from 2.4 to 2.6 seems like a  
> good time to make the break and clean things up. As long as there  
> is a comprehensive list of breakage I don't think people will have  
> a real problem with it.
>
> -- 
> Mike Jackson   Senior Research Engineer
> Innovative Management & Technology Services

I also agree that trying to maintain backwards compatibility to the  
detriment of the future can become a hinderance.  I just had a  
collegue who was extreemly frustrated for several hours with why his  
build didn't work, only to discover that he should have been using  
ADD_SUBDIRECTORIES instead of SUBDIRS.  There was no warning from  
CMake stating that he shouldn't be using it (I would argue that CMake  
should warn about the use of SUBDIRS).

Aside from the backwards compatibility issue, this cmake code should  
work, but it produces a FATAL_ERROR:

SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)

SET(A TRUE)
SET(B FALSE)

IF(A EQUAL B)
   MESSAGE(FATAL_ERROR "${A} shouldn't equal ${B}")
ELSE()
   MESSAGE("${A} should equal ${B}")
ENDIF()

SET(B 1)

IF(A EQUAL B)
   MESSAGE("${A} should equal ${B}")
ELSE()
   MESSAGE(FATAL_ERROR "${A} shouldn't equal ${B}")
ENDIF()

James



More information about the CMake mailing list