function(LoadDependency uri relpath)
    set(outmsg "Check ${relpath}...")
    if (EXISTS ${CMAKE_SOURCE_DIR}/${relpath})
        message(STATUS "${outmsg} Already exists")
    else()
        message(STATUS "${outmsg} Download ${relpath}")

        set(result_list "")
        set(code "")
        file(DOWNLOAD ${uri} ${CMAKE_SOURCE_DIR}/${relpath} STATUS result_list)
        list(GET result_list 0 code)

        if (${code})
            set(error "")
            list(GET result_list 1 error)
            message(SEND_ERROR "Error downloading ${relpath}: ${error}")
        else()
            message(STATUS "Done")
        endif()

    endif()
endfunction()
