# Maintainer: Sandy Carter <bwrsandman+MINGW-packages@gmail.com>
_realname=cxxopts
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.2.1
pkgrel=1
pkgdesc="Lightweight C++ command line option parser (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/jarro2783/cxxopts"
license=("MIT")
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-gcc"
             "git")
options=('strip' 'staticlibs')
source=(${_realname}-${pkgver}.tar.gz::https://github.com/jarro2783/cxxopts/archive/v${pkgver}.tar.gz)
sha256sums=('984aa3c8917d649b14d7f6277104ce38dd142ce378a9198ec926f03302399681')

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DCMAKE_BUILD_TYPE=Release \
    -DCXXOPTS_BUILD_EXAMPLES=OFF \
    -DCXXOPTS_BUILD_TESTS=OFF \
    ../${_realname}-${pkgver}

  make
}

package () {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install

  install -D -m644 ${srcdir}/${_realname}-${pkgver}/LICENSE "${pkgdir}/${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
