[cmake-developers] if (FOO == BAR) ...

Alexander Neundorf neundorf at kde.org
Sun Mar 24 05:24:45 EDT 2013


On Saturday 23 March 2013, David Cole wrote:
> Wow, could be a variable on the right, too. So my previous example was
> still not 100% safe.
> 
> Maybe this construct is 100% safe:
> 
>     set(x "${some_var_that_may_eval_to_another_var_name}")
>     set(y "some string constant that may also accidentally be a var")
>     if(x STREQUAL y)
> 
> You can see why the "x${var}" STREQUAL "xSomeString" approach is
> appealing after a discussion like this. 

Hmm, actually, to me, no.
Now you have ugly code and as Brad noted, you can still construct cases where 
it breaks.
That's why I came up with that quick, safe and not-really-dirty patch.

Having said that, I've never been hit by that problem, or at least I'm not 
aware of it.

Alex



More information about the cmake-developers mailing list