GetBinaryDeps.cmake 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. "BUILD_IN_SOURCE"
  9. "TARGET"
  10. "INSTALL_COMMAND"
  11. ${ARGN})
  12. if(NOT _gettool_TARGET OR NOT _gettool_INSTALL_COMMAND)
  13. message(FATAL_ERROR "Must pass INSTALL_COMMAND and TARGET")
  14. endif()
  15. string(TOUPPER "${_gettool_TARGET}_URL" URL_VARNAME)
  16. string(TOUPPER "${_gettool_TARGET}_SHA256" HASH_VARNAME)
  17. set(URL ${${URL_VARNAME}})
  18. set(HASH ${${HASH_VARNAME}})
  19. if(NOT URL OR NOT HASH )
  20. message(FATAL_ERROR "${URL_VARNAME} and ${HASH_VARNAME} must be set")
  21. endif()
  22. ExternalProject_Add(${_gettool_TARGET}
  23. PREFIX ${DEPS_BUILD_DIR}
  24. URL ${URL}
  25. DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}
  26. DOWNLOAD_COMMAND ${CMAKE_COMMAND}
  27. -DPREFIX=${DEPS_BUILD_DIR}
  28. -DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}
  29. -DURL=${URL}
  30. -DEXPECTED_SHA256=${HASH}
  31. -DTARGET=${_gettool_TARGET}
  32. -DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR}
  33. -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
  34. CONFIGURE_COMMAND ""
  35. BUILD_IN_SOURCE 1
  36. BUILD_COMMAND ""
  37. INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/bin
  38. COMMAND "${_gettool_INSTALL_COMMAND}")
  39. list(APPEND THIRD_PARTY_DEPS ${__gettool_TARGET})
  40. endfunction()