#!/bin/bash

mkdir build
cd build

export LDFLAGS=${LDFLAGS}" -Wl,-rpath,${PREFIX}/lib -L${PREFIX}/lib"

cmake -DCMAKE_INSTALL_PREFIX=$PREFIX \
      -DBUILD_STATIC:BOOL=OFF \
      -DPREFER_EXTERNAL_SNAPPY:BOOL=ON \
      -DPREFER_EXTERNAL_LZ4:BOOL=ON \
      -DPREFER_EXTERNAL_ZLIB:BOOL=ON \
      CMAKE_CXX=${CXX} \
      CMAKE_CC=${CC} \
      ..

cmake --build .
cmake --build . --target install
ctest
