diff options
Diffstat (limited to 'build.sh')
-rwxr-xr-x | build.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..f1983a7 --- /dev/null +++ b/build.sh @@ -0,0 +1,31 @@ +#!/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) + +if [[ ! -f "$DIR"/"$SRCDIR"/CMakeLists.txt ]] +then + echo "$SRCDIR/CMakeLists.txt not found" >&2 + SCRIPTNAME=$(basename "$0" 2>/dev/null || echo "$0") + echo "please run '$SCRIPTNAME' from its containing directory" >&2 + exit 1 +fi + +# 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 "$DIR"/"$SRCDIR"/ && make -j $NCORES + +cd "$DIR" |