brintos

brintos / llvm-project-archived public Read only

0
0
Text · 807 B · af65c27 Raw
26 lines · plain
1# Sort a subset of a list according to the ordering in the full list.2#3# Given a list and a subset of that list, this function sorts the subset4# according to the order in the full list, and returns that in the given5# output variable.6#7# full_list:8#   The list containing the desired order of elements in the sub-list.9#10# sub_list:11#   A subset of the elements in `full_list`. Those elements will be sorted12#   according to the order in `full_list`.13#14# out_var:15#   A variable to store the resulting sorted sub-list in.16function(sort_subset full_list sub_list out_var)17  set(result "${full_list}")18  foreach(project IN LISTS full_list)19    if (NOT project IN_LIST sub_list)20      list(REMOVE_ITEM result ${project})21    endif()22  endforeach()23 24  set(${out_var} "${result}" PARENT_SCOPE)25endfunction()26