File: ListCombinations.cmake

package info (click to toggle)
freespace2 25.0.0%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 47,232 kB
  • sloc: cpp: 657,500; ansic: 22,305; sh: 293; python: 200; makefile: 198; xml: 181
file content (56 lines) | stat: -rw-r--r-- 1,564 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# - Combine lists of prefixes and suffixes in all combinations
#
#  list_combinations(var PREFIXES listitems... SUFFIXES listitems...) -
#   where var is the name of your desired output variable and PREFIXES
#   and SUFFIXES are special arguments that indicate the start of your
#   list of prefixes or suffixes respectively.
#
# Original Author:
# 2009-2010 Rylie Pavlik <rylie@ryliepavlik.com>
# https://ryliepavlik.com/
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright 2009-2010, Iowa State University
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# SPDX-License-Identifier: BSL-1.0

if(__list_combinations)
	return()
endif()
set(__list_combinations YES)

function(list_combinations var)
	# Parse arguments
	set(_prefixes)
	set(_suffixes)
	set(_nowhere)
	set(_curdest _nowhere)
	foreach(_element ${ARGN})
		if("${_element}" STREQUAL "PREFIXES")
			set(_curdest _prefixes)
		elseif("${_element}" STREQUAL "SUFFIXES")
			set(_curdest _suffixes)
		else()
			list(APPEND ${_curdest} "${_element}")
		endif()
	endforeach()
	if(_nowhere)
		message(STATUS "_prefixes ${_prefixes}")
		message(STATUS "_prefixes ${_suffixes}")
		message(STATUS "_prefixes ${_nowhere}")
		message(FATAL_ERROR
			"Syntax error in use of ${CMAKE_CURRENT_LIST_FILE}")
	endif()

	foreach(_prefix ${_prefixes})
		foreach(_suffix ${_suffixes})
			list(APPEND _out "${_prefix}${_suffix}")
		endforeach()
	endforeach()

	set(${var} "${_out}" PARENT_SCOPE)
endfunction()