include_guard(GLOBAL)

# Like list(TRANSFORM) but on a key
function (ixm_dict_transform dict key)
  void(OUTPUT_VARIABLE values)
  ixm_dict_noop(${dict})
  ixm_dict_get(${dict} ${key} values)
  if (NOT values)
    return()
  endif()
  list(TRANSFORM values ${ARGN})
  ixm_dict_assign(${dict} ${key} ${values})
  parse(${ARGN} @ARGS=? OUTPUT_VARIABLE)
  if (OUTPUT_VARIABLE)
    set(${OUTPUT_VARIABLE} ${${OUTPUT_VARIABLE}} PARENT_SCOPE)
  endif()
endfunction()

# list(FILTER) but on a key
function (ixm_dict_filter dict key)
  void(values)
  ixm_dict_noop(${dict})
  ixm_dict_get(${dict} ${key} values)
  if (NOT values)
    return()
  endif()
  list(FILTER values ${ARGN})
  ixm_dict_assign(${dict} ${key} ${values})
endfunction()