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.

<<attachment: loose.vcf>>

--

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

Reply via email to