# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=abseil-cpp
pkgver=20240116.2
pkgrel=2
pkgdesc="Collection of C++ library code designed to augment the C++ standard library"
arch=('x86_64')
url='https://abseil.io'
license=('Apache-2.0')
depends=('gcc-libs' 'glibc' 'gtest')
makedepends=('cmake')
source=("https://github.com/abseil/abseil-cpp/archive/$pkgver/$pkgname-$pkgver.tar.gz"
         scoped-mock-log.patch)
sha256sums=('733726b8c3a6d39a4120d7e45ea8b41a434cdacde401cba500f14236c49b39dc'
            'a6cbc612a2b96fcbd52d081e03e8581107ceb4827edb19d96510a31c568e1396')

prepare() {
  cd "$srcdir/$pkgname-$pkgver"
  patch -p1 -i ../scoped-mock-log.patch # Install target needed by protobuf
}

build() {
  cd "$srcdir/$pkgname-$pkgver"
  cmake -Bbuild \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    -DCMAKE_CXX_FLAGS="${CXXFLAGS} -DNDEBUG" \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_CXX_STANDARD=17 \
    -DBUILD_SHARED_LIBS=ON \
    -DABSL_BUILD_TEST_HELPERS=ON \
    -DABSL_USE_EXTERNAL_GOOGLETEST=ON \
    -DABSL_FIND_GOOGLETEST=ON \
    -DABSL_BUILD_TESTING=ON
  cd build
  cmake --build . --target all
}

check() {
  cd "$srcdir/$pkgname-$pkgver/build"
  ctest
}

package() {
  cd "$srcdir/$pkgname-$pkgver/build"
  DESTDIR="$pkgdir" cmake --install .
}
