include_guard(GLOBAL)

function(add_library name)
    _add_library(${name} ${ARGN})
    set(TARGET ${name} PARENT_SCOPE)
endfunction()

function(ggml_get_system_arch)
    set(options)
    set(oneValueArgs RESULT)
    set(multiValueArgs)
    cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

    if(CMAKE_OSX_ARCHITECTURES STREQUAL "arm64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
        set(${ARG_RESULT} "arm64" PARENT_SCOPE)
    elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64")
        set(${ARG_RESULT} "x86" PARENT_SCOPE)
    elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i[3-6]86")
        set(${ARG_RESULT} "x86" PARENT_SCOPE)
    elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
        set(${ARG_RESULT} "x86" PARENT_SCOPE)
    else()
        set(${ARG_RESULT} "x86" PARENT_SCOPE)
    endif()
endfunction()
