According to the CMake documentation, the STREQUAL
comparison is allowed to take either a VARIABLE or a STRING as either parameter. So, in this example below, the message does NOT print, which is broken:
set( FUBARTEST "OK" )
if( FUBARTEST STREQUAL "OK" )
message( "It Worked" )
endif()
Any reason why this isn't working as documented?
The issue was my cache. I deleted my cache and reconfigured and now the code works.
I didn't test your example at first, but when I did, I see your code works fine on cmake 2.8.0, and the other combinations advertised in the docs do too:
set( FUBARTEST "OK" )
if( FUBARTEST STREQUAL "OK" )
message( "FUBARTEST Worked" )
else()
message( "FUBARTEST FAILED" )
endif()
set( FOO "OK" )
if( ${FOO} STREQUAL "OK" )
message("string STREQUAL string works" )
else ()
message("string STREQUAL string FAILED" )
endif()
set( FOO "OK" )
set( BAR "OK" )
if( FOO STREQUAL BAR )
message("variable STREQUAL variable works" )
else ()
message("variable STREQUAL variable FAILED" )
endif()
set( FOO "OK" )
if( FOO STREQUAL "OK" )
message("variable STREQUAL string works" )
else ()
message("variable STREQUAL string FAILED" )
endif()
gives output:
FUBARTEST Worked
string STREQUAL string works
variable STREQUAL variable works
variable STREQUAL string works
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With