# Maintainer: ImperatorS79 <fevrier.simon@gmail.com>

_realname=sol2
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.5.0
pkgrel=1
pkgdesc="sol2 is a C++ library binding to Lua (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://sol2.readthedocs.io/"
msys2_repository_url='https://github.com/ThePhD/sol2'
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-lua")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-ninja")
source=(${msys2_repository_url}/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz)
sha256sums=('86c0f6d2836b184a250fc2907091c076bf53c9603dd291eaebade36cc342e13c')

build() {
  mkdir build-${MSYSTEM} && cd build-${MSYSTEM}

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -GNinja \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    ../${_realname}-${pkgver}

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

package() {
  cd "build-${MSYSTEM}"
  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake --install .
  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/LICENSE.txt \
    "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE.txt
}
