# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=msgpack-cxx
pkgbase="mingw-w64-${_realname}"
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=7.0.0
pkgrel=1
pkgdesc="MessagePack implementation for C++ (mingw-w64)"
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
url="https://github.com/msgpack/msgpack-c"
msys2_references=(
  'archlinux: msgpack-cxx'
)
license=('spdx:BSL-1.0')
depends=("${MINGW_PACKAGE_PREFIX}-boost")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-ninja")
source=("https://github.com/msgpack/msgpack-c/releases/download/cpp-${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('7504b7af7e7b9002ce529d4f941e1b7fb1fb435768780ce7da4abaac79bb156f')

build() {
  mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  MSYS2_ARG_CONV_EXCL='-DCMAKE_INSTALL_PREFIX=' \
    ${MINGW_PREFIX}/bin/cmake \
      -G "Ninja" \
      -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
      -DMSGPACK_USE_BOOST=ON \
      -DMSGPACK_BUILD_DOCS=OFF \
      -DMSGPACK_BUILD_EXAMPLES=OFF \
      -DMSGPACK_BUILD_TESTS=OFF \
      ../${_realname}-${pkgver}

  ${MINGW_PREFIX}/bin/cmake --build .
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}

  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake --install .

  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/LICENSE_1_0.txt "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE_1_0.txt
}
