function(_pf_download url dest)
    cmake_parse_arguments(ARG "NO_CHECK" "RESULT_VARIABLE" "" "${ARGN}")
    set(tmp "${dest}.tmp")
    file(
        DOWNLOAD "${url}"
        "${tmp}"
        STATUS st
        )
    list(GET st 0 rc)
    list(GET st 1 msg)
    if(rc)
        file(REMOVE "${tmp}")
        if(NOT ARG_NO_CHECK)
            message(FATAL_ERROR "Error while downloading file [${rc}]: ${msg}")
        endif()
        if(ARG_RESULT_VARIABLE)
            set("${ARG_RESULT_VARIABLE}" FALSE PARENT_SCOPE)
        endif()
    else()
        file(RENAME "${tmp}" "${dest}")
        if(ARG_RESULT_VARIABLE)
            set("${ARG_RESULT_VARIABLE}" TRUE PARENT_SCOPE)
        endif()
    endif()
endfunction()

foreach(fname IN ITEMS auto.cmake)
    get_filename_component(_pf_dest "${_PF_DIR}/${fname}" ABSOLUTE)
    _pf_download("${PF_URL}/${fname}" "${_pf_dest}")
    include("${_pf_dest}")
endforeach()
