# Maintainer: Yichao Yu <yyc1992@gmail.com>

pkgbase=qt-heic-image-plugin-git
pkgname=(qt5-heic-image-plugin-git qt6-heic-image-plugin-git)
pkgver=0.7.1
pkgrel=1
pkgdesc='Qt plug-in to allow Qt and KDE based applications to read/write HEIF/HEIC images.'
arch=(i686 x86_64 armv7h aarch64)
url="https://github.com/novomesk/qt-heic-image-plugin"
license=('GPL')
depends=(libheif)
makedepends=(cmake git extra-cmake-modules qt5-base qt6-base)
options=('debug')
source=("git+https://github.com/novomesk/qt-heic-image-plugin")
md5sums=('SKIP')

pkgver() {
  cd qt-heic-image-plugin

  git describe --tags | sed -e 's/^v//' -e 's/-/.0./g'
}

build() {
  cmake -B build-5 -S qt-heic-image-plugin \
        -DQT_MAJOR_VERSION=5 \
        -DCMAKE_BUILD_TYPE=RelWithDebInfo \
        -DCMAKE_INSTALL_PREFIX=/usr
  make -C build-5

  cmake -B build-6 -S qt-heic-image-plugin \
        -DQT_MAJOR_VERSION=6 \
        -DCMAKE_BUILD_TYPE=RelWithDebInfo \
        -DCMAKE_INSTALL_PREFIX=/usr
  make -C build-6
}

package_qt5-heic-image-plugin-git() {
  provides=(qt-heic-image-plugin qt5-heic-image-plugin)
  conflicts=(qt-heic-image-plugin qt5-heic-image-plugin)
  replaces=(qt-heic-image-plugin-git)

  make -C build-5 DESTDIR="$pkgdir/" install
}

package_qt6-heic-image-plugin-git() {
  provides=(qt6-heic-image-plugin)
  conflicts=(qt6-heic-image-plugin)

  make -C build-6 DESTDIR="$pkgdir/" install
}
