blob: d93dcee519b5b2a6e46ba46b42f4956558e8caeb [file] [log] [blame]
Gyorgy Szing5e429cb2019-12-03 20:39:55 +01001#-------------------------------------------------------------------------------
2# Copyright (c) 2019-2020, Arm Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8#[===[.rst:
9Misc utilities
10--------------
11#]===]
12
13include_guard(DIRECTORY)
14
15#[===[.rst:
16.. cmake:command:: check_args
17
18 .. code-block:: cmake
19
20 check_args(func_name REQ_ARG1 REQ_ARG2)
21
22 Helper macro for argument checking in functions. First argument *func_name* is
23 the name of the function, other arguments are the names of the required
24 arguments to that function. The macro iterates through the list, and prints
25 and error message if not all arguments are defined.
26
27#]===]
28macro(check_args)
29 set(_argv "${ARGV}")
30 list(SUBLIST _argv 0 1 _func)
31 list(SUBLIST _argv 1 -1 _args)
32 foreach(_arg IN LISTS _args)
33 if (NOT DEFINED _MY_PARAMS_${_arg})
34 message(FATAL_ERROR "${_func}(): mandatory parameter '${_arg}' missing.")
35 endif()
36 endforeach()
37endmacro()