6350.2.1
by Christian Dywan
Initial minimal CMake build setup |
1 |
##
|
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
|
|
5 |
# licensing.
|
|
6 |
##
|
|
7 |
macro(parse_arguments prefix arg_names option_names) |
|
8 |
set(DEFAULT_ARGS) |
|
9 |
foreach(arg_name ${arg_names}) |
|
10 |
set(${prefix}_${arg_name}) |
|
11 |
endforeach(arg_name) |
|
12 |
foreach(option ${option_names}) |
|
13 |
set(${prefix}_${option} FALSE) |
|
14 |
endforeach(option) |
|
15 |
||
16 |
set(current_arg_name DEFAULT_ARGS) |
|
17 |
set(current_arg_list) |
|
18 |
foreach(arg ${ARGN}) |
|
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}) |
|
24 |
set(current_arg_list) |
|
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) |
|
34 |
endforeach(arg) |
|
35 |
set(${prefix}_${current_arg_name} ${current_arg_list}) |
|
36 |
endmacro(parse_arguments) |