No subject


Fri Mar 19 13:53:46 EDT 2010


"[...] The convenience feature that sometimes throws new authors is how
CMake handles values that do not match the true or false list. Those
values are treated as variables and are dereferenced [...]"

Thus, the observed behaviour, i.e. the interpretation of IF()'s single
argument as a variable if it doesn't equal one of the explicitly listed
true'n'false values and the subsequent evaluation of that "variable's"
content, is regular as AN and HS have pointed out in the meantime, and
it's also documented. IMO, there's no bug in the CMake docs w.r.t. this.

> including non-zero numbers with space appended (but not prefixed) [...]

This is a quite common behaviour, cf. strtol(): Leading white-space is
consumed implicitly, but trailing white-space is left alone. Obviously,
CMake decides that explicitly trailing white-space also disqualifies a
string literal from being considered as a non-zero number.

> [...] That means 
> that the -NOTFOUND suffix is actually quite useless, [...] 

No: "IF(mylibrary.so)" and "IF(mylibrary.so-NOTFOUND)" both evaluate to
FALSE, indeed, but while "SET(VAR mylibrary.so)...IF(VAR)" evaluates to
TRUE note that "SET(VAR mylibrary.so-NOTFOUND)" makes "IF(VAR)" to
yield FALSE which is essential for commands like FIND_LIBRARY().

In summary, the crucial moment is the distinction between evaluating a
literal constant and evaluating a variable during IF()'s execution.

Best regards,

Michael


More information about the CMake mailing list