[CMake] Inconsistent CMake Warning on policy CMP0012
Marcel Loose
loose at astron.nl
Wed Dec 12 10:30:27 EST 2012
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: loose.vcf
Type: text/x-vcard
Size: 292 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20121212/23ac958d/attachment.vcf>
More information about the CMake
mailing list