Marco A.
Marco A.

Reputation: 43662

CMake if(VARIABLE LESS 22) - what if VARIABLE doesn't exist?

If I write

if(VARIABLE LESS 22)
  .. do some stuff..
else()
  .. do some other stuff..
endif()

if VARIABLE has a value less than 22, ".. do some stuff.." is executed, if VARIABLE is equal or greater to 22, ".. do some other stuff.." is executed.

My question: what if VARIABLE is NOT defined?

Will ".. do some other stuff.." be executed?

Upvotes: 0

Views: 876

Answers (1)

Fraser
Fraser

Reputation: 78280

If you mean in the context of a CMakeLists file, then yes, ".. do some other stuff.." will be executed.

From the docs for if:

if(<variable|string> LESS <variable|string>)

True if the given string or variable's value is a valid number and the inequality or equality is true.

In this case, the variable's value is not a valid number.

Upvotes: 1

Related Questions