build-unit-test-docker: Make common cmake flags

We have a common set of flags we want to pass to all cmake type builds.
This defines them in a common area and substitutes them into each cmake
command line.

Change-Id: Idf685d1c9cd4ce1016b0a1ad235c9b9370d6555a
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/build-unit-test-docker.sh b/build-unit-test-docker.sh
index d2fe133..a27aaea 100755
--- a/build-unit-test-docker.sh
+++ b/build-unit-test-docker.sh
@@ -78,6 +78,13 @@
 done
 wait
 
+# Define common flags used for cmake builds
+CMAKE_FLAGS=(
+  "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
+  "-DBUILD_SHARED_LIBS=ON"
+  "-DCMAKE_INSTALL_PREFIX:PATH=/usr/local"
+)
+
 ################################# docker img # #################################
 # Create docker image that can run package unit tests
 if [[ "${DISTRO}" == "ubuntu"* ]]; then
@@ -157,7 +164,7 @@
 RUN curl -L -o googletest.tar.gz https://github.com/google/googletest/archive/ba96d0b1161f540656efdaed035b3c062b60e006.tar.gz
 RUN tar -xzf googletest.tar.gz
 RUN cd googletest-* && \
-cmake -DBUILD_GTEST=ON -DBUILD_GMOCK=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX:PATH=/usr/local . && \
+cmake ${CMAKE_FLAGS[@]} -DBUILD_GTEST=ON -DBUILD_GMOCK=ON . && \
 make && make install
 
 RUN curl -L -O https://github.com/USCiLab/cereal/archive/v1.2.2.tar.gz
@@ -178,7 +185,7 @@
 cd tinyxml2-3* && \
 mkdir build && \
 cd build && \
-cmake .. && \
+cmake ${CMAKE_FLAGS[@]} .. && \
 make -j$(nproc) && \
 make install
 
@@ -189,7 +196,7 @@
 cd libvncserver && \
 mkdir build && \
 cd build && \
-cmake -DWITH_PNG=OFF .. && \
+cmake ${CMAKE_FLAGS[@]} -DWITH_PNG=OFF .. && \
 make -j$(nproc) && \
 make install