1# - List filtering functions
2#
3#  list_filter(var regex listitems...) - where var is the name of
4#   your desired output variable, regex is the regex whose matching items
5#   WILL be put in the output variable, and everything else is considered
6#   a list item to be filtered.
7#
8#  list_filter_out(var regex listitems...) - where var is the name of
9#   your desired output variable, regex is the regex whose matching items
10#   will NOT be put in the output variable, and everything else is considered
11#   a list item to be filtered.
12#
13# Original Author:
14# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
15# http://academic.cleardefinition.com
16# Iowa State University HCI Graduate Program/VRAC
17#
18# Copyright Iowa State University 2009-2010.
19# Distributed under the Boost Software License, Version 1.0.
20# (See accompanying file LICENSE_1_0.txt or copy at
21# http://www.boost.org/LICENSE_1_0.txt)
22
23if(__list_filter_out)
24	return()
25endif()
26set(__list_filter_out YES)
27
28function(list_filter_out var regex)
29	set(_out)
30	foreach(_item ${ARGN})
31		set(_re)
32		string(REGEX MATCH "${regex}" _re "${_item}")
33		if(NOT _re)
34			list(APPEND _out "${_item}")
35		endif()
36	endforeach()
37	set(${var} "${_out}" PARENT_SCOPE)
38endfunction()
39
40function(list_filter var regex)
41	set(_out)
42	foreach(_item ${ARGN})
43		set(_re)
44		string(REGEX MATCH "${regex}" _re "${_item}")
45		if(_re)
46			list(APPEND _out "${_item}")
47		endif()
48	endforeach()
49	set(${var} "${_out}" PARENT_SCOPE)
50endfunction()
51