File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,30 @@ if (NOT COMMAND "extract_value")
4848 endfunction ()
4949endif ()
5050
51+ if (NOT COMMAND "requires_arguments" )
52+
53+ #! requires_arguments : Verifies that specified arguments have been defined, fails otherwise
54+ #
55+ # Macro is intended to be used within a custom function, after `cmake_parse_arguments()` has
56+ # been used.
57+ #
58+ # @see https://cmake.org/cmake/help/latest/command/cmake_parse_arguments.html#cmake-parse-arguments
59+ # @see https://cmake.org/cmake/help/latest/command/if.html#defined
60+ #
61+ # @param <variable|string> input The parsed arguments prefix
62+ # @param <list> required List of required arguments
63+ #
64+ # @throws If required arguments are not defined
65+ #
66+ macro (requires_arguments input required)
67+ foreach (arg ${required} )
68+ if (NOT DEFINED "${input} _${arg} " )
69+ message (FATAL_ERROR "${arg} argument is missing, for ${CMAKE_CURRENT_FUNCTION} ()" )
70+ endif ()
71+ endforeach ()
72+ endmacro ()
73+ endif ()
74+
5175if (NOT COMMAND "safeguard_properties" )
5276
5377 #! safeguard_properties : Invoke a "risky" callback whilst "safeguarding" properties
You can’t perform that action at this time.
0 commit comments