DownloadCEF.cmake 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
  2. # reserved. Use of this source code is governed by a BSD-style license that
  3. # can be found in the LICENSE file.
  4. # Download the CEF binary distribution for |platform| and |version| to
  5. # |download_dir|. The |CEF_ROOT| variable will be set in global scope pointing
  6. # to the extracted location.
  7. # Visit https://cef-builds.spotifycdn.com/index.html for the list of
  8. # supported platforms and versions.
  9. function(DownloadCEF platform version download_dir)
  10. # Specify the binary distribution type and download directory.
  11. set(CEF_DISTRIBUTION "cef_binary_${version}_${platform}")
  12. set(CEF_DOWNLOAD_DIR "${download_dir}")
  13. # The location where we expect the extracted binary distribution.
  14. set(CEF_ROOT "${CEF_DOWNLOAD_DIR}/${CEF_DISTRIBUTION}" CACHE INTERNAL "CEF_ROOT")
  15. # Download and/or extract the binary distribution if necessary.
  16. if(NOT IS_DIRECTORY "${CEF_ROOT}")
  17. set(CEF_DOWNLOAD_FILENAME "${CEF_DISTRIBUTION}.tar.bz2")
  18. set(CEF_DOWNLOAD_PATH "${CEF_DOWNLOAD_DIR}/${CEF_DOWNLOAD_FILENAME}")
  19. if(NOT EXISTS "${CEF_DOWNLOAD_PATH}")
  20. set(CEF_DOWNLOAD_URL "https://cef-builds.spotifycdn.com/${CEF_DOWNLOAD_FILENAME}")
  21. string(REPLACE "+" "%2B" CEF_DOWNLOAD_URL_ESCAPED ${CEF_DOWNLOAD_URL})
  22. # Download the SHA1 hash for the binary distribution.
  23. message(STATUS "Downloading ${CEF_DOWNLOAD_PATH}.sha1 from ${CEF_DOWNLOAD_URL_ESCAPED}...")
  24. file(DOWNLOAD "${CEF_DOWNLOAD_URL_ESCAPED}.sha1" "${CEF_DOWNLOAD_PATH}.sha1")
  25. file(READ "${CEF_DOWNLOAD_PATH}.sha1" CEF_SHA1)
  26. # Download the binary distribution and verify the hash.
  27. message(STATUS "Downloading ${CEF_DOWNLOAD_PATH}...")
  28. file(
  29. DOWNLOAD "${CEF_DOWNLOAD_URL_ESCAPED}" "${CEF_DOWNLOAD_PATH}"
  30. EXPECTED_HASH SHA1=${CEF_SHA1}
  31. SHOW_PROGRESS
  32. )
  33. endif()
  34. # Extract the binary distribution.
  35. message(STATUS "Extracting ${CEF_DOWNLOAD_PATH}...")
  36. execute_process(
  37. COMMAND ${CMAKE_COMMAND} -E tar xzf "${CEF_DOWNLOAD_DIR}/${CEF_DOWNLOAD_FILENAME}"
  38. WORKING_DIRECTORY ${CEF_DOWNLOAD_DIR}
  39. )
  40. endif()
  41. endfunction()