function(download_external_files url filename hash)
  message(STATUS "Check file: ${filename}")
  set(filehash "checksum sha256")
  if(EXISTS ${filename})
    file(SHA256 ${filename} filehash)
    message(STATUS "SHA256: ${filehash}")
  endif()
  if(NOT EXISTS ${filename} OR NOT (${hash} STREQUAL ${filehash}))
    message(STATUS "Download from ${url}")
    file(DOWNLOAD ${url} ${filename} TIMEOUT 180 EXPECTED_HASH SHA256=${hash} TLS_VERIFY ON)
  endif()
endfunction(download_external_files)