DownloadExternals.cmake 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # SPDX-FileCopyrightText: 2017 yuzu Emulator Project
  2. # SPDX-License-Identifier: GPL-2.0-or-later
  3. # This function downloads a binary library package from our external repo.
  4. # Params:
  5. # remote_path: path to the file to download, relative to the remote repository root
  6. # prefix_var: name of a variable which will be set with the path to the extracted contents
  7. function(download_bundled_external remote_path lib_name prefix_var)
  8. set(package_base_url "https://github.com/yuzu-emu/")
  9. set(package_repo "no_platform")
  10. set(package_extension "no_platform")
  11. if (WIN32)
  12. set(package_repo "ext-windows-bin/raw/master/")
  13. set(package_extension ".7z")
  14. elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
  15. set(package_repo "ext-linux-bin/raw/main/")
  16. set(package_extension ".tar.xz")
  17. elseif (ANDROID)
  18. set(package_base_url "https://gitlab.com/tertius42/")
  19. set(package_repo "ext-android-bin/-/raw/main/")
  20. set(package_extension ".tar.xz") #ffmpeg/ffmpeg-android-20221229.tar.xz")
  21. else()
  22. message(FATAL_ERROR "No package available for this platform")
  23. endif()
  24. set(package_url "${package_base_url}${package_repo}")
  25. set(prefix "${CMAKE_BINARY_DIR}/externals/${lib_name}")
  26. if (NOT EXISTS "${prefix}")
  27. message(STATUS "Downloading binaries for ${lib_name}...")
  28. file(DOWNLOAD
  29. ${package_url}${remote_path}${lib_name}${package_extension}
  30. "${CMAKE_BINARY_DIR}/externals/${lib_name}${package_extension}" SHOW_PROGRESS)
  31. execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${CMAKE_BINARY_DIR}/externals/${lib_name}${package_extension}"
  32. WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/externals")
  33. endif()
  34. message(STATUS "Using bundled binaries at ${prefix}")
  35. set(${prefix_var} "${prefix}" PARENT_SCOPE)
  36. endfunction()