include(FetchContent)

if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
    set(EMBREE_URL https://github.com/embree/embree/releases/download/v3.10.0/embree-3.10.0.x86_64.linux.tar.gz)
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
    set(EMBREE_URL https://github.com/embree/embree/releases/download/v3.10.0/embree-3.10.0.x86_64.macosx.zip)
elseif (${MSVC_VERSION} EQUAL 1800)
    set(EMBREE_URL https://github.com/embree/embree/releases/download/v3.10.0/embree-3.10.0.x64.vc12.windows.zip)
elseif (${MSVC_VERSION} GREATER_EQUAL 1900)
    set(EMBREE_URL https://github.com/embree/embree/releases/download/v3.10.0/embree-3.10.0.x64.vc14.windows.zip)
else ()
    message(WARNING "Cannot detect OS to download Embree")
endif ()
if (DEFINED EMBREE_URL)
    FetchContent_Declare(embree URL "${EMBREE_URL}")
    FetchContent_Populate(embree)
endif ()
find_package(embree 3.0 REQUIRED HINTS ${embree_SOURCE_DIR})
