annotate cmake/ParseArguments.cmake @ 356:67b471c4d1fc

Default for loaded certificates from file to install
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 10 Apr 2014 16:23:29 +0200
parents 524cd4908656
children
rev   line source
1
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1 # Parse arguments passed to a function into several lists separated by
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
2 # upper-case identifiers and options that do not have an associated list e.g.:
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
3 #
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
4 # SET(arguments
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
5 # hello OPTION3 world
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
6 # LIST3 foo bar
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
7 # OPTION2
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
8 # LIST1 fuz baz
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
9 # )
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
10 # PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "OPTION1;OPTION2;OPTION3" ${arguments})
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
11 #
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
12 # results in 7 distinct variables:
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
13 # * ARG_DEFAULT_ARGS: hello;world
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
14 # * ARG_LIST1: fuz;baz
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
15 # * ARG_LIST2:
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
16 # * ARG_LIST3: foo;bar
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
17 # * ARG_OPTION1: FALSE
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
18 # * ARG_OPTION2: TRUE
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
19 # * ARG_OPTION3: TRUE
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
20 #
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
21 # taken from http://www.cmake.org/Wiki/CMakeMacroParseArguments
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
22
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
23 MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
24 SET(DEFAULT_ARGS)
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
25 FOREACH(arg_name ${arg_names})
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
26 SET(${prefix}_${arg_name})
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
27 ENDFOREACH(arg_name)
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
28 FOREACH(option ${option_names})
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
29 SET(${prefix}_${option} FALSE)
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
30 ENDFOREACH(option)
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
31
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
32 SET(current_arg_name DEFAULT_ARGS)
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
33 SET(current_arg_list)
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
34 FOREACH(arg ${ARGN})
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
35 SET(larg_names ${arg_names})
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
36 LIST(FIND larg_names "${arg}" is_arg_name)
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
37 IF (is_arg_name GREATER -1)
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
38 SET(${prefix}_${current_arg_name} ${current_arg_list})
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
39 SET(current_arg_name ${arg})
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
40 SET(current_arg_list)
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
41 ELSE (is_arg_name GREATER -1)
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
42 SET(loption_names ${option_names})
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
43 LIST(FIND loption_names "${arg}" is_option)
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
44 IF (is_option GREATER -1)
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
45 SET(${prefix}_${arg} TRUE)
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
46 ELSE (is_option GREATER -1)
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
47 SET(current_arg_list ${current_arg_list} ${arg})
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
48 ENDIF (is_option GREATER -1)
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
49 ENDIF (is_arg_name GREATER -1)
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
50 ENDFOREACH(arg)
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
51 SET(${prefix}_${current_arg_name} ${current_arg_list})
524cd4908656 Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
52 ENDMACRO(PARSE_ARGUMENTS)

http://wald.intevation.org/projects/trustbridge/