MINIFICPP-1114 - Fix u16 build

Signed-off-by: Arpad Boda <aboda@apache.org>

This closes #705
diff --git a/aptitude.sh b/aptitude.sh
index ed3d815..05913d5 100644
--- a/aptitude.sh
+++ b/aptitude.sh
@@ -25,11 +25,19 @@
     CMAKE_BUILD_COMMAND="${CMAKE_BUILD_COMMAND} -DFAIL_ON_WARNINGS= "
 }
 bootstrap_cmake(){
+    ## on Ubuntu 16.04 we need a more recent CMake
+    if [[ "$OS" = Ubuntu* && "$VER" = "16.04" ]]; then
+      echo "Adding KitWare CMake apt repository..."
+      sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates gnupg software-properties-common wget
+      wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add -
+      sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial main' && sudo apt-get update
+    fi
     sudo apt-get -y install cmake
 }
 build_deps(){
     ## need to account for debian
     COMMAND="sudo apt-get -y install cmake gcc g++ zlib1g-dev libssl-dev uuid uuid-dev"
+
     export DEBIAN_FRONTEND=noninteractive
     INSTALLED=()
     INSTALLED+=("libbz2-dev")
diff --git a/bootstrap.sh b/bootstrap.sh
index 18d5832..ac60b9b 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -18,6 +18,10 @@
 
 script_directory="$(cd "$(dirname "$0")" && pwd)"
 
+CMAKE_GLOBAL_MIN_VERSION_MAJOR=3
+CMAKE_GLOBAL_MIN_VERSION_MINOR=7
+CMAKE_GLOBAL_MIN_VERSION_REVISION=0
+
 #RED='\033[0;41;30m'
 RED='\033[0;101m'
 NO_COLOR='\033[0;0;39m'
@@ -215,26 +219,31 @@
   CMAKE_COMMAND="cmake"
 fi
 
-if [ -z "${CMAKE_COMMAND}" ]; then
-  echo "CMAKE is not installed, attempting to install it..."
+if [ -n "${CMAKE_COMMAND}" ]; then
+  get_cmake_version
+fi
+
+if [ -z "${CMAKE_COMMAND}" ] ||
+   [ "$CMAKE_MAJOR" -lt "$CMAKE_GLOBAL_MIN_VERSION_MAJOR" ] ||
+   [ "$CMAKE_MINOR" -lt "$CMAKE_GLOBAL_MIN_VERSION_MINOR" ] ||
+   [ "$CMAKE_REVISION" -lt "$CMAKE_GLOBAL_MIN_VERSION_REVISION" ]; then
+  echo "CMake is not installed or too old, attempting to install it..."
   bootstrap_cmake
   if [ -x "$(command -v cmake3)" ]; then
     CMAKE_COMMAND="cmake3"
   elif [ -x "$(command -v cmake)" ]; then
     CMAKE_COMMAND="cmake"
   fi
+
+  get_cmake_version
 fi
 
-
-## before we begin, let's ensure that cmake exists
-
-CMAKE_VERSION=`${CMAKE_COMMAND} --version | head -n 1 | awk '{print $3}'`
-
-CMAKE_MAJOR=`echo $CMAKE_VERSION | cut -d. -f1`
-CMAKE_MINOR=`echo $CMAKE_VERSION | cut -d. -f2`
-CMAKE_REVISION=`echo $CMAKE_VERSION | cut -d. -f3`
-
-
+if [ "$CMAKE_MAJOR" -lt "$CMAKE_GLOBAL_MIN_VERSION_MAJOR" ] ||
+   [ "$CMAKE_MINOR" -lt "$CMAKE_GLOBAL_MIN_VERSION_MINOR" ] ||
+   [ "$CMAKE_REVISION" -lt "$CMAKE_GLOBAL_MIN_VERSION_REVISION" ]; then
+  echo "Failed to install or update CMake, exiting..."
+  exit
+fi
 
 add_cmake_option PORTABLE_BUILD ${TRUE}
 add_cmake_option DEBUG_SYMBOLS ${FALSE}
diff --git a/bstrp_functions.sh b/bstrp_functions.sh
index 74f079a..93b85f5 100755
--- a/bstrp_functions.sh
+++ b/bstrp_functions.sh
@@ -18,6 +18,14 @@
 
 script_directory="$(cd "$(dirname "$0")" && pwd)"
 
+get_cmake_version(){
+  CMAKE_VERSION=`${CMAKE_COMMAND} --version | head -n 1 | awk '{print $3}'`
+
+  CMAKE_MAJOR=`echo $CMAKE_VERSION | cut -d. -f1`
+  CMAKE_MINOR=`echo $CMAKE_VERSION | cut -d. -f2`
+  CMAKE_REVISION=`echo $CMAKE_VERSION | cut -d. -f3`
+}
+
 add_option(){
   eval "$1=$2"
   OPTIONS+=("$1")
diff --git a/docker/xenial/Dockerfile b/docker/xenial/Dockerfile
index ea30332..6299bef 100644
--- a/docker/xenial/Dockerfile
+++ b/docker/xenial/Dockerfile
@@ -34,13 +34,7 @@
 RUN mkdir -p $MINIFI_BASE_DIR 
 USER $USER
 
-
 RUN apt-get update && apt-get install -y openjdk-8-jdk openjdk-8-source sudo git maven autogen autoconf automake
-RUN apt-get install -y apt-transport-https ca-certificates gnupg software-properties-common wget
-RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add -
-RUN apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial main' && apt-get update
-RUN apt-get install -y cmake
-
 
 ADD $MINIFI_SOURCE_CODE $MINIFI_BASE_DIR