CMake implementation of topological sorting algorithm. More...
Go to the source code of this file.
Functions | |
function | topological_sort (in LIST, in PREFIX, in SUFFIX) |
CMake implementation of topological sorting algorithm.
Perform a reverse topological sort on the given LIST.
topological_sort(my_list "MY_" "_EDGES")
LIST is the name of a variable containing a list of elements to be sorted in reverse topological order. Each element in the list has a set of outgoing edges (for example, those other list elements that it depends on). In the resulting reverse topological ordering (written back into the variable named LIST), an element will come later in the list than any of the elements that can be reached by following its outgoing edges and the outgoing edges of any vertices they target, recursively. Thus, if the edges represent dependencies on build targets, for example, the reverse topological ordering is the order in which one would build those targets.
For each element E in this list, the edges for E are contained in the variable named ${PREFIX}${E}${SUFFIX}. If no such variable exists, then it is assumed that there are no edges. For example, if my_list contains a, b, and c, one could provide a dependency graph using the following variables:
MY_A_EDGES b MY_B_EDGES MY_C_EDGES a b
With the involcation of topological_sort shown above and these variables, the resulting reverse topological ordering will be b, a, c.
Definition in file TopologicalSort.cmake.
function topological_sort | ( | in | LIST, |
in | PREFIX, | ||
in | SUFFIX | ||
) |