-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMUTIL_TRAIT.cmake
More file actions
49 lines (44 loc) · 918 Bytes
/
CMUTIL_TRAIT.cmake
File metadata and controls
49 lines (44 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
## Main
#
# Trait is something which has to be true!
# Otherwise FATAL_ERROR occur
#
IF(DEFINED CMUTIL_TRAIT_MODULE)
RETURN()
ENDIF()
SET(CMUTIL_TRAIT_MODULE 1)
FIND_PACKAGE(CMLIB)
##
# Check if all elements from array VALUES
# can be found in array ${ARRAY}
#
# <function> (
# ARRAY <array_name>
# VALUES <values> M
# DESCRIPTION <description>
# )
#
FUNCTION(CMUTIL_TRAIT_IN_ARRAY)
CMLIB_PARSE_ARGUMENTS(
MULTI_VALUE
VALUES
ARRAY
ONE_VALUE
DESCRIPTION
REQUIRED
DESCRIPTION
VALUES
ARRAY
P_ARGN ${ARGN}
)
IF("${__DESCRIPTION}" STREQUAL "")
MESSAGE(FATAL_ERROR "Description cannot be empty")
ENDIF()
FOREACH(element IN LISTS __VALUES)
LIST(FIND ${__ARRAY} ${element} in_array)
IF(in_array EQUAL -1)
LIST(JOIN ${__ARRAY} "," array_join)
MESSAGE(FATAL_ERROR "${description} - element '${element}' is not in array '${array_join}'")
ENDIF()
ENDFOREACH()
ENDFUNCTION()