summaryrefslogtreecommitdiff
path: root/cmake/vala/ParseArguments.cmake
diff options
context:
space:
mode:
authorAlessandro Ghedini <al3xbio@gmail.com>2011-10-19 10:56:04 +0200
committerAlessandro Ghedini <al3xbio@gmail.com>2011-10-19 10:56:04 +0200
commit6451a495637c6e3047a5a56573cffc6e3de9a515 (patch)
tree7c3eb29532e7c4b36a9da13c5890664fb816959b /cmake/vala/ParseArguments.cmake
Imported Upstream version 0.2+gitdfdad95upstream/0.2+gitdfdad95
Diffstat (limited to 'cmake/vala/ParseArguments.cmake')
-rw-r--r--cmake/vala/ParseArguments.cmake36
1 files changed, 36 insertions, 0 deletions
diff --git a/cmake/vala/ParseArguments.cmake b/cmake/vala/ParseArguments.cmake
new file mode 100644
index 0000000..717c0f5
--- /dev/null
+++ b/cmake/vala/ParseArguments.cmake
@@ -0,0 +1,36 @@
+##
+# This is a helper Macro to parse optional arguments in Macros/Functions
+# It has been taken from the public CMake wiki.
+# See http://www.cmake.org/Wiki/CMakeMacroParseArguments for documentation and
+# licensing.
+##
+macro(parse_arguments prefix arg_names option_names)
+ set(DEFAULT_ARGS)
+ foreach(arg_name ${arg_names})
+ set(${prefix}_${arg_name})
+ endforeach(arg_name)
+ foreach(option ${option_names})
+ set(${prefix}_${option} FALSE)
+ endforeach(option)
+
+ set(current_arg_name DEFAULT_ARGS)
+ set(current_arg_list)
+ foreach(arg ${ARGN})
+ set(larg_names ${arg_names})
+ list(FIND larg_names "${arg}" is_arg_name)
+ if(is_arg_name GREATER -1)
+ set(${prefix}_${current_arg_name} ${current_arg_list})
+ set(current_arg_name ${arg})
+ set(current_arg_list)
+ else(is_arg_name GREATER -1)
+ set(loption_names ${option_names})
+ list(FIND loption_names "${arg}" is_option)
+ if(is_option GREATER -1)
+ set(${prefix}_${arg} TRUE)
+ else(is_option GREATER -1)
+ set(current_arg_list ${current_arg_list} ${arg})
+ endif(is_option GREATER -1)
+ endif(is_arg_name GREATER -1)
+ endforeach(arg)
+ set(${prefix}_${current_arg_name} ${current_arg_list})
+endmacro(parse_arguments)