function(FindTargetPlatform)
    set(options)
    set(oneValueArgs NAME)
    set(multiValueArgs)

    cmake_parse_arguments(PARAM "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

    if(WIN32)
        set(PLATFORM "Win32")
    elseif(UNIX)
        if(ANDROID)
            set(PLATFORM "Android")
        elseif(APPLE)
            set(PLATFORM "MacOS")
        else()
            set(PLATFORM "Linux")
        endif()
    else()
        message(FATAL_ERROR "Platform not supported!")
    endif()

    set(${PARAM_NAME} ${PLATFORM} PARENT_SCOPE)
endfunction()

function(FindTargetProcessor)
    set(options)
    set(oneValueArgs NAME)
    set(multiValueArgs)

    cmake_parse_arguments(PARAM "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

    if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
        set(ARCH "x86")
    elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
        set(ARCH "x86")
    elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
        set(ARCH "x86")
    elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
        set(ARCH "x86")
    elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
        set(ARCH "x86")
    elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
        set(ARCH "x86")
    elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm")
        set(ARCH "arm")
    elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv6")
        set(ARCH "arm_v6")
    elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7-a")
        set(ARCH "arm_v7")
    elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64-v8a")
        set(ARCH "arm_v8")
    else()
        message(FATAL_ERROR "Unknown processor:" ${CMAKE_SYSTEM_PROCESSOR})
    endif()

    set(${PARAM_NAME} ${ARCH} PARENT_SCOPE)
endfunction()

function(FindTargetArchitecture)
    set(options)
    set(oneValueArgs NAME)
    set(multiValueArgs)

    cmake_parse_arguments(PARAM "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

    if(CMAKE_SIZEOF_VOID_P EQUAL 8)
        set(ARCH "64")
    else()
        set(ARCH "32")
    endif()

    FindTargetProcessor(NAME PROC)

    set(${PARAM_NAME} "${PROC}_${ARCH}" PARENT_SCOPE)
endfunction()
