# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: Gaetan Bisson <bisson@archlinux.org>
# Contributor: Tobias Kieslich <tobias@archlinux.org>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>
# Contributor: Dominik Ryba <domryba@post.pl>

pkgname=hugin
pkgver=2020.0.0
pkgrel=9
pkgdesc="Panorama photo stitcher"
arch=(x86_64)
url="http://hugin.sourceforge.net/"
license=(GPL)
depends=(wxgtk3 boost-libs libtiff libpano13 libjpeg libpng openexr vigra
         exiv2 glew sqlite lcms2 lapack fftw glu libxi libxmu python
         lensfun make enblend-enfuse)
makedepends=(cmake boost tclap mesa swig)
optdepends=('perl-image-exiftool: GPano tags support'
            'dcraw: RAW import using dcraw'
            'darktable: RAW import using darktable'
            'rawtherapee: RAW import using rawtherapee')
source=(https://downloads.sourceforge.net/${pkgname}/${pkgname}-${pkgver/r/_r}.tar.bz2
        hugin-openexr3.patch)
sha256sums=('283e7601259a7914cb075333424410928a439dc5f84216f33e2fe55501fbcacb'
            '8ae66f1d2da9368e0089a91ac96a3efb702f703affdcb368830c6de49aca6ce1')

prepare() {
  patch -d $pkgname-$pkgver -p1 < hugin-openexr3.patch # Fix build with OpenEXR 3
  rm $pkgname-$pkgver/CMakeModules/FindZLIB.cmake # Doesn't define the ZLIB::ZLIB target needed by OpenEXR 3
}

build() {
  cmake -B build -S ${pkgname}-${pkgver} \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DENABLE_LAPACK=yes \
    -DBUILD_HSI=ON \
    -DUSE_GDKBACKEND_X11=ON \
    -DwxWidgets_CONFIG_EXECUTABLE=/usr/bin/wx-config-gtk3
  make -C build
}

package() {
  make -C build DESTDIR="${pkgdir}" install
}
