#!/bin/sh

set -ev

export WORKSPACE=${WORKSPACE:?}
export BUILD_DIR="${WORKSPACE}/${BUILD_DIR:-build}"
export INSTALL_DIR="${WORKSPACE}/${INSTALL_DIR:-install}"

mkdir -p ${BUILD_DIR}
mkdir -p ${INSTALL_DIR}

cd ${BUILD_DIR}

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig

cmake \
  -G Ninja \
  -D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
  -DCMAKE_BUILD_TYPE=Release \
  -D PYTHON_EXECUTABLE=/usr/local/bin/python3 \
  ${CMAKE_OPTIONS} \
  ..
cmake --build . --target install
