function(list_subtract lhs rhs result_var_name)
  set(result)
  foreach(item IN LISTS lhs)
    list(FIND rhs "${item}" index)
    if(${index} EQUAL -1)
      list(APPEND result "${item}")
    endif()
  endforeach()
  set("${result_var_name}" "${result}" PARENT_SCOPE)
endfunction()

function(list_intersect lhs rhs result_var_name)
  set(result)
  foreach(item IN LISTS lhs)
    list(FIND rhs "${item}" index)
    if(NOT ${index} EQUAL -1)
      list(APPEND result "${item}")
    endif()
  endforeach()
  set("${result_var_name}" "${result}" PARENT_SCOPE)
endfunction()

function(list_union lhs rhs result_var_name)
  set(result)
  foreach(item IN LISTS lhs rhs)
    list(FIND result "${item}" index)
    if(${index} EQUAL -1)
      list(APPEND result "${item}")
    endif()
  endforeach()
  set("${result_var_name}" "${result}" PARENT_SCOPE)
endfunction()
