[CMake] set(a b); set(b c); if(a STREQUAL b OR a STREQUAL c) ...

Clark Wang dearvoid at gmail.com
Thu Sep 4 01:44:20 EDT 2014


On Thu, Sep 4, 2014 at 1:36 PM, Chuck Atkins <chuck.atkins at kitware.com>
wrote:

> Hi Clark
>
> The expression inside the if statement has it's variables dereferenced
> before evaluating and the non-variables are treated as constant
> expressions.  In this case, a resolves to "b", b resolves to "c", and c is
> not a variable so it's treated as the constant expression "c".  Thus
>
>
> if(a STREQUAL b OR a STREQUAL c)
>
> gets evaluated as
>
> if( ("b" STREQUAL "c") OR ("b" STREQUAL "c") )
>

Thanks a lot. It's clear now. But is there a way to check if the value of
the variable a equals to "b" or "c"?

-clark

>
> which is clearly false.  Hope that helps.
>
>  - Chuck
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140904/52df509b/attachment.html>


More information about the CMake mailing list