1 # macro(MACRO_PARSE_ARGUMENTS prefix arg_names option_names)
3 # From http://www.cmake.org/Wiki/CMakeMacroParseArguments:
5 # The MACRO_PARSE_ARGUMENTS macro will take the arguments of another macro and
6 # define several variables:
8 # 1) The first argument to is a prefix to put on all variables it creates.
9 # 2) The second argument is a quoted list of names,
10 # 3) and the third argument is a quoted list of options.
12 # The rest of MACRO_PARSE_ARGUMENTS are arguments from another macro to be
15 # MACRO_PARSE_ARGUMENTS(prefix arg_names options arg1 arg2...)
17 # For each item in options, MACRO_PARSE_ARGUMENTS will create a variable
18 # with that name, prefixed with prefix_. So, for example, if prefix is
19 # MY_MACRO and options is OPTION1;OPTION2, then PARSE_ARGUMENTS will create
20 # the variables MY_MACRO_OPTION1 and MY_MACRO_OPTION2. These variables will
21 # be set to true if the option exists in the command line or false otherwise.
23 # For each item in arg_names, MACRO_PARSE_ARGUMENTS will create a variable
24 # with that name, prefixed with prefix_. Each variable will be filled with the
25 # arguments that occur after the given arg_name is encountered up to the next
26 # arg_name or the end of the arguments. All options are removed from these
29 # MACRO_PARSE_ARGUMENTS also creates a prefix_DEFAULT_ARGS variable containing
30 # the list of all arguments up to the first arg_name encountered.
34 macro(MACRO_PARSE_ARGUMENTS prefix arg_names option_names)
36 message(WARNING
"The MACRO_PARSE_ARGUMENTS macro is deprecated. Use cmake_parse_arguments instead.")
40 foreach(arg_name ${arg_names})
41 set(${prefix}_${arg_name})
44 foreach(option ${option_names})
45 set(${prefix}_${option} FALSE)
48 set(current_arg_name DEFAULT_ARGS)
53 set(larg_names ${arg_names})
54 list(FIND larg_names
"${arg}" is_arg_name)
56 if(is_arg_name GREATER -1)
58 set(${prefix}_${current_arg_name} ${current_arg_list})
59 set(current_arg_name
"${arg}")
62 else(is_arg_name GREATER -1)
64 set(loption_names ${option_names})
65 list(FIND loption_names
"${arg}" is_option)
67 if(is_option GREATER -1)
68 set(${prefix}_${arg} TRUE)
69 else(is_option GREATER -1)
70 set(current_arg_list ${current_arg_list}
"${arg}")
71 endif(is_option GREATER -1)
73 endif(is_arg_name GREATER -1)
75 endforeach(arg ${ARGN})
77 set(${prefix}_${current_arg_name} ${current_arg_list})
79 endmacro(MACRO_PARSE_ARGUMENTS)
81 endif(NOT COMMAND MACRO_PARSE_ARGUMENTS)
MACRO_PARSE_ARGUMENTS(prefix, arg_names, option_names)