[CMake] evaluating a simple boolean expression?
Brandon J. Van Every
bvanevery at gmail.com
Thu Mar 30 05:15:22 EST 2006
How do I evaluate a simple boolean expression in CMake? I've tried {}
and ${} and they don't work for expressions, only for variable
substitutions. () and $() give errors. [] and $[] appear to be absent
from the language. I've Googled all over the place and can't find any
documentation. I'm looking for something like an EVAL() function. Why
do I need an evaluator? I get tired of writing my boolean conditionals
twice:
SET(HAVE_EXTANT_CHICKEN true)
IF(${EXTANT_CHICKEN} STREQUAL "EXTANT_CHICKEN-NOTFOUND")
SET(HAVE_EXTANT_CHICKEN false)
ENDIF(${EXTANT_CHICKEN} STREQUAL "EXTANT_CHICKEN-NOTFOUND")
IF(HAVE_EXTANT_CHICKEN)
blah blah blah...
ELSE(HAVE_EXTANT_CHICKEN)
bleh bleh bleh...
ENDIF(HAVE_EXTANT_CHICKEN)
I would rather isolate my conditional and only edit it in 1 place.
Particularly when conditionals get longer. Something like:
SET(HAVE_EXTANT_CHICKEN {${EXTANT_CHICKEN} STREQUAL
"EXTANT_CHICKEN-NOTFOUND"})
IF(HAVE_EXTANT_CHICKEN)
blah blah blah...
ELSE(HAVE_EXTANT_CHICKEN)
bleh bleh bleh...
ENDIF(HAVE_EXTANT_CHICKEN)
Cheers,
Brandon Van Every
More information about the CMake
mailing list