Folks:

This seems like CMake 101, but I'm running into weird behavior testing
boolean expressions within a macro.  I've reproduced the problem using
both 2.4.7 and CVS trunk on Gentoo Linux, presumably it is some subtlety
that I just don't get :)

If I run the following:

        set(var YES)

        if(var)
                message("true")
        else(var)
                message("false")
        endif(var)

I get the expected result:

        true

This produces expected results for all of the documented "boolean"
values: YES, NO, TRUE, FALSE, ON, OFF, etc.  However, if I pass one of
those values to a macro:

        macro(test var)
                if(${var})
                        message("true")
                else(${var})
                        message("false")
                endif(${var})
        endmacro(test)

        test(1)
        test(0)
        test(YES)
        test(NO)
        test(TRUE)
        test(FALSE)
        test(ON)
        test(OFF)

Things look pretty strange to me:

        true
        false
        false
        false
        false
        false
        false
        false

... only "1" tests true!  Can anyone shed some light on where I'm going
wrong?

Thanks in advance,
Tim


_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to