[cmake-developers] [PATCH] remove "x" placeholder from STREQUAL operands

Jiri Malak malak.jiri at gmail.com
Sun Apr 13 04:22:44 EDT 2014


> Am Sonntag, 13. April 2014, 09:59:03 schrieb Jiri Malak:
>> >> I enclosed patch for removing placeholder "x" from STREQUAL operands.
>> >> It does comparision transparent.
>> >
>> > I very much would like to see that, but there is a problem: CMake may
>> > interpret the operands of STREQUAL both as text and as variable name.
>> >
>> > So this does what you expect for the moment:
>> >
>> > if (${CMAKE_SYSTEM_NAME} STREQUAL Linux) ...
>> >
>> > But now you will get into trouble:
>> >
>> > set(Linux Windows)
>> >
>> > Sadly the expression is even expanded when it is quoted as long as it is a
>> > valid variable name.
>        ^^^
>
>> Sorry, I am new for CMake script.
>> Is it also true for quoted operands?
>
> Yes.
>
> One other way to solve this: if you are sure both expressions are indeed
> variables you may simply write "if (foo STREQUAL bar)": the expression will
> always be expanded and you don't need any quoting. This is why e.g. things
> like CMAKE_* are rarely quoted or expanded by hand in such an expression, it
> is known that they will be a variable and will be expanded.
>
> Eike

Hmm..
It is a little bit confusing for newcommers that you can not do simple comparision for text word
if some variable with this name exists.

Thanks

Jiri





More information about the cmake-developers mailing list