@@ -58,14 +58,26 @@ if (NOT COMMAND "requires_arguments")
5858 # @see https://cmake.org/cmake/help/latest/command/cmake_parse_arguments.html#cmake-parse-arguments
5959 # @see https://cmake.org/cmake/help/latest/command/if.html#defined
6060 #
61- # @param <variable|string> input The parsed arguments prefix
62- # @param <list> required List of required arguments
61+ # @param <list> required List of required arguments
62+ # @param <variable|string> prefix The parsed input arguments prefix
63+ # used in your cmake_parse_arguments() call.
6364 #
6465 # @throws If required arguments are not defined
6566 #
66- macro (requires_arguments input required)
67+ macro (requires_arguments required prefix )
68+ # Note: the "prefix" parameter cannot be made optional for this macro.
69+ # It is unsafe to rely on any ${ARGV} in this context, ...
70+ # @see https://cmake.org/cmake/help/latest/command/macro.html#argument-caveats
71+
72+ # Append "_" to the prefix, if given.
73+ # @see https://cmake.org/cmake/help/latest/command/cmake_parse_arguments.html#cmake-parse-arguments
74+ set (resolved_prefix "${prefix} " )
75+ if (NOT ${prefix} EQUAL "" )
76+ set (resolved_prefix "${prefix} _" )
77+ endif ()
78+
6779 foreach (arg ${required} )
68- if (NOT DEFINED "${input} _ ${arg} " )
80+ if (NOT DEFINED "${resolved_prefix} ${arg} " )
6981 message (FATAL_ERROR "${arg} argument is missing, for ${CMAKE_CURRENT_FUNCTION} ()" )
7082 endif ()
7183 endforeach ()
0 commit comments