[CMake] Explanation....

Matthew Woehlke mw_triad at users.sourceforge.net
Thu Apr 24 11:34:40 EDT 2014


On 2014-04-24 04:53, Johannes Zarl wrote:
> On Wednesday, 23. April 2014, 18:54:39, Matthew Woehlke wrote:
>>> if (" ${arg}" STREQUAL " TOTO")
>>
>> set(" TOTO" "evil")
>
> You sure? When I checked, this did not work.

Are *you* sure? :-)

> Also, the following gives me a syntax error:
>
> message( "${ foo}")

Right; *explicit* expansion is limited in what characters are allowed. 
As David Cole points out, you must expand such variables indirectly. Of 
course, implicit expansion counts as indirect expansion, which is why 
there is no safe character/prefix that can guarantee implicit expansion 
won't occur.

(And - again as David Cole already noted - you didn't get an error in 
the set() command, did you?)

>> See also
>> http://permalink.gmane.org/gmane.comp.programming.tools.cmake.devel/9936.
>
> This is totally different, in that it uses an unsafe prefix.

No it doesn't. The point being made there (and here) is that *ANY* 
prefix is unsafe. (Granted, some are more unsafe than others...)

On 2014-04-24 06:31, David Cole wrote:
> I, for one, would fully support breaking backwards compatibility to fix
> this, and be strict with variable and macro and function name
> identifiers.

Of course, the *real* problem is implicit expansion. The permissiveness 
of variable naming makes it harder to work around this, but would be 
less of an issue if implicit expansion was less "eager".

-- 
Matthew



More information about the CMake mailing list