# Packager = Developer <dev@tuxcore.org> 
pkgname=spdlog
pkgver=%version%
pkgrel=%release%
pkgdesc='Very fast, header-only/compiled, C++ logging library'
arch=('x86_64')
url='https://github.com/gabime/spdlog'
license=('MIT')
depends=('libfmt.so')
makedepends=('cmake')
source=(
    "$pkgname-$pkgver.tar.gz::https://github.com/gabime/spdlog/archive/v$pkgver.tar.gz"
    "spdlog_fmt_external.patch"
)
provides=(
    'libspdlog.so'
)
sha256sums=('1586508029a7d0670dfcb2d97575dcdc242d3868a259742b69f100801ab4e16b'
            'a0eb34b7c6920f0db2587460071f53372663c191cdfe34bf5ea2704c309c745f')

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

build() {
    export CFLAGS+=" ${CPPFLAGS}"
    export CXXFLAGS+=" ${CPPFLAGS}"
    # FIXME: Stop -DSPDLOG_BUILD_TESTS=ON from downloading bundled catch2
    cmake -B build -S "$pkgname-$pkgver" \
        -DSPDLOG_BUILD_BENCH=OFF \
        -DSPDLOG_FMT_EXTERNAL=ON \
        -DSPDLOG_BUILD_SHARED=ON \
        -DCMAKE_BUILD_TYPE=None \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_INSTALL_LIBDIR=lib \
        -Wno-dev
    make -C build
}

# See FIXME above
#check() {
#    make -C build test
#}

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