Mercurial > trustbridge
comparison cmake/ParseArguments.cmake @ 1:524cd4908656
Build infrastructure
Add hardening flags
Add static_check target for flawfinder and cppcheck
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 10 Feb 2014 16:14:55 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:cb0cde2c5eb9 | 1:524cd4908656 |
---|---|
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.: | |
3 # | |
4 # SET(arguments | |
5 # hello OPTION3 world | |
6 # LIST3 foo bar | |
7 # OPTION2 | |
8 # LIST1 fuz baz | |
9 # ) | |
10 # PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "OPTION1;OPTION2;OPTION3" ${arguments}) | |
11 # | |
12 # results in 7 distinct variables: | |
13 # * ARG_DEFAULT_ARGS: hello;world | |
14 # * ARG_LIST1: fuz;baz | |
15 # * ARG_LIST2: | |
16 # * ARG_LIST3: foo;bar | |
17 # * ARG_OPTION1: FALSE | |
18 # * ARG_OPTION2: TRUE | |
19 # * ARG_OPTION3: TRUE | |
20 # | |
21 # taken from http://www.cmake.org/Wiki/CMakeMacroParseArguments | |
22 | |
23 MACRO(PARSE_ARGUMENTS prefix arg_names option_names) | |
24 SET(DEFAULT_ARGS) | |
25 FOREACH(arg_name ${arg_names}) | |
26 SET(${prefix}_${arg_name}) | |
27 ENDFOREACH(arg_name) | |
28 FOREACH(option ${option_names}) | |
29 SET(${prefix}_${option} FALSE) | |
30 ENDFOREACH(option) | |
31 | |
32 SET(current_arg_name DEFAULT_ARGS) | |
33 SET(current_arg_list) | |
34 FOREACH(arg ${ARGN}) | |
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}) | |
40 SET(current_arg_list) | |
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) | |
50 ENDFOREACH(arg) | |
51 SET(${prefix}_${current_arg_name} ${current_arg_list}) | |
52 ENDMACRO(PARSE_ARGUMENTS) |