apply pkg-config patch to googletest

Googletest doesn't properly support pkg-config, however
there is a patch used by the yocto community.  This sets
everything up, and applies the patch.  With this patch,
the gtest.pc, etc files are created and installed, allowing
autotools to find the gtest/gmock libraries and correctly
configure any code using them.  Previously this was worked
around by explicitly using -lgtest, without checking for the
library.

Change-Id: I64854e676d74afa3d9e809e8d59351cfb88490f4
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/build-unit-test-docker.sh b/build-unit-test-docker.sh
index f91b52c..b28a9d4 100755
--- a/build-unit-test-docker.sh
+++ b/build-unit-test-docker.sh
@@ -90,15 +90,16 @@
 RUN tar -xJf autoconf-archive-2016.09.16.tar.xz
 RUN cd autoconf-archive-2016.09.16 && ./configure --prefix=/usr && make && make install
 
+# Googletest doesn't support pkg-config properly and therefore yocto uses a
+# patch to fix it.  This grabs and applies that patch and then builds it.
 RUN wget https://github.com/google/googletest/archive/release-1.8.0.tar.gz
 RUN tar -xzf release-1.8.0.tar.gz
-RUN cd googletest-release-1.8.0 && cmake -DBUILD_SHARED_LIBS=ON . && make && \
-cp -a googletest/include/gtest /usr/include && \
-cp -a googlemock/include/gmock /usr/include && \
-cp -a googlemock/gtest/libgtest.so /usr/lib/ && \
-cp -a googlemock/gtest/libgtest_main.so /usr/lib/ && \
-cp -a googlemock/libgmock.so /usr/lib/ && \
-cp -a googlemock/libgmock_main.so /usr/lib/
+RUN wget -O googletest-release-1.8.0/Add-pkg-config-support.patch \
+http://cgit.openembedded.org/meta-openembedded/plain/meta-oe/recipes-test/gtest/gtest/Add-pkg-config-support.patch?h=rocko
+RUN cd googletest-release-1.8.0 && patch -p1 -i Add-pkg-config-support.patch
+RUN cd googletest-release-1.8.0 && \
+cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_INSTALL_LIBDIR:PATH=/usr/lib -DCMAKE_INSTALL_INCLUDEDIR:PATH=/usr/include . && \
+make && make install
 
 RUN wget https://github.com/USCiLab/cereal/archive/v1.2.2.tar.gz
 RUN tar -xzf v1.2.2.tar.gz