set(PXR_PREFIX pxr/imaging)
set(PXR_PACKAGE hioAvif)

pxr_plugin(hioAvif
    LIBRARIES
        ar
        arch
        gf
        hio
        tf

    PRIVATE_HEADERS
        aom/aom.h
        aom/aom_codec.h
        aom/aom_decoder.h
        aom/aom_encoder.h
        aom/aom_frame_buffer.h
        aom/aom_image.h
        aom/aom_integer.h
        aom/aomdx.h
        aom/aom_external_partition.h
        aom/internal/aom_codec_internal.h
        aom/internal/aom_image_internal.h
        aom_dsp/aom_dsp_common.h
        aom_dsp/aom_filter.h
        aom_dsp/binary_codes_reader.h
        aom_dsp/bitreader.h
        aom_dsp/bitreader_buffer.h
        aom_dsp/blend.h
        aom_dsp/entcode.h
        aom_dsp/entdec.h
        aom_dsp/flow_estimation/corner_detect.h
        aom_dsp/flow_estimation/flow_estimation.h
        aom_dsp/grain_params.h
        aom_dsp/grain_table.h
        aom_dsp/intrapred_common.h
        aom_dsp/odintrin.h
        aom_dsp/prob.h
        aom_dsp/pyramid.h
        aom_dsp/recenter.h
        aom_dsp/txfm_common.h
        aom_mem/aom_mem.h
        aom_mem/include/aom_mem_intrnl.h
        aom_ports/aom_once.h
        aom_ports/aom_timer.h
        aom_ports/bitops.h
        aom_ports/mem.h
        aom_ports/mem_ops.h
        aom_ports/mem_ops_aligned.h
        aom_ports/sanitizer.h
        aom_scale/yv12config.h
        aom_util/aom_thread.h
        aom_util/aom_pthread.h
        av1/av1_iface_common.h
        av1/common/alloccommon.h
        av1/common/av1_common_int.h
        av1/common/av1_inv_txfm1d.h
        av1/common/av1_inv_txfm1d_cfg.h
        av1/common/av1_loopfilter.h
        av1/common/av1_txfm.h
        av1/common/blockd.h
        av1/common/cdef.h
        av1/common/cdef_block.h
        av1/common/cfl.h
        av1/common/common.h
        av1/common/common_data.h
        av1/common/convolve.h
        av1/common/entropy.h
        av1/common/entropymode.h
        av1/common/entropymv.h
        av1/common/enums.h
        av1/common/filter.h
        av1/common/frame_buffers.h
        av1/common/idct.h
        av1/common/mv.h
        av1/common/mvref_common.h
        av1/common/obmc.h
        av1/common/obu_util.h
        av1/common/pred_common.h
        av1/common/quant_common.h
        av1/common/reconinter.h
        av1/common/reconinter_template.inc
        av1/common/reconintra.h
        av1/common/resize.h
        av1/common/restoration.h
        av1/common/scale.h
        av1/common/scan.h
        av1/common/seg_common.h
        av1/common/thread_common.h
        av1/common/tile_common.h
        av1/common/timing.h
        av1/common/token_cdfs.h
        av1/common/txb_common.h
        av1/common/warped_motion.h
        av1/decoder/decodeframe.h
        av1/decoder/decodemv.h
        av1/decoder/decoder.h
        av1/decoder/decodetxb.h
        av1/decoder/detokenize.h
        av1/decoder/dthread.h
        av1/decoder/grain_synthesis.h
        av1/decoder/obu.h
        common/args_helper.h
        AVIF/src/avif/avif.h
        AVIF/src/avif/internal.h
        AVIF/src/src-libyuv/libyuv/basic_types.h
        AVIF/src/src-libyuv/libyuv.h
        AVIF/src/src-libyuv/libyuv/planar_functions.h
        AVIF/src/src-libyuv/libyuv/row.h
        AVIF/src/src-libyuv/libyuv/scale.h
        AVIF/src/src-libyuv/libyuv/scale_row.h
        AVIF/src/src-libyuv/libyuv/version.h

    CPPFILES
        aom/src/aom_codec.c
        aom/src/aom_decoder.c
        aom/src/aom_image.c
        aom/src/aom_integer.c
        aom_dsp/aom_convolve.c
        aom_dsp/aom_dsp_rtcd.c
        aom_dsp/binary_codes_reader.c
        aom_dsp/bitreader.c
        aom_dsp/bitreader_buffer.c
        aom_dsp/blend_a64_hmask.c
        aom_dsp/blend_a64_mask.c
        aom_dsp/blend_a64_vmask.c
        aom_dsp/entcode.c
        aom_dsp/entdec.c
        aom_dsp/intrapred.c
        aom_dsp/loopfilter.c
        aom_dsp/odintrin.c
        aom_dsp/pyramid.c
        aom_mem/aom_mem.c
        aom_scale/aom_scale_rtcd.c
        aom_scale/generic/yv12config.c
        aom_scale/generic/yv12extend.c
        aom_util/aom_thread.c
        av1/av1_dx_iface.c
        av1/common/alloccommon.c
        av1/common/av1_inv_txfm1d.c
        av1/common/av1_inv_txfm2d.c
        av1/common/av1_loopfilter.c
        av1/common/av1_rtcd.c
        av1/common/av1_txfm.c
        av1/common/blockd.c
        av1/common/cdef.c
        av1/common/cdef_block.c
        av1/common/cfl.c
        av1/common/common_data.c
        av1/common/convolve.c
        av1/common/entropy.c
        av1/common/entropymode.c
        av1/common/entropymv.c
        av1/common/frame_buffers.c
        av1/common/idct.c
        av1/common/mvref_common.c
        av1/common/obu_util.c
        av1/common/pred_common.c
        av1/common/quant_common.c
        av1/common/reconinter.c
        av1/common/reconintra.c
        av1/common/resize.c
        av1/common/restoration.c
        av1/common/scale.c
        av1/common/scan.c
        av1/common/seg_common.c
        av1/common/thread_common.c
        av1/common/tile_common.c
        av1/common/timing.c
        av1/common/txb_common.c
        av1/common/warped_motion.c
        av1/decoder/decodeframe.c
        av1/decoder/decodemv.c
        av1/decoder/decoder.c
        av1/decoder/decodetxb.c
        av1/decoder/detokenize.c
        av1/decoder/grain_synthesis.c
        av1/decoder/obu.c
        AVIF/src/alpha.c
        AVIF/src/avif.c
        AVIF/src/codec_aom.c
        AVIF/src/colr.c
        AVIF/src/diag.c
        AVIF/src/exif.c
        AVIF/src/io.c
        AVIF/src/mem.c
        AVIF/src/avif_obu.c
        AVIF/src/rawdata.c
        AVIF/src/read.c
        AVIF/src/reformat.c
        AVIF/src/reformat_libsharpyuv.c
        AVIF/src/reformat_libyuv.c
        AVIF/src/avif-scale.c
        AVIF/src/stream.c
        AVIF/src/utils.c
        AVIF/src/write.c
        AVIF/src/src-libyuv/planar_functions.c
        AVIF/src/src-libyuv/row_common.c
        AVIF/src/src-libyuv/yuv_scale.c
        AVIF/src/src-libyuv/scale_any.c
        AVIF/src/src-libyuv/scale_common.c
        AVIFImage.cpp

    RESOURCE_FILES
        plugInfo.json
)

if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
    if (TARGET hioAvif)
        # Hide symbols and inlines in the C code
        target_compile_options(hioAvif PRIVATE
             $<$<COMPILE_LANGUAGE:C>:-fvisibility=hidden>)
    endif()
endif()

pxr_install_test_dir(
    SRC testenv/testHioAvif
    DEST testHioAvif
)

pxr_build_test(testHioAvif
    LIBRARIES
        hio
    CPPFILES
        testenv/testHioAvif.cpp
)

pxr_register_test(testHioAvif
    COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHioAvif"
    EXPECTED_RETURN_CODE 0
)
