WSJT-X/CMake/download_kvasd.cmake
Bill Somerville cfec462e73 Don't try and generate an MD5 hash on a missing kvasd binary
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4831 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2014-12-17 00:55:00 +00:00

44 lines
1.4 KiB
CMake

#
# CMake script to fetch kvasd binary for the current platform
#
set (kvasd_NAME "${URL}/${SYSTEM_NAME}/kvasd${EXECUTABLE_SUFFIX}")
set (kvasd_target "contrib/kvasd${EXECUTABLE_SUFFIX}")
message (STATUS "downloading file: ${kvasd_NAME}.md5")
file (
DOWNLOAD "${kvasd_NAME}.md5" "${kvasd_target}.md5"
TIMEOUT 120
STATUS status
LOG log
SHOW_PROGRESS
)
list (GET status 0 rc)
if (rc)
message (WARNING "${status}")
message (FATAL_ERROR "${log}")
endif (rc)
file (READ "${kvasd_target}.md5" md5sum)
string (REGEX MATCH "[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]" md5sum "${md5sum}")
if (EXISTS "${kvasd_target}")
file (MD5 "${kvasd_target}" current_md5sum)
endif (EXISTS "${kvasd_target}")
if (NOT "${md5sum}" STREQUAL "${current_md5sum}")
message (STATUS "downloading file: ${kvasd_NAME}")
file (
DOWNLOAD ${kvasd_NAME} contrib/kvasd${EXECUTABLE_SUFFIX}
TIMEOUT 120
STATUS status
LOG log
SHOW_PROGRESS
EXPECTED_MD5 "${md5sum}"
)
list (GET status 0 rc)
if (rc)
message (WARNING "${status}")
message (FATAL_ERROR "${log}")
endif (rc)
else (NOT "${md5sum}" STREQUAL "${current_md5sum}")
message (STATUS "file: ${kvasd_NAME} up to date")
endif (NOT "${md5sum}" STREQUAL "${current_md5sum}")