[CMake] Inconsistent CMake Warning on policy CMP0012

David Cole david.cole at kitware.com
Wed Dec 12 11:32:13 EST 2012


Only the "special" strings cause the warning. Things like "Y" "y" "N" "n"
"true" "0" "1" "on" "off" etc.

This is correct behavior and what the policy is about. It's not about
strings in general, but about the specific strings that are used for
boolean constant aliases...



On Wed, Dec 12, 2012 at 10:30 AM, Marcel Loose <loose at astron.nl> wrote:

> Hi all,
>
> I noticed that, when using a string expression in an IF() statement --
> which you obviously shouldn't do, but I was just playing around -- CMake
> sometimes generates a developer warning CMP0012. Whether it does that or
> not depends on the string your using.
>
> The following file
>
> $ cat string_in_conditional.cmake
> if("x")
>   message(STATUS "\"x\" evaluate to TRUE")
> else()
>   message(STATUS "\"x\" evaluate to FALSE")
> endif()
> if("y")
>   message(STATUS "\"y\" evaluate to TRUE")
> else()
>   message(STATUS "\"y\" evaluate to FALSE")
> endif()
>
> produces the following output when run with cmake 2.8.9
>
> $ cmake -P string_in_conditional.cmake
> -- "x" evaluate to FALSE
> CMake Warning (dev) at string_in_conditional.cmake:6 (if):
>   given arguments:
>
>     "y"
>
>   An argument named "y" appears in a conditional statement.  Policy CMP0012
>   is not set: if() recognizes numbers and boolean constants.  Run "cmake
>   --help-policy CMP0012" for policy details.  Use the cmake_policy command
> to
>   set the policy and suppress this warning.
> This warning is for project developers.  Use -Wno-dev to suppress it.
>
> -- "y" evaluate to FALSE
>
> I.e., it doesn't produce a warning when using "x" in an if() statement,
> but it does when using "y".
>
>
> Best regards,
> Marcel Loose.
>
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20121212/d39330c5/attachment.htm>


More information about the CMake mailing list