#!/bin/bash # relative path to the cmake source tree directory (contains "CMakeLists.txt") SRCDIR="." # relative path to the cmake build tree directory BUILDDIR="build" DIR=$(pwd) SCRIPTNAME=$(basename "$0" 2>/dev/null || echo "$0") if [[ ! -f "$DIR"/"$SRCDIR"/CMakeLists.txt ]] then echo "$SRCDIR/CMakeLists.txt not found" >&2 echo "please run '$SCRIPTNAME' from its containing directory" >&2 exit 1 fi for OPTION in "$@" do if [[ "$OPTION" == "--clean" ]] then rm -r "$BUILDDIR" elif [[ "$OPTION" == "--update-translations" ]] then CMAKE_ARGS="$CMAKE_ARGS -DUPDATE_TRANSLATIONS:BOOL=ON" else echo "usage: $SCRIPTNAME [--clean] [--update-translations]" >&2 exit 1 fi done # note: NCORES may be too large on systems with hyperthreading NCORES=$(grep -c "^processor" /proc/cpuinfo 2>/dev/null) if [[ ! $NCORES -ge 1 ]] then NCORES=1 fi mkdir -p "$BUILDDIR" cd "$BUILDDIR" cmake $CMAKE_ARGS "$DIR"/"$SRCDIR"/ && make -j $NCORES cd "$DIR"