1# - Combine lists of prefixes and suffixes in all combinations
2#
3#  list_combinations(var PREFIXES listitems... SUFFIXES listitems...) -
4#   where var is the name of your desired output variable and PREFIXES
5#   and SUFFIXES are special arguments that indicate the start of your
6#   list of prefixes or suffixes respectively.
7#
8# Original Author:
9# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
10# http://academic.cleardefinition.com
11# Iowa State University HCI Graduate Program/VRAC
12#
13# Copyright Iowa State University 2009-2010.
14# Distributed under the Boost Software License, Version 1.0.
15# (See accompanying file LICENSE_1_0.txt or copy at
16# http://www.boost.org/LICENSE_1_0.txt)
17
18if(__list_combinations)
19	return()
20endif()
21set(__list_combinations YES)
22
23function(list_combinations var)
24	# Parse arguments
25	set(_prefixes)
26	set(_suffixes)
27	set(_nowhere)
28	set(_curdest _nowhere)
29	foreach(_element ${ARGN})
30		if("${_element}" STREQUAL "PREFIXES")
31			set(_curdest _prefixes)
32		elseif("${_element}" STREQUAL "SUFFIXES")
33			set(_curdest _suffixes)
34		else()
35			list(APPEND ${_curdest} "${_element}")
36		endif()
37	endforeach()
38	if(_nowhere)
39		message(STATUS "_prefixes ${_prefixes}")
40		message(STATUS "_prefixes ${_suffixes}")
41		message(STATUS "_prefixes ${_nowhere}")
42		message(FATAL_ERROR
43			"Syntax error in use of ${CMAKE_CURRENT_LIST_FILE}")
44	endif()
45
46	foreach(_prefix ${_prefixes})
47		foreach(_suffix ${_suffixes})
48			list(APPEND _out "${_prefix}${_suffix}")
49		endforeach()
50	endforeach()
51
52	set(${var} "${_out}" PARENT_SCOPE)
53endfunction()
54