# Maintainer: Daniel Bermond <dbermond@archlinux.org>

pkgname=libvpl
pkgver=2.11.0
pkgrel=1
pkgdesc='Intel Video Processing Library'
arch=('x86_64' 'aarch64')
url='https://intel.github.io/libvpl/'
license=('MIT')
depends=('gcc-libs')
optdepends=('vpl-gpu-rt: runtime implementation for Tiger Lake and newer GPUs')
optdepends_x86_64=('intel-media-sdk: runtime implementation for legacy Intel GPUs')
makedepends=('cmake')
provides=('onevpl' 'libvpl.so')
conflicts=('onevpl')
replaces=('onevpl')
options=('!emptydirs')
source=("https://github.com/intel/libvpl/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha256sums=('3e322ba6b3593da03e1cfdb8062f9f1545f6d9b1de39e36876de5934b26737d2')

build() {
    export CFLAGS+=' -DNDEBUG'
    export CXXFLAGS+=' -DNDEBUG'
    cmake -B build -S "libvpl-${pkgver}" \
        -G 'Unix Makefiles' \
        -DCMAKE_BUILD_TYPE:STRING='None' \
        -DCMAKE_INSTALL_PREFIX:PATH='/usr' \
        -DCMAKE_INSTALL_SYSCONFDIR:PATH='/etc' \
        -DBUILD_EXAMPLES:BOOL='OFF' \
        -DBUILD_TESTS:BOOL='ON' \
        -DVPL_INSTALL_LICENSEDIR:PATH="share/licenses/${pkgname}" \
        -Wno-dev
    cmake --build build
}

check() {
    ctest --test-dir build --output-on-failure
}

package() {
    DESTDIR="$pkgdir" cmake --install build
    rm -r "${pkgdir}/usr/share/vpl/examples"
    rm "${pkgdir}/"{etc/vpl/vars.sh,usr/include/vpl/preview/{,legacy/}README.txt}
}
