diff --git a/build.sh b/build.sh
index 9ede334ae30434eefaf4540e0593f1a2cf4b76d6..87ea6ae8657ffddc2271a76082fd2c411b232391 100755
--- a/build.sh
+++ b/build.sh
@@ -3,13 +3,30 @@ set -e
 
 INSTALL_PREFIX=$1
 
+unameOut="$(uname -s)"
+case "${unameOut}" in
+    Linux*)
+			machine=Linux
+      CMAKE=cmake3
+      ;;
+    Darwin*)
+      machine=Darwin
+      CMAKE=cmake
+      ;;
+    *)
+      machine="UNKNOWN:${unameOut}"
+      echo "Unsupported hostOS: ${machine}"
+      exit 1
+esac
+echo "Host OS is ${machine}. Using $CMAKE"
+
 rm -rf build
 mkdir -p build
 pushd build
-cmake3 .. \
+${CMAKE} .. \
 	-DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
 	-DCMAKE_BUILD_TYPE=Release \
 	-DCMAKE_EXPORT_COMPILE_COMMANDS=true
-cmake3 --build . -- VERBOSE=1
-cmake3 --build . --target install
+${CMAKE} --build . -- VERBOSE=1
+${CMAKE} --build . --target install
 popd