# Description: YAML parser and emitter in C++, written around the YAML 1.2 spec
# URL: https://github.com/jbeder/yaml-cpp
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: cmake
# Optional: ninja

name=yaml-cpp
version=0.7.0
release=1
source=(https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-$version/$name-$version.tar.gz
  yaml-cpp-0.6.3-abi-breakage.patch patch-yaml-cpp-config.cmake.in)


build() {
  patch -Np1 -d $name-$name-$version -i $SRC/yaml-cpp-0.6.3-abi-breakage.patch
  sed -e 's|%%PREFIX%%|/usr|' -i $SRC/patch-yaml-cpp-config.cmake.in
  patch -Np0 -d $name-$name-$version -i $SRC/patch-yaml-cpp-config.cmake.in

  prt-get isinst ninja && PKGMK_YAMLCPP+=' -G Ninja'

  cmake -S $name-$name-$version -B build $PKGMK_YAMLCPP \
    -D CMAKE_INSTALL_PREFIX=/usr \
    -D CMAKE_INSTALL_LIBDIR=lib \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_CXX_FLAGS_RELEASE="$CXXFLAGS" \
    -D BUILD_SHARED_LIBS=ON \
    -D YAML_BUILD_SHARED_LIBS=ON \
    -D YAML_CPP_BUILD_TESTS=OFF \
    -D YAML_CPP_BUILD_TOOLS=OFF \
    -Wno-dev
  cmake --build build
  DESTDIR=$PKG cmake --install build

  cmake -S $name-$name-$version -B build-static $PKGMK_YAMLCPP \
    -D CMAKE_INSTALL_PREFIX=/usr \
    -D CMAKE_INSTALL_LIBDIR=lib \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_CXX_FLAGS_RELEASE="$CXXFLAGS" \
    -D BUILD_SHARED_LIBS=OFF \
    -D YAML_BUILD_SHARED_LIBS=OFF \
    -D YAML_CPP_BUILD_TESTS=OFF \
    -D YAML_CPP_BUILD_TOOLS=OFF \
    -Wno-dev
  cmake --build build-static
  DESTDIR=$PKG cmake --install build-static
}
