Checking of valid variable names in set command
When you (accidentally) write something like
set(MY_OPTIONS, "-fno-omit-frame-pointer")
and then try to use the variable MY_OPTIONS
it will silently fail, like e.g.
target_compile_options(my_target PRIVATE "${MY_OPTIONS}")
will just do nothing.
When you debug the script, you can see that the first line indeed sets a variable with the name MY_OPTIONS,
, which however you can't access afterwards. Something like
message("${MY_OPTIONS,}")
will lead to a syntax error Invalid character (',') in a variable name: 'MY_OPTIONS'
.
This should be consistent. Either commas or other punctuation are allowed in variables names everywhere or nowhere, where I would strongly lean to the latter.
Since there must already be some function that checks validity of variable names in string expansion, it should not cost too much effort to use that in set
or unset
too.