#!/bin/env sh

set +e

# check whether ninja is around (you better start running)
if [ -x "$(command -v ninja)" ]; then
    generator="-G Ninja"
fi

# check whether clang is around (it's just better)
if [ -x "$(command -v clang)" ]; then
    cc="-DCMAKE_C_COMPILER=clang"
fi

if [ "$1" = "web" ]; then
    emcmake cmake $generator $cc -B build-web "${@:2}" && cmake --build build-web --parallel
else
    cmake $generator $cc -B build "$@" && cmake --build build --parallel
fi
