[CMake] Explanation....

David Cole dlrdave at aol.com
Thu Apr 24 06:31:50 EDT 2014


> You sure? When I checked, this did not work. Also, the following
> gives me a syntax error:
>
> set (" foo" "Evil!")
> message( "${ foo}")


But you *can* still do it indirectly (even with the 3.0 RCs):

    set (" variable with spaces" "Evil too!")
    set (varname " variable with spaces")
    message("${${varname}}")

(Sorry, but I refuse to use "foo" in example code...)

You'll notice that in your original example, the error was reported on
the "message" command. The parser simply could not parse a directly
coded variable name containing spaces inside the context of ${}... but
de-referencing indirectly, as is commonly done, still makes it possible
to end up with weirdly named variables if you're not extremely careful
with your variable naming schemes.

I, for one, would fully support breaking backwards compatibility to fix
this, and be strict with variable and macro and function name
identifiers.

It's just ridiculous to waste time trying to justify the existing
behavior. It's more confusing than useful, and ought to be changed.


Just my opinion,
David C.





More information about the CMake mailing list