[CMake] Explanation....

David Cole dlrdave at aol.com
Mon Apr 28 08:16:30 EDT 2014


> I'm always happy to learn something new. How would you manage to make
> the following if statement trigger?
>
> set( arg "value")
> if (" ${arg}" STREQUAL " TOTO" )
>   message ( "arg equals 'TOTO', and arg equals 'value'" )
> endif()


By having a variable named " value" that you didn't know about...

This makes it print out:

    set(" value" " TOTO")

    set( arg "value")
    if (" ${arg}" STREQUAL " TOTO" )
      message ( "arg equals 'TOTO', and arg equals 'value'" )
    endif()

:-)

Ridiculous, I know, but possible, and therefore, I'm sure somebody has
seen the unexpected as a result of this "feature"...


Cheers,
David C.



More information about the CMake mailing list