CMP0174.rst 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. CMP0174
  2. -------
  3. .. versionadded:: 3.31
  4. :command:`cmake_parse_arguments(PARSE_ARGV)` defines a variable for an empty
  5. string after a single-value keyword.
  6. One of the main reasons for using the ``PARSE_ARGV`` form of the
  7. :command:`cmake_parse_arguments` command is to more robustly handle corner
  8. cases related to empty values. The non-``PARSE_ARGV`` form doesn't preserve
  9. empty arguments, but the ``PARSE_ARGV`` form does. For each single-value
  10. keyword given, a variable should be defined if the keyword is present, even
  11. if it is followed by an empty string.
  12. Prior to CMake 3.31, no variable would be defined if the value given after a
  13. single-value keyword was an empty string. This meant the code could not detect
  14. the difference between the keyword not being given, and it being given but with
  15. an empty value, except by iterating over all the arguments and checking if the
  16. keyword is present.
  17. For the ``OLD`` behavior of this policy,
  18. :command:`cmake_parse_arguments(PARSE_ARGV)` does not define a variable for a
  19. single-value keyword followed by an empty string, or followed by no value at
  20. all.
  21. For the ``NEW`` behavior, :command:`cmake_parse_arguments(PARSE_ARGV)` always
  22. defines a variable for each keyword given in the arguments, even a single-value
  23. keyword with an empty string as its value or no value at all. With the
  24. ``NEW`` behavior, the code can robustly check if a single-value keyword was
  25. given using just ``if(DEFINED <prefix>_<keyword>)``.
  26. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.31
  27. .. |WARNS_OR_DOES_NOT_WARN| replace:: warns
  28. .. include:: STANDARD_ADVICE.txt
  29. .. include:: DEPRECATED.txt