0

What was the reason to allow numeric only variable names in CMake? It makes the next code frustrative (if's condition becomes true):

set(1 3)
set(2 3)
if (1 EQUAL 2)
    MESSAGE( "hi there" )
endif()

And even more likely usage (if's condition becomes true also):

set(1 2)
... # later on, or even in the other file:
set(var1 1)
if (${var1} EQUAL 2)
    MESSAGE( "hi there" )
endif()

PS I understand why variable references without ${} used inside IF/WHILE. But the possibility of numeric only variable names makes using IFs more error-prone...

1 Answers1

0

Answer from Brad King at CMake issue tracker:

For reference, variable names are arbitrary strings, e.g.

set(var "almost anything here")
set("${var}" value)
message(STATUS "${${var}}")

Allowing numeric-only names is a side effect of that.

Certainly they can be used in confusing ways. Disallowing them, even if only for if() evaluation, would require a policy.