[CMake] NOT operator gotchas for newbies

Dan Kegel dank at kegel.com
Fri Nov 4 18:22:28 EDT 2011


I just ran into two little newbie problems having to do with booleans.

CMP0012 made various boolean constants case insensitive,
but NOT is still case sensitive.
If you use it in lowercase, you get the warning

CMake Warning (dev) at CMakeLists.txt:2 (if):
  given arguments:
    "not" "foo"
  Unknown arguments specified

That's fairly clear, and anyone who's been around cmake will
suspect that uppercase is required.
Still, it might be nice to accept lowercase not at some point.

Also, people who mistakenly use !foo instead of NOT foo
get a surprise: the result is always silently false.
It might be nice to catch this possibly common error
and output an error message.


More information about the CMake mailing list