# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=spdlog
pkgver=1.15.0
pkgrel=1
pkgdesc='Very fast, header-only/compiled, C++ logging library'
arch=('x86_64')
url='https://github.com/gabime/spdlog'
license=('MIT')
depends=(
    'gcc-libs'
    'glibc'
    'libfmt.so'
)
makedepends=(
    'cmake'
    'catch2'
)
source=(
    "$pkgname-$pkgver.tar.gz::https://github.com/gabime/spdlog/archive/v$pkgver.tar.gz"
    "spdlog_fmt_external.patch"
    "fix_build_with_fmt11.patch::https://github.com/gabime/spdlog/commit/d276069a6e916b1e1fd45885b15b72bd8ee000a7.patch"
)
provides=(
    'libspdlog.so'
)
sha256sums=('9962648c9b4f1a7bbc76fd8d9172555bad1871fdb14ff4f842ef87949682caa5'
            'a0eb34b7c6920f0db2587460071f53372663c191cdfe34bf5ea2704c309c745f'
            '9208168114b0996d6c4b74cfbdf145ed3209680bef258b9306467c39f1149202')

prepare() {
    cd "$pkgname-$pkgver"
    patch -p1 <../spdlog_fmt_external.patch
}

build() {
    cmake -B build -S "$pkgname-$pkgver" \
        -DSPDLOG_BUILD_BENCH=OFF \
        -DSPDLOG_FMT_EXTERNAL=ON \
        -DSPDLOG_BUILD_SHARED=ON \
        -DSPDLOG_BUILD_TESTS=ON \
        -DCMAKE_BUILD_TYPE=None \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_INSTALL_LIBDIR=lib \
        -Wno-dev
    cmake --build build
}

check() {
    cmake --build build --target test
}

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