GetBinaryDeps.cmake (1612B)
1 # This is similar to the build recipes, but instead downloads a third party 2 # binary and installs it under the DEPS_PREFIX. 3 # The INSTALL_COMMAND is executed in the folder where downloaded files are 4 # extracted and the ${DEPS_INSTALL_DIR} holds the path to the third-party 5 # install root. 6 function(GetBinaryDep) 7 cmake_parse_arguments(_gettool 8 "" 9 "TARGET" 10 "INSTALL_COMMAND" 11 ${ARGN}) 12 13 string(TOUPPER "${_gettool_TARGET}_URL" URL_VARNAME) 14 string(TOUPPER "${_gettool_TARGET}_SHA256" HASH_VARNAME) 15 set(URL ${${URL_VARNAME}}) 16 set(HASH ${${HASH_VARNAME}}) 17 18 ExternalProject_Add(${_gettool_TARGET} 19 URL ${URL} 20 URL_HASH SHA256=${HASH} 21 DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR} 22 CONFIGURE_COMMAND "" 23 BUILD_IN_SOURCE 1 24 BUILD_COMMAND "" 25 INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_BIN_DIR} 26 COMMAND "${_gettool_INSTALL_COMMAND}" 27 DOWNLOAD_NO_PROGRESS TRUE) 28 endfunction() 29 30 # Download executable and move it to DEPS_BIN_DIR 31 function(GetExecutable) 32 cmake_parse_arguments(ARG 33 "" 34 "TARGET" 35 "" 36 ${ARGN}) 37 38 string(TOUPPER "${ARG_TARGET}_URL" URL_VARNAME) 39 string(TOUPPER "${ARG_TARGET}_SHA256" HASH_VARNAME) 40 set(URL ${${URL_VARNAME}}) 41 set(HASH ${${HASH_VARNAME}}) 42 43 ExternalProject_Add(${ARG_TARGET} 44 URL ${URL} 45 URL_HASH SHA256=${HASH} 46 DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR} 47 DOWNLOAD_NO_EXTRACT TRUE 48 CONFIGURE_COMMAND "" 49 BUILD_COMMAND "" 50 INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_BIN_DIR} 51 COMMAND ${CMAKE_COMMAND} -E copy <DOWNLOADED_FILE> ${DEPS_BIN_DIR} 52 DOWNLOAD_NO_PROGRESS TRUE) 53 endfunction()