[CMake] [WIKI] New macro `LIST_FILTER'
Tristan Carel
tristan.carel at gmail.com
Sat Sep 1 15:24:55 EDT 2007
Hi,
I have added a macro to the CMake wiki to filter list items with
regular expressions.
Here is the synopsis/doc:
# LIST_FILTER(<list> <regexp_var> [<regexp_var> ...]
# [OUTPUT_VARIABLE <variable>])
# Removes items from <list> which do not match any of the specified
# regular expressions. An optional argument OUTPUT_VARIABLE
# specifies a variable in which to store the matched items instead of
# updating <list>
# As regular expressions can not be given to macros (see bug #5389), we pass
# variable names whose content is the regular expressions.
# Note that this macro requires PARSE_ARGUMENTS macro, available here:
# http://www.cmake.org/Wiki/CMakeMacroParseArguments
Code and examples available on CMake wiki:
http://www.cmake.org/Wiki/CMakeMacroListOperations#LIST_FILTER
The code uses FATAL_ERROR when arguments are wrong. It is rude but I
prefer this way as it prevents further logic errors. As there is no
need to reinvent the wheel, It uses the powerful PARSE_ARGUMENTS
macro, available on CMake wiki.
HTH
--
Tristan Carel
Music with dinner is an insult both to the cook and the violinist.
http://www.tristancarel.com
More information about the CMake
mailing list