summaryrefslogtreecommitdiffstats
path: root/Help/policy/CMP0174.rst
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2024-10-27 11:08:03 (GMT)
committerBrad King <brad.king@kitware.com>2024-10-28 13:47:21 (GMT)
commitc8567acc326dc72a7f9f8371bd6f4836eeab7c28 (patch)
tree90c443ded9cdac00b52dea8145364f55414fe904 /Help/policy/CMP0174.rst
parentfcff1dcb064950f83ef45a41ea236b64fe2ac5e7 (diff)
downloadCMake-c8567acc326dc72a7f9f8371bd6f4836eeab7c28.zip
CMake-c8567acc326dc72a7f9f8371bd6f4836eeab7c28.tar.gz
CMake-c8567acc326dc72a7f9f8371bd6f4836eeab7c28.tar.bz2
cmake_parse_arguments: Restore capture of value after repeated keyword
When a single-value keyword is repeated, and the first instance is missing a value, it prevents the value from the second instance from being stored in a variable. This was a regression introduced by commit ceeea4e511 (cmake_parse_arguments: Set variable if empty string given after keyword, 2024-08-18). That change also didn't create a variable if the keyword was given but without a value. The purpose of the change was to always define a variable if a keyword was given. Lastly, that change didn't protect the CMP0174 logic to make it only apply to the PARSE_ARGV form. The first two of the above problems are fixed here by tracking the keywords given instead of checking which keywords were missing values. The third problem is also fixed here, being tightly coupled to the same logic as the first two problems. Fixes: #26397
Diffstat (limited to 'Help/policy/CMP0174.rst')
-rw-r--r--Help/policy/CMP0174.rst24
1 files changed, 14 insertions, 10 deletions
diff --git a/Help/policy/CMP0174.rst b/Help/policy/CMP0174.rst
index bde0a03..748fdba 100644
--- a/Help/policy/CMP0174.rst
+++ b/Help/policy/CMP0174.rst
@@ -10,21 +10,25 @@ One of the main reasons for using the ``PARSE_ARGV`` form of the
:command:`cmake_parse_arguments` command is to more robustly handle corner
cases related to empty values. The non-``PARSE_ARGV`` form doesn't preserve
empty arguments, but the ``PARSE_ARGV`` form does. For each single-value
-keyword given, a variable should be defined if the keyword is followed by a
-value. Prior to CMake 3.31, no variable would be defined if the value given
-was an empty string. This meant the code could not detect the difference
-between the keyword not being given, and it being given but with an empty
-value, except by iterating over all the arguments and checking if the keyword
-is present.
+keyword given, a variable should be defined if the keyword is present, even
+if it is followed by an empty string.
+
+Prior to CMake 3.31, no variable would be defined if the value given after a
+single-value keyword was an empty string. This meant the code could not detect
+the difference between the keyword not being given, and it being given but with
+an empty value, except by iterating over all the arguments and checking if the
+keyword is present.
For the ``OLD`` behavior of this policy,
:command:`cmake_parse_arguments(PARSE_ARGV)` does not define a variable for a
-single-value keyword followed by an empty string.
+single-value keyword followed by an empty string, or followed by no value at
+all.
+
For the ``NEW`` behavior, :command:`cmake_parse_arguments(PARSE_ARGV)` always
defines a variable for each keyword given in the arguments, even a single-value
-keyword with an empty string as its value. With the ``NEW`` behavior, the
-code can robustly check if a single-value keyword was given with any value
-using just ``if(DEFINED <prefix>_<keyword>)``.
+keyword with an empty string as its value or no value at all. With the
+``NEW`` behavior, the code can robustly check if a single-value keyword was
+given using just ``if(DEFINED <prefix>_<keyword>)``.
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.31
.. |WARNS_OR_DOES_NOT_WARN| replace:: warns