[CMake] Testing values

Stephen Quinney squinney at inf.ed.ac.uk
Tue Jul 22 05:24:48 EDT 2008


I'm seeing some odd behaviour and I wonder if this is just me doing
things the wrong way or whether this is a genuine bug. Here's a
snippet which shows the problem:

IF(${FOO})
  MESSAGE("Test A: true")
ELSE(${FOO})
  MESSAGE("Test A: false")
ENDIF(${FOO})
  
IF(FOO)
  MESSAGE("Test B: true")
ELSE(FOO)
  MESSAGE("Test B: false")
ENDIF(FOO)

When FOO is set to 1 the result is:

Test A: true
Test B: true

As expected.

When FOO is set to zero the result is:

Test A: false
Test B: false

When FOO is set to three (or any other value) the result is:

Test A: false
Test B: true

which is definitely NOT what I expected.

If I invert the test with the NOT operator the results are
consistent. So, is this just a case of "don't do it that way" or a
real issue? For reference this is with cmake version 2.6 patch 0.


Stephen Quinney






-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



More information about the CMake mailing list