CMP0012.rst 1.2 KB

12345678910111213141516171819202122232425262728
  1. CMP0012
  2. -------
  3. :command:`if` recognizes numbers and boolean constants.
  4. In CMake versions 2.6.4 and lower the :command:`if` command implicitly
  5. dereferenced arguments corresponding to variables, even those named
  6. like numbers or boolean constants, except for ``0`` and ``1``. Numbers and
  7. boolean constants such as ``true``, ``false``, ``yes``, ``no``, ``on``,
  8. ``off``, ``y``, ``n``, ``notfound``, ``ignore`` (all case insensitive)
  9. were recognized in some cases but not all. For example, the code ``if(TRUE)``
  10. might have evaluated as ``false``.
  11. Numbers such as 2 were recognized only in boolean expressions
  12. like ``if(NOT 2)`` (leading to ``false``) but not as a single-argument like
  13. ``if(2)`` (also leading to ``false``). Later versions of CMake prefer to
  14. treat numbers and boolean constants literally, so they should not be
  15. used as variable names.
  16. The ``OLD`` behavior for this policy is to implicitly dereference
  17. variables named like numbers and boolean constants. The ``NEW`` behavior
  18. for this policy is to recognize numbers and boolean constants without
  19. dereferencing variables with such names.
  20. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 2.8.0
  21. .. |WARNS_OR_DOES_NOT_WARN| replace:: warns
  22. .. include:: STANDARD_ADVICE.txt
  23. .. include:: DEPRECATED.txt