summaryrefslogtreecommitdiffstats
path: root/build.sh
diff options
context:
space:
mode:
authorNils Schwabe2014-03-03 15:14:20 +0100
committerNils Schwabe2014-03-03 15:14:20 +0100
commit030d91e628a2ecd5634376c9c4d903a1fa0fb423 (patch)
tree227029e3b48deb1d4d01ce497d9ec3b8d47f7a61 /build.sh
parentInitial commit (diff)
downloadvmchooser2-030d91e628a2ecd5634376c9c4d903a1fa0fb423.tar.gz
vmchooser2-030d91e628a2ecd5634376c9c4d903a1fa0fb423.tar.xz
vmchooser2-030d91e628a2ecd5634376c9c4d903a1fa0fb423.zip
added files from vmchooser1
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh46
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"