1
# Parse arguments passed to a function into several lists separated by
2
# upper-case identifiers and options that do not have an associated list e.g.:
10
# PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "OPTION1;OPTION2;OPTION3" ${arguments})
12
# results in 7 distinct variables:
13
# * ARG_DEFAULT_ARGS: hello;world
14
# * ARG_LIST1: fuz;baz
16
# * ARG_LIST3: foo;bar
17
# * ARG_OPTION1: FALSE
21
# taken from http://www.cmake.org/Wiki/CMakeMacroParseArguments
23
MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
25
FOREACH(arg_name ${arg_names})
26
SET(${prefix}_${arg_name})
28
FOREACH(option ${option_names})
29
SET(${prefix}_${option} FALSE)
32
SET(current_arg_name DEFAULT_ARGS)
35
SET(larg_names ${arg_names})
36
LIST(FIND larg_names "${arg}" is_arg_name)
37
IF (is_arg_name GREATER -1)
38
SET(${prefix}_${current_arg_name} ${current_arg_list})
39
SET(current_arg_name ${arg})
41
ELSE (is_arg_name GREATER -1)
42
SET(loption_names ${option_names})
43
LIST(FIND loption_names "${arg}" is_option)
44
IF (is_option GREATER -1)
45
SET(${prefix}_${arg} TRUE)
46
ELSE (is_option GREATER -1)
47
SET(current_arg_list ${current_arg_list} ${arg})
48
ENDIF (is_option GREATER -1)
49
ENDIF (is_arg_name GREATER -1)
51
SET(${prefix}_${current_arg_name} ${current_arg_list})
52
ENDMACRO(PARSE_ARGUMENTS)