pkgname=spdlog
pkgver=1.15.3
pkgdesc="Fast C++ logging library"
homepage="https://github.com/gabime/spdlog"
license=("MIT")
_patches=("spdlog-force_external_fmt.patch")
_patch_sums=("257c7f7f56e66b88a16238a2c81887f2d5ba9692c18bf5fc371b95f44936018ec7c4a0abd0e54f38cb6a7957f82a1b95af9d238fa7fa16631f0be1980d76f692")
sources=("${pkgname}-${pkgver}.tar.gz"
  "${_patches[@]}"
)
urls=("https://github.com/gabime/${pkgname}/archive/v${pkgver}.tar.gz"
  "${_patches[@]}"
)
sha512sums=("21c35f4091850ea3a0cd6a24867e06e943df70d76cd5a7ec0b15a33e0e9e0cc3584ed7930e1ac6f347e7e06f0e002d0e759884eaf05310014e24ea0e0419fcc4"
  "${_patch_sums[@]}"
)

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
  for _patch in ${_patches[@]}; do
    patch -p1 -i ${filedir}/${_patch}
  done
  find include/spdlog/ -type f -name "*.orig" -delete
  rm -r include/spdlog/fmt/bundled
}

src_build() {
  local cmake_args=(
    -D CMAKE_INSTALL_PREFIX=/usr
    -D CMAKE_BUILD_TYPE=release
    -DSPDLOG_BUILD_BENCH=no
    -DSPDLOG_BUILD_EXAMPLE=no
    -DSPDLOG_FMT_EXTERNAL=yes
    -DSPDLOG_BUILD_SHARED=yes
    -DSPDLOG_BUILD_TESTS=no
  )
  cmake -B build "${cmake_args[@]}"
  cmake --build build
}

src_install() {
  DESTDIR="$pkgdir" cmake --install build
}

# vim:ft=sh syn=sh et sw=2:
