function(get_target_triplet VOUT)
    if(APPLE)
        if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
          set(${VOUT} "x86_64-apple-darwin17.0.0" PARENT_SCOPE)
        endif()
    elseif(WIN32)
        if(CMAKE_CL_64)
            set(${VOUT} "x86_64-pc-windows-msvc19.0.0" PARENT_SCOPE)
        else()
            set(${VOUT} "i686-pc-windows-msvc19.0.0" PARENT_SCOPE)
        endif()
    endif()
endfunction()

function(are_triplets_compatible VOUT T1 T2)
    string(REPLACE "-" ";" T1LIST ${T1})
    string(REPLACE "-" ";" T2LIST ${T2})
    list(LENGTH T1LIST T1LEN)
    list(LENGTH T2LIST T2LEN)
    list(GET T1LIST 0 T1MACH)
    list(GET T2LIST 0 T2MACH)
    list(GET T1LIST 1 T1VENDOR)
    list(GET T2LIST 1 T2VENDOR)
    list(GET T1LIST 2 T1OS)
    list(GET T2LIST 2 T2OS)
    if(T1LEN LESS_EQUAL 3)
        set(T1ABI "")
    else()
        list(GET T1LIST 3 T1ABI)
    endif()
    if(T2LEN LESS_EQUAL 3)
        set(T2ABI "")
    else()
        list(GET T2LIST 3 T2ABI)
    endif()

    # Machines have to be equal
    if(T1MACH STREQUAL T2MACH)
        string(FIND ${T1OS} darwin _T)
        if(NOT _T EQUAL -1)
            string(FIND ${T2OS} darwin _T)
            if(NOT _T EQUAL -1)
                set(${VOUT} YES PARENT_SCOPE)
            else()
                set(${VOUT} NO PARENT_SCOPE)
            endif()
        else()
            # Not darwin
            set(${VOUT} NO PARENT_SCOPE)
        endif()
    else()
        set(${VOUT} NO PARENT_SCOPE)
    endif()
endfunction()
