pkgname=libjxl
pkgver=0.11.1
pkgdesc='JPEG XL image format reference implementation'
arch=('x86_64')
homepage='https://jpeg.org/jpegxl/'
license=('BSD-3-Clause')
makedepends=(
  'brotli'
  'cmake'
  'highway'
  'libpng'
  'glib'
  'gdk-pixbuf'
  'lcms'
  'shared-mime-info'
)
sources=("${pkgname}-${pkgver}.tar.gz")
urls=("https://github.com/libjxl/libjxl/archive/refs/tags/v${pkgver}.tar.gz")
md5sums=("8f26fc954c2d9cb377544a5f029182ef")

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
}

src_build() {
  local cmake_args=(
    -D CMAKE_INSTALL_PREFIX=/usr
    -D CMAKE_BUILD_TYPE=Release
    -D JPEGXL_ENABLE_BENCHMARK=OFF
    -D JPEGXL_ENABLE_COVERAGE=OFF
    -D JPEGXL_ENABLE_FUZZERS=OFF
    -D JPEGXL_ENABLE_SJPEG=OFF
    -D JPEGXL_WARNINGS_AS_ERRORS=OFF
    -D CMAKE_DISABLE_FIND_PACKAGE_GIF=yes
    -D CMAKE_DISABLE_FIND_PACKAGE_JPEG=yes
    -D CMAKE_DISABLE_FIND_PACKAGE_PNG=no
    -D JPEGXL_ENABLE_SKCMS=OFF
    -D JPEGXL_ENABLE_VIEWERS=OFF
    -D JPEGXL_FORCE_SYSTEM_BROTLI=ON
    -D JPEGXL_FORCE_SYSTEM_GTEST=ON
    -D JPEGXL_FORCE_SYSTEM_HWY=ON
    -D JPEGXL_FORCE_SYSTEM_LCMS2=ON
    -D JPEGXL_ENABLE_DOXYGEN=OFF
    -D JPEGXL_ENABLE_MANPAGES=OFF
    -D JPEGXL_ENABLE_JNI=OFF
    -D JPEGXL_ENABLE_JPEGLI=OFF
    -D JPEGXL_ENABLE_JPEGLI_LIBJPEG=OFF
    -D JPEGXL_ENABLE_TCMALLOC=OFF
    -D JPEGXL_ENABLE_EXAMPLES=OFF
    -D BUILD_TESTING=OFF

    -D JPEGXL_ENABLE_TOOLS=ON
    -D JPEGXL_ENABLE_OPENEXR=OFF
    -D JPEGXL_ENABLE_PLUGINS=ON
    -D JPEGXL_ENABLE_PLUGIN_GDKPIXBUF=ON
    -D JPEGXL_ENABLE_PLUGIN_GIMP210=OFF
    -D JPEGXL_ENABLE_PLUGIN_MIME=OFF
  )
  cmake -B build "${cmake_args[@]}"
  cmake --build build
}

src_install() {
  DESTDIR="$pkgdir" cmake --install build
  find "${pkgdir}" -name '*.a' -delete
  install -D -m644 {LICENSE,PATENTS} -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim:ft=sh syn=sh et sw=2:
