download_file(): avoid copying files if the correct file already exists

develop
lethosor 2017-03-18 00:31:15 -04:00
parent 38702febf7
commit 50a022d81b
1 changed files with 9 additions and 9 deletions

@ -25,16 +25,16 @@ function(download_file URL DEST EXPECTED_MD5)
get_filename_component(FILENAME "${URL}" NAME)
file_md5_if_exists("${DEST}" CUR_MD5)
search_downloads(${EXPECTED_MD5} DLPATH)
if(NOT("${DLPATH}" STREQUAL ""))
message("* Copying ${FILENAME} from ${DLPATH}")
execute_process(COMMAND "${CMAKE_COMMAND}" -E copy
"${DLPATH}"
"${DEST}")
return()
endif()
if(NOT "${EXPECTED_MD5}" STREQUAL "${CUR_MD5}")
search_downloads(${EXPECTED_MD5} DLPATH)
if(NOT("${DLPATH}" STREQUAL ""))
message("* Copying ${FILENAME} from ${DLPATH}")
execute_process(COMMAND "${CMAKE_COMMAND}" -E copy
"${DLPATH}"
"${DEST}")
return()
endif()
message("* Downloading ${FILENAME}")
file(DOWNLOAD "${URL}" "${DEST}" EXPECTED_MD5 "${EXPECTED_MD5}" SHOW_PROGRESS)
endif()