# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=cmake
pkgname="${_realname}-bootstrap"
pkgver=4.1.2
pkgrel=1
pkgdesc="A cross-platform open-source make system"
arch=('i686' 'x86_64')
url="https://www.cmake.org/"
msys2_repository_url="https://gitlab.kitware.com/cmake/cmake"
msys2_references=(
  "anitya: 306"
  "cpe: cpe:2.3:a:cmake_project:cmake"
)
license=(spdx:BSD-3-Clause)
makedepends=('gcc'
             'make')
depends=('gcc-libs')
conflicts=('cmake' 'cmake-emacs' 'cmake-vim')
provides=("cmake=$pkgver")
source=(https://www.cmake.org/files/v${pkgver%.*}/${_realname}-${pkgver}.tar.gz)
sha256sums=('643f04182b7ba323ab31f526f785134fb79cba3188a852206ef0473fee282a15')

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

  "${srcdir}/${_realname}-${pkgver}/configure" \
    --prefix=/usr \
    --no-system-libs \
    --no-qt-gui \
    --parallel="$(nproc)" \
    --mandir=share/man \
    --docdir="share/doc/${_realname}" \
    --datadir="share/${_realname}" \
    -- -DCMAKE_USE_OPENSSL=OFF

  make
}

package() {
  cd ${srcdir}/build-${CARCH}

  make DESTDIR="${pkgdir}" install

  install -Dm644 ${srcdir}/${_realname}-${pkgver}/LICENSE.rst \
    ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE
}
