1# DownloadLcbDeb(url location)
2MACRO(DOWNLOAD_LCB_DEP url dest)
3    FIND_PROGRAM(WGET wget)
4    FIND_PROGRAM(CURL curl)
5    IF(CURL)
6        EXECUTE_PROCESS(COMMAND "${CURL}" "${url}" -L -o "${dest}" RESULT_VARIABLE DLRC)
7    ELSEIF(WGET)
8        EXECUTE_PROCESS(COMMAND "${WGET}" "${url}" -O "${dest}" RESULT_VARIABLE DLRC)
9    ENDIF()
10    IF(NOT DLRC EQUAL 0)
11      MESSAGE(WARNING "Using buggy built-in CMake downloader")
12      FILE(DOWNLOAD ${url} ${dest} INACTIVITY_TIMEOUT 30 SHOW_PROGRESS STATUS RET)
13      LIST(GET RET 0 DLRC)
14    ENDIF()
15    IF(NOT DLRC EQUAL 0)
16        MESSAGE(FATAL_ERROR "Failed to download ${url}")
17    ENDIF()
18ENDMACRO()
19