Skip to content
Snippets Groups Projects
download.cmake 5.46 KiB
Newer Older
  • Learn to ignore specific revisions
  • Milan Jaros's avatar
    Milan Jaros committed
    # SPDX-License-Identifier: GPL-2.0-or-later
    
    ## Update and uncomment this in the release branch
    
    Milan Jaros's avatar
    Milan Jaros committed
    set(BLENDER_VERSION 3.6)
    
    Milan Jaros's avatar
    Milan Jaros committed
    
    function(download_source dep)
      set(TARGET_FILE ${${dep}_FILE})
      set(TARGET_HASH_TYPE ${${dep}_HASH_TYPE})
      set(TARGET_HASH ${${dep}_HASH})
      if(PACKAGE_USE_UPSTREAM_SOURCES)
        set(TARGET_URI  ${${dep}_URI})
      elseif(BLENDER_VERSION)
    
    Milan Jaros's avatar
    Milan Jaros committed
        set(TARGET_URI https://svn.blender.org/svnroot/bf-blender/tags/blender-${BLENDER_VERSION}-release/lib/packages/${TARGET_FILE})
    
    Milan Jaros's avatar
    Milan Jaros committed
      else()
    
    Milan Jaros's avatar
    Milan Jaros committed
        set(TARGET_URI https://svn.blender.org/svnroot/bf-blender/trunk/lib/packages/${TARGET_FILE})
    
    Milan Jaros's avatar
    Milan Jaros committed
      endif()
      # Validate all required variables are set and give an explicit error message
      # rather than CMake erroring out later on with a more ambigious error.
    
    Milan Jaros's avatar
    Milan Jaros committed
      if(NOT DEFINED TARGET_FILE)
    
    Milan Jaros's avatar
    Milan Jaros committed
        message(FATAL_ERROR "${dep}_FILE variable not set")
      endif()
    
    Milan Jaros's avatar
    Milan Jaros committed
      if(NOT DEFINED TARGET_HASH)
    
    Milan Jaros's avatar
    Milan Jaros committed
        message(FATAL_ERROR "${dep}_HASH variable not set")
      endif()
    
    Milan Jaros's avatar
    Milan Jaros committed
      if(NOT DEFINED TARGET_HASH_TYPE)
    
    Milan Jaros's avatar
    Milan Jaros committed
        message(FATAL_ERROR "${dep}_HASH_TYPE variable not set")
      endif()
    
    Milan Jaros's avatar
    Milan Jaros committed
      if(NOT DEFINED TARGET_URI)
    
    Milan Jaros's avatar
    Milan Jaros committed
        message(FATAL_ERROR "${dep}_URI variable not set")
      endif()
      set(TARGET_FILE ${PACKAGE_DIR}/${TARGET_FILE})
      message("Checking source : ${dep} (${TARGET_FILE})")
      if(NOT EXISTS ${TARGET_FILE})
        message("Checking source : ${dep} - source not found downloading from ${TARGET_URI}")
    
    Milan Jaros's avatar
    Milan Jaros committed
        file(
          DOWNLOAD ${TARGET_URI} ${TARGET_FILE}
          TIMEOUT 1800  # seconds
          EXPECTED_HASH ${TARGET_HASH_TYPE}=${TARGET_HASH}
          TLS_VERIFY ON
          SHOW_PROGRESS
        )
    
    Milan Jaros's avatar
    Milan Jaros committed
      endif()
      if(EXISTS ${TARGET_FILE})
        # Sometimes the download fails, but that is not a
        # fail condition for "file(DOWNLOAD" it will warn about
    
    Milan Jaros's avatar
    Milan Jaros committed
        # a CRC mismatch and just carry on, we need to explicitly
    
    Milan Jaros's avatar
    Milan Jaros committed
        # catch this and remove the bogus 0 byte file so we can
        # retry without having to go find the file and manually
        # delete it.
    
    Milan Jaros's avatar
    Milan Jaros committed
        file(SIZE ${TARGET_FILE} TARGET_SIZE)
    
    Milan Jaros's avatar
    Milan Jaros committed
        if(${TARGET_SIZE} EQUAL 0)
          file(REMOVE ${TARGET_FILE})
          message(FATAL_ERROR "for ${TARGET_FILE} file size 0, download likely failed, deleted...")
        endif()
    
        # If we are using sources from the blender repo also
        # validate that the hashes match, this takes a
        # little more time, but protects us when we are
        # building a release package and one of the packages
        # is missing or incorrect.
        #
        # For regular platform maintenaince this is not needed
        # since the actual build of the dep will notify the
        # platform maintainer if there is a problem with the
        # source package and refuse to build.
        if(NOT PACKAGE_USE_UPSTREAM_SOURCES OR FORCE_CHECK_HASH)
          file(${TARGET_HASH_TYPE} ${TARGET_FILE} LOCAL_HASH)
          if(NOT ${TARGET_HASH} STREQUAL ${LOCAL_HASH})
            message(FATAL_ERROR "${TARGET_FILE} ${TARGET_HASH_TYPE} mismatch\nExpected\t: ${TARGET_HASH}\nActual\t: ${LOCAL_HASH}")
          endif()
        endif()
      endif()
    endfunction(download_source)
    
    download_source(ZLIB)
    download_source(OPENAL)
    download_source(PNG)
    download_source(JPEG)
    download_source(BOOST)
    download_source(BLOSC)
    download_source(PTHREADS)
    download_source(OPENEXR)
    download_source(FREETYPE)
    
    Milan Jaros's avatar
    Milan Jaros committed
    download_source(EPOXY)
    
    Milan Jaros's avatar
    Milan Jaros committed
    download_source(FREEGLUT)
    download_source(ALEMBIC)
    download_source(OPENSUBDIV)
    download_source(SDL)
    download_source(OPENCOLLADA)
    download_source(OPENCOLORIO)
    
    Milan Jaros's avatar
    Milan Jaros committed
    download_source(MINIZIPNG)
    
    Milan Jaros's avatar
    Milan Jaros committed
    download_source(LLVM)
    download_source(OPENMP)
    download_source(OPENIMAGEIO)
    download_source(TIFF)
    download_source(OSL)
    download_source(PYTHON)
    download_source(TBB)
    download_source(OPENVDB)
    download_source(NUMPY)
    download_source(LAME)
    download_source(OGG)
    download_source(VORBIS)
    download_source(THEORA)
    download_source(FLAC)
    download_source(VPX)
    download_source(OPUS)
    download_source(X264)
    download_source(XVIDCORE)
    download_source(OPENJPEG)
    download_source(FFMPEG)
    download_source(FFTW)
    download_source(ICONV)
    download_source(SNDFILE)
    download_source(WEBP)
    download_source(SPNAV)
    download_source(JEMALLOC)
    download_source(XML2)
    download_source(YAMLCPP)
    download_source(EXPAT)
    download_source(PUGIXML)
    download_source(FLEXBISON)
    download_source(BZIP2)
    download_source(FFI)
    download_source(LZMA)
    download_source(SSL)
    download_source(SQLITE)
    download_source(EMBREE)
    download_source(USD)
    
    Milan Jaros's avatar
    Milan Jaros committed
    download_source(MATERIALX)
    
    Milan Jaros's avatar
    Milan Jaros committed
    download_source(OIDN)
    download_source(LIBGLU)
    download_source(MESA)
    download_source(NASM)
    download_source(XR_OPENXR_SDK)
    download_source(WL_PROTOCOLS)
    
    Milan Jaros's avatar
    Milan Jaros committed
    download_source(WAYLAND)
    download_source(WAYLAND_LIBDECOR)
    
    Milan Jaros's avatar
    Milan Jaros committed
    download_source(ISPC)
    download_source(GMP)
    download_source(POTRACE)
    download_source(HARU)
    download_source(ZSTD)
    
    Milan Jaros's avatar
    Milan Jaros committed
    download_source(SSE2NEON)
    
    Milan Jaros's avatar
    Milan Jaros committed
    download_source(FLEX)
    download_source(BROTLI)
    download_source(FMT)
    download_source(ROBINMAP)
    download_source(IMATH)
    download_source(PYSTRING)
    
    Milan Jaros's avatar
    Milan Jaros committed
    download_source(OPENPGL)
    
    Milan Jaros's avatar
    Milan Jaros committed
    download_source(LEVEL_ZERO)
    download_source(DPCPP)
    download_source(VCINTRINSICS)
    download_source(OPENCLHEADERS)
    download_source(ICDLOADER)
    download_source(MP11)
    download_source(SPIRV_HEADERS)
    
    Milan Jaros's avatar
    Milan Jaros committed
    download_source(UNIFIED_RUNTIME)
    
    Milan Jaros's avatar
    Milan Jaros committed
    download_source(IGC)
    download_source(IGC_LLVM)
    download_source(IGC_OPENCL_CLANG)
    download_source(IGC_VCINTRINSICS)
    download_source(IGC_SPIRV_HEADERS)
    download_source(IGC_SPIRV_TOOLS)
    download_source(IGC_SPIRV_TRANSLATOR)
    download_source(GMMLIB)
    download_source(OCLOC)
    download_source(AOM)
    
    Milan Jaros's avatar
    Milan Jaros committed
    download_source(FRIBIDI)
    download_source(HARFBUZZ)
    download_source(SHADERC)
    download_source(SHADERC_SPIRV_TOOLS)
    download_source(SHADERC_SPIRV_HEADERS)
    download_source(SHADERC_GLSLANG)
    download_source(VULKAN_HEADERS)
    download_source(VULKAN_LOADER)
    download_source(PYBIND11)