blob: c889320bfdd97c4746b22c7bc27e3dd3f2dfb603 [file] [log] [blame]
Gyorgy Szing49091802020-11-24 00:33:09 +01001#-------------------------------------------------------------------------------
2# Copyright (c) 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()
38
39# Verify MSYS environment.
40function(ts_verify_build_env)
41 if (WIN32)
42 #On MSYS2 64 bit builds do not work. Verify environment.
43 execute_process(COMMAND uname -s
44 OUTPUT_VARIABLE _os_name)
45 #If uname is present we assume MSYS environment and the os name must
46 #contain MING32.
47 if(_os_name STREQUAL "" AND NOT _os_name MATCHES ".*MINGW32.*")
48 message(FATAL_ERROR "This seems to be a 64 bit MINGW shell, which has issues. Please run the 32bit version.")
49 endif()
50 endif()
51endFunction()