1# - For each given prefix in a list, glob using the prefix+pattern
2#
3#
4# Original Author:
5# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
6# http://academic.cleardefinition.com
7# Iowa State University HCI Graduate Program/VRAC
8#
9# Copyright Iowa State University 2009-2010.
10# Distributed under the Boost Software License, Version 1.0.
11# (See accompanying file LICENSE_1_0.txt or copy at
12# http://www.boost.org/LICENSE_1_0.txt)
13
14if(__prefix_list_glob)
15	return()
16endif()
17set(__prefix_list_glob YES)
18
19function(prefix_list_glob var pattern)
20	set(_out)
21	set(_result)
22	foreach(prefix ${ARGN})
23		file(GLOB _globbed ${prefix}${pattern})
24		if(_globbed)
25			list(SORT _globbed)
26			list(REVERSE _globbed)
27			list(APPEND _out ${_globbed})
28		endif()
29	endforeach()
30	foreach(_name ${_out})
31		get_filename_component(_name "${_name}" ABSOLUTE)
32		list(APPEND _result "${_name}")
33	endforeach()
34
35	set(${var} "${_result}" PARENT_SCOPE)
36endfunction()
37