2
# This is a helper Macro to parse optional arguments in Macros/Functions
3
# It has been taken from the public CMake wiki.
4
# See http://www.cmake.org/Wiki/CMakeMacroParseArguments for documentation and
7
macro(parse_arguments prefix arg_names option_names)
9
foreach(arg_name ${arg_names})
10
set(${prefix}_${arg_name})
12
foreach(option ${option_names})
13
set(${prefix}_${option} FALSE)
16
set(current_arg_name DEFAULT_ARGS)
19
set(larg_names ${arg_names})
20
list(FIND larg_names "${arg}" is_arg_name)
21
if(is_arg_name GREATER -1)
22
set(${prefix}_${current_arg_name} ${current_arg_list})
23
set(current_arg_name ${arg})
25
else(is_arg_name GREATER -1)
26
set(loption_names ${option_names})
27
list(FIND loption_names "${arg}" is_option)
28
if(is_option GREATER -1)
29
set(${prefix}_${arg} TRUE)
30
else(is_option GREATER -1)
31
set(current_arg_list ${current_arg_list} ${arg})
32
endif(is_option GREATER -1)
33
endif(is_arg_name GREATER -1)
35
set(${prefix}_${current_arg_name} ${current_arg_list})
36
endmacro(parse_arguments)