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

pkgname=highway
pkgver=1.2.0
pkgrel=1
pkgdesc='A C++ library that provides portable SIMD/vector intrinsics'
arch=('x86_64' 'aarch64')
url='https://github.com/google/highway/'
license=('Apache-2.0' 'BSD-3-Clause')
depends=('gcc-libs')
makedepends=('cmake' 'gtest')
source=("https://github.com/google/highway/archive/${pkgver}/${pkgname}-${pkgver}.tar.gz"
	"disable_test_gcc_ice.patch")
sha256sums=('7e0be78b8318e8bdbf6fa545d2ecb4c90f947df03f7aadc42c1967f019e63343'
	'5b0147f36815d5d1b1e7869d049a4ad48aabb8a146ef78c55438b997dc6c7ab2')

prepare() {
	cd "${pkgname}-${pkgver}"
	patch -Np0 -i ${srcdir}/disable_test_gcc_ice.patch
}

build() {
    cmake -B build -S "${pkgname}-${pkgver}" \
        -G 'Unix Makefiles' \
        -DCMAKE_BUILD_TYPE:STRING='None' \
        -DCMAKE_INSTALL_PREFIX:PATH='/usr' \
        -DBUILD_SHARED_LIBS:BOOL='ON' \
        -DHWY_SYSTEM_GTEST:BOOL='ON' \
        -Wno-dev
    cmake --build build
}

check() {
    if [[ x"$CARCH" != x"aarch64" ]]; then
        ctest --test-dir build --output-on-failure
    fi
}

package() {
    DESTDIR="$pkgdir" cmake --install build
    install -D -m644 "${pkgname}-${pkgver}/LICENSE-BSD3" -t "${pkgdir}/usr/share/licenses/${pkgname}"
}
