GetBinaryDeps.cmake 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. string(TOUPPER "${_gettool_TARGET}_URL" URL_VARNAME)
  13. string(TOUPPER "${_gettool_TARGET}_SHA256" HASH_VARNAME)
  14. set(URL ${${URL_VARNAME}})
  15. set(HASH ${${HASH_VARNAME}})
  16. ExternalProject_Add(${_gettool_TARGET}
  17. URL ${URL}
  18. URL_HASH SHA256=${HASH}
  19. DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}
  20. CONFIGURE_COMMAND ""
  21. BUILD_IN_SOURCE 1
  22. BUILD_COMMAND ""
  23. INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_BIN_DIR}
  24. COMMAND "${_gettool_INSTALL_COMMAND}"
  25. DOWNLOAD_NO_PROGRESS TRUE)
  26. endfunction()
  27. # Download executable and move it to DEPS_BIN_DIR
  28. function(GetExecutable)
  29. cmake_parse_arguments(ARG
  30. ""
  31. "TARGET"
  32. ""
  33. ${ARGN})
  34. string(TOUPPER "${ARG_TARGET}_URL" URL_VARNAME)
  35. string(TOUPPER "${ARG_TARGET}_SHA256" HASH_VARNAME)
  36. set(URL ${${URL_VARNAME}})
  37. set(HASH ${${HASH_VARNAME}})
  38. ExternalProject_Add(${ARG_TARGET}
  39. URL ${URL}
  40. URL_HASH SHA256=${HASH}
  41. DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}
  42. DOWNLOAD_NO_EXTRACT TRUE
  43. CONFIGURE_COMMAND ""
  44. BUILD_COMMAND ""
  45. INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_BIN_DIR}
  46. COMMAND ${CMAKE_COMMAND} -E copy <DOWNLOADED_FILE> ${DEPS_BIN_DIR}
  47. DOWNLOAD_NO_PROGRESS TRUE)
  48. endfunction()