# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Martin Wimpress <code@flexion.org>
# Contributor: Jorge Araya Navarro <elcorreo@deshackra.com>
# Contributor: Piotr Beling <qwak@w8.pl>
# Contributor: Vianney le Clément <vleclement AT gmail · com>

pkgname=unittestpp
pkgver=2.0.0
pkgrel=6
pkgdesc='Lightweight unit testing framework for C++'
url='https://github.com/unittest-cpp/unittest-cpp/'
arch=('x86_64' 'aarch64')
license=('MIT')
depends=('gcc-libs')
makedepends=('cmake')
options=('staticlibs')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/unittest-cpp/unittest-cpp/archive/v${pkgver}.tar.gz
        fix-pc-version.patch
        weaken-time-constraint.patch)
sha256sums=('74852198877dc2fdebdc4e5e9bd074018bf8ee03a13de139bfe41f4585b2f5b9'
            '511bc6ea34b49201c0ca17c2935fcf33b19c5598ef7b7246143469f9f54d6339'
            'SKIP')
sha512sums=('39318f4ed31534c116679a3257bf1438a6c4b3bef1894dfd40aea934950c6c8197af6a7f61539b8e9ddc67327c9388d7e8a6f8a3e0e966ad26c07554e2429cab'
            '89ed53b10864eca0dd35e53d5e098d9872d1a74e33bec1792ef6994768c687608f71995288d785693e76c279998e251cd3c3afd663980316e4c5c6ffd0bf4d2e'
            'SKIP')

prepare() {
  mkdir -p unittest-cpp-${pkgver}/build

  patch -d unittest-cpp-${pkgver} -p1 < fix-pc-version.patch # Fix version number in pc file
  patch -d unittest-cpp-${pkgver} -p1 < weaken-time-constraint.patch # 1ms is too short to be reliably passed
  sed -e 's/-Werror//' -i unittest-cpp-${pkgver}/CMakeLists.txt # Evil -Werror
}

build() {
  cd unittest-cpp-${pkgver}/build
  cmake .. \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_CXX_FLAGS="$CXXFLAGS -ffat-lto-objects"
  make all
}

package() {
  cd unittest-cpp-${pkgver}
  make -C build DESTDIR="${pkgdir}" install
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
