include(Utils)
include(FetchContent)

message("-- Building TinyUSDZ")

if(NOT DEFINED TINYUSDZ_REPO)
    set(TINYUSDZ_REPO https://github.com/syoyo/tinyusdz.git)
endif ()

FetchContent_Declare(
    tinyusdz
    GIT_REPOSITORY ${TINYUSDZ_REPO}
    GIT_TAG        v0.8.0rc8
    GIT_SHALLOW    TRUE
    CMAKE_ARGS
        -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/INSTALL
        -DCMAKE_BUILD_TYPE:STRING=Release
        -DTINYUSDZ_BUILD_TESTS:BOOL=OFF
        -DTINYUSDZ_BUILD_EXAMPLES:BOOL=OFF
)

set(TINYUSDZ_NO_WERROR ON)
set(TINYUSDZ_BUILD_TESTS OFF)
set(TINYUSDZ_BUILD_BENCHMARKS OFF)
set(TINYUSDZ_BUILD_EXAMPLES OFF)
set(TINYUSDZ_WITH_BUILTIN_IMAGE_LOADER OFF)

FetchContent_MakeAvailable(tinyusdz)

function (LinkTinyUSDZ TARGET)
    target_include_directories(${TARGET} PRIVATE ${tinyusdz_SOURCE_DIR}/src)
    target_link_libraries(${TARGET} PRIVATE tinyusdz_static)
endfunction ()
