Unexpected order of precedence inside if()
As stated in the documentation, expression inside if
is evaluated with traditional order of precedence. Hence, I expect this:
if((A STREQUAL "foo" AND B STREQUAL "bar") OR (A STREQUAL "foo" AND B STREQUAL "baz"))
To yield the same result as:
if(A STREQUAL "foo" AND B STREQUAL "bar" OR A STREQUAL "foo" AND B STREQUAL "baz")
However, it does not. Here's my test script:
set(A "foo")
set(B "bar")
# passes
if((A STREQUAL "foo" AND B STREQUAL "bar") OR (A STREQUAL "foo" AND B STREQUAL "baz"))
message("OK")
else()
message(FATAL_ERROR "FAIL")
endif()
# should have the same outcome, but doesn't?
if(A STREQUAL "foo" AND B STREQUAL "bar" OR A STREQUAL "foo" AND B STREQUAL "baz")
message("OK")
else()
message(FATAL_ERROR "FAIL") # if() returns FALSE, oops!
endif()
If this is a bug, it should've been found ages ago, so I'm probably missing something.
Tested on Windows using CMake 3.13.0-rc3.
Edited by Alexander Sharov