diff options
Diffstat (limited to 'build.sh')
-rwxr-xr-x | build.sh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..fdd8b44 --- /dev/null +++ b/build.sh @@ -0,0 +1,46 @@ +#!/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" |