[CMake] How to assign a boolean expression to a variable?
Nils Gladitz
nilsgladitz at gmail.com
Sun Jul 19 10:49:31 EDT 2015
On 19.07.2015 16:39, Yaron Cohen-Tal wrote:
> I want to set "FOO" to "TRUE" iff both "COND_A" and "COND_B" are
> true.I tried the following:
>
> set (FOO (${COND_A} AND ${COND_B}))
The AND operator is handled and implemented by the if() and while()
commands and hence not available elsewhere.
>
> but then FOO get's a value like "(;TRUE;AND;TRUE;)" instead of "TRUE".
> So I had to write instead:
>
> if (${COND_A} AND ${COND_B})
> set (FOO TRUE)
> else ()
> set (FOO FALSE)
> endif ()
>
> Is there a better way?
>
Depending on context you might omit the else() block given that if(FOO)
will evaluate false if FOO is not a defined variable.
Nils
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150719/87c7f92f/attachment.html>
More information about the CMake
mailing list