diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2626f2c601879d8537c24224ae0ddd0549552173..f3240982968a4e6e6d2ce98c4ccd3b6c5084c3b0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -679,10 +679,6 @@ if (CONFIG_AOM_HIGHBITDEPTH)
       "${AOM_ROOT}/test/av1_quantize_test.cc")
 endif ()
 
-set(AOM_GTEST_SOURCES
-    "${AOM_ROOT}/third_party/googletest/src/src/gtest-all.cc"
-    "${AOM_ROOT}/third_party/googletest/src/include/gtest/gtest.h")
-
 set(AOM_TEST_INTRA_PRED_SPEED_SOURCES
     "${AOM_CONFIG_DIR}/usage_exit.c"
     "${AOM_ROOT}/test/test_intra_pred_speed.cc")
@@ -898,10 +894,10 @@ if (CONFIG_WEBM_IO)
 endif ()
 
 if (CONFIG_UNIT_TESTS)
-  include_directories("${AOM_ROOT}/third_party/googletest/src/include"
-                      "${AOM_ROOT}/third_party/googletest/src")
-
-  add_library(aom_gtest OBJECT ${AOM_GTEST_SOURCES})
+  include_directories(
+    "${AOM_ROOT}/third_party/googletest/src/googletest/src"
+    "${AOM_ROOT}/third_party/googletest/src/googletest/include")
+  add_subdirectory("${AOM_ROOT}/third_party/googletest/src/googletest")
 
   # Generate a stub file containing the C function usage_exit(); this is
   # required because of the test dependency on aom_common_app_util.
@@ -912,15 +908,13 @@ if (CONFIG_UNIT_TESTS)
   add_executable(test_libaom ${AOM_UNIT_TEST_SOURCES}
                  $<TARGET_OBJECTS:aom_common_app_util>
                  $<TARGET_OBJECTS:aom_decoder_app_util>
-                 $<TARGET_OBJECTS:aom_encoder_app_util>
-                 $<TARGET_OBJECTS:aom_gtest>)
-  target_link_libraries(test_libaom PUBLIC aom)
+                 $<TARGET_OBJECTS:aom_encoder_app_util>)
+  target_link_libraries(test_libaom PUBLIC aom gtest)
 
   add_executable(test_intra_pred_speed
                  ${AOM_TEST_INTRA_PRED_SPEED_SOURCES}
-                 $<TARGET_OBJECTS:aom_common_app_util>
-                 $<TARGET_OBJECTS:aom_gtest>)
-  target_link_libraries(test_intra_pred_speed PUBLIC aom)
+                 $<TARGET_OBJECTS:aom_common_app_util>)
+  target_link_libraries(test_intra_pred_speed PUBLIC aom gtest)
 
   if (CONFIG_DECODE_PERF_TESTS AND CONFIG_WEBM_IO)
     target_sources(test_libaom PUBLIC ${AOM_DECODE_PERF_TEST_SOURCES})
diff --git a/libs.mk b/libs.mk
index d4a304032f63014ad0975e4009bda39c8fbc89c2..f931e1266f17200137607568be718c982e1e9848 100644
--- a/libs.mk
+++ b/libs.mk
@@ -396,8 +396,7 @@ testdata:: $(LIBAOM_TEST_DATA)
 
 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
 ifeq ($(CONFIG_MSVS),yes)
-
-gtest.$(VCPROJ_SFX): $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc
+gtest.$(VCPROJ_SFX): $(SRC_PATH_BARE)/third_party/googletest/src/googletest/src/gtest-all.cc
 	@echo "    [CREATE] $@"
 	$(qexec)$(GEN_VCPROJ) \
             --lib \
@@ -408,8 +407,10 @@ gtest.$(VCPROJ_SFX): $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.c
             --ver=$(CONFIG_VS_VERSION) \
             --src-path-bare="$(SRC_PATH_BARE)" \
             -D_VARIADIC_MAX=10 \
-            --out=gtest.$(VCPROJ_SFX) $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \
-            -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" -I"$(SRC_PATH_BARE)/third_party/googletest/src"
+            --out=gtest.$(VCPROJ_SFX) \
+	    $(SRC_PATH_BARE)/third_party/googletest/src/googletest/src/gtest-all.cc \
+            -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/googletest/include" \
+	    -I"$(SRC_PATH_BARE)/third_party/googletest/src/googletest"
 
 PROJECTS-$(CONFIG_MSVS) += gtest.$(VCPROJ_SFX)
 
@@ -425,7 +426,7 @@ test_libaom.$(VCPROJ_SFX): $(LIBAOM_TEST_SRCS) aom.$(VCPROJ_SFX) gtest.$(VCPROJ_
             --src-path-bare="$(SRC_PATH_BARE)" \
             $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
             --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
-            -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
+            -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/googletest/include" \
             $(if $(CONFIG_WEBM_IO),-I"$(SRC_PATH_BARE)/third_party/libwebm") \
             -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^
 
@@ -447,21 +448,21 @@ test_intra_pred_speed.$(VCPROJ_SFX): $(TEST_INTRA_PRED_SPEED_SRCS) aom.$(VCPROJ_
             --src-path-bare="$(SRC_PATH_BARE)" \
             $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
             --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
-            -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
+            -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/googletest/include" \
             -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^
 endif  # TEST_INTRA_PRED_SPEED
 endif
 else
 
 include $(SRC_PATH_BARE)/third_party/googletest/gtest.mk
-GTEST_SRCS := $(addprefix third_party/googletest/src/,$(call enabled,GTEST_SRCS))
+GTEST_SRCS := $(addprefix third_party/,$(call enabled,GTEST_SRCS))
 GTEST_OBJS=$(call objs,$(GTEST_SRCS))
 ifeq ($(filter win%,$(TGT_OS)),$(TGT_OS))
 # Disabling pthreads globally will cause issues on darwin and possibly elsewhere
 $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -DGTEST_HAS_PTHREAD=0
 endif
-GTEST_INCLUDES := -I$(SRC_PATH_BARE)/third_party/googletest/src
-GTEST_INCLUDES += -I$(SRC_PATH_BARE)/third_party/googletest/src/include
+GTEST_INCLUDES := -I$(SRC_PATH_BARE)/third_party/googletest/src/googletest
+GTEST_INCLUDES += -I$(SRC_PATH_BARE)/third_party/googletest/src/googletest/include
 $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES)
 OBJS-yes += $(GTEST_OBJS)
 LIBS-yes += $(BUILD_PFX)libgtest.a $(BUILD_PFX)libgtest_g.a
diff --git a/test/accounting_test.cc b/test/accounting_test.cc
index b4f76849b98b15bdef56031758b0b8fa83c4c708..e8387d0dc08f3067e300eab3dbada792abaa6eeb 100644
--- a/test/accounting_test.cc
+++ b/test/accounting_test.cc
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "test/acm_random.h"
 #include "aom/aom_integer.h"
diff --git a/test/acm_random.h b/test/acm_random.h
index eb2353d4af34c83f2128227864c03f7b6063bd24..4842345ff62bb535034bade47e9b5ec4b24af68d 100644
--- a/test/acm_random.h
+++ b/test/acm_random.h
@@ -12,7 +12,7 @@
 #ifndef TEST_ACM_RANDOM_H_
 #define TEST_ACM_RANDOM_H_
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "aom/aom_integer.h"
 
diff --git a/test/active_map_refresh_test.cc b/test/active_map_refresh_test.cc
index 161dc733d5d18a5662f3618c06581f62b86a673d..7ee86e7e6798f90f250524251694825e655bd17b 100644
--- a/test/active_map_refresh_test.cc
+++ b/test/active_map_refresh_test.cc
@@ -10,7 +10,7 @@
 */
 
 #include <algorithm>
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/util.h"
diff --git a/test/active_map_test.cc b/test/active_map_test.cc
index 2d30480458a64a6252b3a8191438c741f32feb10..a926b0faf3919aaf99360be188bfa7344657fe99 100644
--- a/test/active_map_test.cc
+++ b/test/active_map_test.cc
@@ -11,7 +11,7 @@
 
 #include <climits>
 #include <vector>
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/i420_video_source.h"
diff --git a/test/altref_test.cc b/test/altref_test.cc
index be9b774545940d987184ed2545a54393fa3db6a8..6dd8b5186fe91c98200f709a7a5d1f583539e16b 100644
--- a/test/altref_test.cc
+++ b/test/altref_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/i420_video_source.h"
diff --git a/test/android/Android.mk b/test/android/Android.mk
index 9ad2a345828d0b77023a4bd0e002156dc95d1b9e..74f9d7cbaf22b3d1ac7651a74596d5d54c0a2ed1 100644
--- a/test/android/Android.mk
+++ b/test/android/Android.mk
@@ -32,9 +32,9 @@ include $(CLEAR_VARS)
 LOCAL_ARM_MODE := arm
 LOCAL_CPP_EXTENSION := .cc
 LOCAL_MODULE := gtest
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/third_party/googletest/src/
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/third_party/googletest/src/include/
-LOCAL_SRC_FILES := ./third_party/googletest/src/src/gtest-all.cc
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/third_party/googletest/src/googletest/src
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/third_party/googletest/src/googletest/include
+LOCAL_SRC_FILES := ./third_party/googletest/src/googletest/src/gtest-all.cc
 include $(BUILD_STATIC_LIBRARY)
 
 #libaom_test
diff --git a/test/ans_codec_test.cc b/test/ans_codec_test.cc
index 0b1650e0bb99b56e39a2c64817b3e0e2839ab2dc..a1b25fbdac070ace74c43b816e612f36b39d02b3 100644
--- a/test/ans_codec_test.cc
+++ b/test/ans_codec_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
diff --git a/test/ans_test.cc b/test/ans_test.cc
index 585773f1c53fa579f7368dbbb50e64c0f52275c6..2e513eaf11bb5e2935d778c12e5ba64457ce0262 100644
--- a/test/ans_test.cc
+++ b/test/ans_test.cc
@@ -16,7 +16,7 @@
 #include <utility>
 #include <vector>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "test/acm_random.h"
 #include "aom_dsp/ansreader.h"
diff --git a/test/aq_segment_test.cc b/test/aq_segment_test.cc
index e231b4e6cabf9f80bf32f189852f792e5a01c860..a9bad821e05e02843750bd0e26c1640f5dfa48a0 100644
--- a/test/aq_segment_test.cc
+++ b/test/aq_segment_test.cc
@@ -10,7 +10,7 @@
 */
 
 #include "./aom_config.h"
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/i420_video_source.h"
diff --git a/test/arf_freq_test.cc b/test/arf_freq_test.cc
index 3666697bc5f6107e7a056aa1e2f2b642c49546b4..cafd8e358efea72f16ab6599ec7b0bb20581d61b 100644
--- a/test/arf_freq_test.cc
+++ b/test/arf_freq_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
diff --git a/test/av1_convolve_optimz_test.cc b/test/av1_convolve_optimz_test.cc
index a4bb7e7d1594f741f4bf415b55c76200b14c46c0..6265c68d4f4a65b6d3e544ae06865a1688fe5579 100644
--- a/test/av1_convolve_optimz_test.cc
+++ b/test/av1_convolve_optimz_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./av1_rtcd.h"
 #include "test/acm_random.h"
diff --git a/test/av1_convolve_test.cc b/test/av1_convolve_test.cc
index 6de85398e365e26985161eea0cef19e93f3988a0..225b29d59d08138c0597dae53739e27000baa6be 100644
--- a/test/av1_convolve_test.cc
+++ b/test/av1_convolve_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./av1_rtcd.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/av1_dct_test.cc b/test/av1_dct_test.cc
index defecb2188d4724ccb766e57aee84ca471708ba0..691cc8b794db967ed468b8726301c78337246fb1 100644
--- a/test/av1_dct_test.cc
+++ b/test/av1_dct_test.cc
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <new>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/acm_random.h"
 #include "test/util.h"
 #include "./aom_config.h"
diff --git a/test/av1_ext_tile_test.cc b/test/av1_ext_tile_test.cc
index 679a6ed917d6e9a864a272db938b276e2964afa7..cf707341559e8461acfc46e6b537a0f8e85cdc05 100644
--- a/test/av1_ext_tile_test.cc
+++ b/test/av1_ext_tile_test.cc
@@ -12,7 +12,7 @@
 #include <assert.h>
 #include <string>
 #include <vector>
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/i420_video_source.h"
diff --git a/test/av1_fht16x16_test.cc b/test/av1_fht16x16_test.cc
index a776618dea7f840ab2803d212094394ebb42b4cb..0eee35b365a631468868e43c7c00f46e147b1fad 100644
--- a/test/av1_fht16x16_test.cc
+++ b/test/av1_fht16x16_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./av1_rtcd.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/av1_fht16x32_test.cc b/test/av1_fht16x32_test.cc
index aea3024635202b3dd83633afa5cf245935f01895..43d0253273a123fac419f00f34f1404444199a3a 100644
--- a/test/av1_fht16x32_test.cc
+++ b/test/av1_fht16x32_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_dsp_rtcd.h"
 #include "./av1_rtcd.h"
diff --git a/test/av1_fht16x8_test.cc b/test/av1_fht16x8_test.cc
index e0fbb95ff4695868cbb73ed398d914ae2723a30d..d99bec5eb38b9675f32e2a2043317e23b6469e8e 100644
--- a/test/av1_fht16x8_test.cc
+++ b/test/av1_fht16x8_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_dsp_rtcd.h"
 #include "./av1_rtcd.h"
diff --git a/test/av1_fht32x16_test.cc b/test/av1_fht32x16_test.cc
index ae7f0be8603988546d0b743317d058be9faea5bb..e38283f865bf9131891b19f8838bf899a16b2c83 100644
--- a/test/av1_fht32x16_test.cc
+++ b/test/av1_fht32x16_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_dsp_rtcd.h"
 #include "./av1_rtcd.h"
diff --git a/test/av1_fht4x4_test.cc b/test/av1_fht4x4_test.cc
index 913add4e233ec4dd35ad1444d1aad9f513255a64..611b867c0071b4490794eafd4567fd2a107b4672 100644
--- a/test/av1_fht4x4_test.cc
+++ b/test/av1_fht4x4_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./av1_rtcd.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/av1_fht4x8_test.cc b/test/av1_fht4x8_test.cc
index ddb2929bee14ed70f003f7c28056c86eb7c9649b..a899c8739121d8022aef01f706cdd0ae0248d67d 100644
--- a/test/av1_fht4x8_test.cc
+++ b/test/av1_fht4x8_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_dsp_rtcd.h"
 #include "./av1_rtcd.h"
diff --git a/test/av1_fht8x16_test.cc b/test/av1_fht8x16_test.cc
index 9e92913dd548a8bcb95041d2ac2d4597b5fb4c46..601fa320bfa3560c42eb1c5b366ac270201df000 100644
--- a/test/av1_fht8x16_test.cc
+++ b/test/av1_fht8x16_test.cc
@@ -8,7 +8,7 @@
  * Media Patent License 1.0 was not distributed with this source code in the
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_dsp_rtcd.h"
 #include "./av1_rtcd.h"
diff --git a/test/av1_fht8x4_test.cc b/test/av1_fht8x4_test.cc
index dc63c0b8e503c780ea744ff2b9523093f43b3938..9bf4ff647559c7a91fa7cd67b2721e6dcf3dd49d 100644
--- a/test/av1_fht8x4_test.cc
+++ b/test/av1_fht8x4_test.cc
@@ -8,7 +8,7 @@
  * Media Patent License 1.0 was not distributed with this source code in the
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_dsp_rtcd.h"
 #include "./av1_rtcd.h"
diff --git a/test/av1_fht8x8_test.cc b/test/av1_fht8x8_test.cc
index 90a7e443db4d9f5d063d1d5b140ccd7e6922db04..29ca004d0f47f79cbe63f4483e5253083b26d0a9 100644
--- a/test/av1_fht8x8_test.cc
+++ b/test/av1_fht8x8_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./av1_rtcd.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/av1_highbd_iht_test.cc b/test/av1_highbd_iht_test.cc
index 94d178da6703b14221b32f4c056b9126aff86c7f..422cca5f3415be2009683f64bbbbf04bad3ea140 100644
--- a/test/av1_highbd_iht_test.cc
+++ b/test/av1_highbd_iht_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./av1_rtcd.h"
 #include "test/acm_random.h"
diff --git a/test/av1_inv_txfm_test.cc b/test/av1_inv_txfm_test.cc
index f5b33d29251d11e7781ad888d000f576cc27fc97..af3fee8726b0b6ce01fede032279646e9e9d1c6f 100644
--- a/test/av1_inv_txfm_test.cc
+++ b/test/av1_inv_txfm_test.cc
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./av1_rtcd.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/av1_quantize_test.cc b/test/av1_quantize_test.cc
index 667b5581e4a39937e8355c109a2b8b7c9cdc029a..43acd6fe72ae11ac6d645cb1e7f64f71e48af0d6 100644
--- a/test/av1_quantize_test.cc
+++ b/test/av1_quantize_test.cc
@@ -10,7 +10,7 @@
  */
 #include <stdlib.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #include "./av1_rtcd.h"
diff --git a/test/av1_txfm_test.h b/test/av1_txfm_test.h
index b786665c2fba767bc744306f6e091f4c3b5102b8..a62d0603f73a68259d687b8adaaf2a30b20bf408 100644
--- a/test/av1_txfm_test.h
+++ b/test/av1_txfm_test.h
@@ -19,7 +19,7 @@
 #endif
 #include <math.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "test/acm_random.h"
 #include "av1/common/enums.h"
diff --git a/test/av1_wedge_utils_test.cc b/test/av1_wedge_utils_test.cc
index 52b9fc0b8d8b8aac086a90c0750334964e0e329a..d4b560fc10cac176132aa2c807c021da1a6a130d 100644
--- a/test/av1_wedge_utils_test.cc
+++ b/test/av1_wedge_utils_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 
diff --git a/test/avg_test.cc b/test/avg_test.cc
index b7a707d4e5f300106c58cdabeb53d1d6d382a94b..529672d74df84431aca2674a7d063038b7966916 100644
--- a/test/avg_test.cc
+++ b/test/avg_test.cc
@@ -13,7 +13,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/blend_a64_mask_1d_test.cc b/test/blend_a64_mask_1d_test.cc
index 684cbedb394413f7ba610760811c4fca1220feb9..25a22e5ebd08443557b56b91f4a1a999f478fb14 100644
--- a/test/blend_a64_mask_1d_test.cc
+++ b/test/blend_a64_mask_1d_test.cc
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/register_state_check.h"
 #include "test/function_equivalence_test.h"
 
diff --git a/test/blend_a64_mask_test.cc b/test/blend_a64_mask_test.cc
index 0cfee2ec245d498d656333d136fca18d7af7975c..21c3721fe6740fa7eb883ce95b30b30bcfdb281c 100644
--- a/test/blend_a64_mask_test.cc
+++ b/test/blend_a64_mask_test.cc
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/register_state_check.h"
 #include "test/function_equivalence_test.h"
 
diff --git a/test/boolcoder_test.cc b/test/boolcoder_test.cc
index c6a32884c7d991e313d7831332e8b6a1aea11aa1..4d9d7aaf44f93f550e3aacb3263349219e2ff048 100644
--- a/test/boolcoder_test.cc
+++ b/test/boolcoder_test.cc
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "test/acm_random.h"
 #include "aom/aom_integer.h"
diff --git a/test/borders_test.cc b/test/borders_test.cc
index 16830b488e92052cf5208a61196847137dce6ef7..076f9140448ceb67fe318dc584bc6d8e043a7eed 100644
--- a/test/borders_test.cc
+++ b/test/borders_test.cc
@@ -11,7 +11,7 @@
 
 #include <climits>
 #include <vector>
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/i420_video_source.h"
diff --git a/test/clpf_test.cc b/test/clpf_test.cc
index 8d6dd7530a2a4499a1597b7e214a28c6a7e3ae4e..dfcde50973353737ca247a16d1eac3017b7a2bdd 100644
--- a/test/clpf_test.cc
+++ b/test/clpf_test.cc
@@ -12,7 +12,7 @@
 #include <cstdlib>
 #include <string>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/convolve_test.cc b/test/convolve_test.cc
index 12af4fd7c8dd040d4390a4e93f755644444a267c..62749a0a805d5b2e9e5ad9f0f56e9f333157705e 100644
--- a/test/convolve_test.cc
+++ b/test/convolve_test.cc
@@ -11,7 +11,7 @@
 
 #include <string.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/cpu_speed_test.cc b/test/cpu_speed_test.cc
index 558068e6f50589b0f9400ce59e4f5483f80404a7..9b796646274b9511c1ad7cccec7904963ce41c7e 100644
--- a/test/cpu_speed_test.cc
+++ b/test/cpu_speed_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/i420_video_source.h"
diff --git a/test/datarate_test.cc b/test/datarate_test.cc
index ec866044efe386dfd80c64f83f303db30fa9f2b5..48be4a46dfe7fe5e3d003dd1d21072f5ca63823a 100644
--- a/test/datarate_test.cc
+++ b/test/datarate_test.cc
@@ -10,7 +10,7 @@
 */
 
 #include "./aom_config.h"
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/i420_video_source.h"
diff --git a/test/dct16x16_test.cc b/test/dct16x16_test.cc
index 9928b0c18834ef1d4bb08cffe68e87ac20933d16..0fba26c23dfc7db9e6a42614a7a4c7d0838c5f74 100644
--- a/test/dct16x16_test.cc
+++ b/test/dct16x16_test.cc
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./av1_rtcd.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/dct32x32_test.cc b/test/dct32x32_test.cc
index cb2fbd538e449258a0cec402f8c2b8cfea3b119e..a9c4c0b8e81f4775eca42987e7578181c371570a 100644
--- a/test/dct32x32_test.cc
+++ b/test/dct32x32_test.cc
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./av1_rtcd.h"
 #include "./aom_config.h"
diff --git a/test/decode_api_test.cc b/test/decode_api_test.cc
index d62fcedb60c9b4301f828c086bd78043df01c6d8..6bd72a45d40368c67c709f0b6f31370ac08ee647 100644
--- a/test/decode_api_test.cc
+++ b/test/decode_api_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #include "test/ivf_video_source.h"
diff --git a/test/decode_test_driver.cc b/test/decode_test_driver.cc
index 7adb9d616f0085f0e67d5d66e6707b10c55c6671..782f58e5323eb1726480bbd4211c5d01ed9ed359 100644
--- a/test/decode_test_driver.cc
+++ b/test/decode_test_driver.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "test/codec_factory.h"
 #include "test/decode_test_driver.h"
diff --git a/test/decode_test_driver.h b/test/decode_test_driver.h
index b8f8d1a619be22c2acfefd11441c2865e407e1d5..153ff5db47ce0e3004a22606eb06dfe967f5dd18 100644
--- a/test/decode_test_driver.h
+++ b/test/decode_test_driver.h
@@ -12,7 +12,7 @@
 #ifndef TEST_DECODE_TEST_DRIVER_H_
 #define TEST_DECODE_TEST_DRIVER_H_
 #include <cstring>
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "./aom_config.h"
 #include "aom/aom_decoder.h"
 
diff --git a/test/divu_small_test.cc b/test/divu_small_test.cc
index d3a134a2bff36d2af285a15f734f67207e9de907..064f8ee4541e7dc8fc5a21b73fce76dc79f8a1fa 100644
--- a/test/divu_small_test.cc
+++ b/test/divu_small_test.cc
@@ -11,7 +11,7 @@
 
 #include <stdlib.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "test/acm_random.h"
 #include "av1/common/odintrin.h"
diff --git a/test/encode_api_test.cc b/test/encode_api_test.cc
index 49fac2720763cc13b5a46e8f39b4f380b1b63ff5..14e43c847f0865ecce16d1951662e5b3aaa9c45d 100644
--- a/test/encode_api_test.cc
+++ b/test/encode_api_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #include "aom/aomcx.h"
diff --git a/test/encode_perf_test.cc b/test/encode_perf_test.cc
index 732e2a1613633d3f47104764bbf2e7131453d4d8..e2a4f2b71cc47f96120572e52e8852f08299dfa2 100644
--- a/test/encode_perf_test.cc
+++ b/test/encode_perf_test.cc
@@ -10,7 +10,7 @@
 */
 
 #include <string>
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "./aom_config.h"
 #include "./aom_version.h"
 #include "test/codec_factory.h"
diff --git a/test/encode_test_driver.cc b/test/encode_test_driver.cc
index 092e669589ad9f0b57ea97fef24a8e0ef2801fa4..626ca528abb38f8604ca1fed2504cbe4df50e687 100644
--- a/test/encode_test_driver.cc
+++ b/test/encode_test_driver.cc
@@ -11,7 +11,7 @@
 
 #include <string>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #include "aom_ports/mem.h"
diff --git a/test/encode_test_driver.h b/test/encode_test_driver.h
index 45a080e778a3f8996e947e857fdc4d3823cb58e5..5de949d7c16c25df3348af5057d84ede636541bc 100644
--- a/test/encode_test_driver.h
+++ b/test/encode_test_driver.h
@@ -14,7 +14,7 @@
 #include <string>
 #include <vector>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #if CONFIG_AV1_ENCODER
diff --git a/test/encoder_parms_get_to_decoder.cc b/test/encoder_parms_get_to_decoder.cc
index 8d8e2b2fd216ac6849b43e68f5ccb6c90728fa91..4c04869303b441a076d4d6910e50ad625019bc05 100644
--- a/test/encoder_parms_get_to_decoder.cc
+++ b/test/encoder_parms_get_to_decoder.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
diff --git a/test/end_to_end_test.cc b/test/end_to_end_test.cc
index e9e7d425dd8cc2b475e726e0ea389b51c3377185..9769d6e5c06d42e2172e79e88d5d05336211161e 100644
--- a/test/end_to_end_test.cc
+++ b/test/end_to_end_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
diff --git a/test/error_block_test.cc b/test/error_block_test.cc
index 3de35c7d89f7e3d40e3ee2b717cbbfaa227a8caf..1c985577e3e7b68306e5c8a92d6cec8ecdc77a5c 100644
--- a/test/error_block_test.cc
+++ b/test/error_block_test.cc
@@ -13,7 +13,7 @@
 #include <cstdlib>
 #include <string>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #include "./av1_rtcd.h"
diff --git a/test/error_resilience_test.cc b/test/error_resilience_test.cc
index 07b60399ebd7297245f72237f5e12e5cea876fe1..63f10012f8ae51385165d53064e61b10afb9d9da 100644
--- a/test/error_resilience_test.cc
+++ b/test/error_resilience_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/i420_video_source.h"
diff --git a/test/ethread_test.cc b/test/ethread_test.cc
index 5ea73f610d1f39f6d6c7c71a99db6171e9ebf89f..5b519f8febaefb0464211a5930456530ea5b9fab 100644
--- a/test/ethread_test.cc
+++ b/test/ethread_test.cc
@@ -11,7 +11,7 @@
 
 #include <string>
 #include <vector>
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/md5_helper.h"
diff --git a/test/fdct4x4_test.cc b/test/fdct4x4_test.cc
index c22abb5eb441c72278452b21b0edce6961f57e56..b191a971e9b610445b6840242e81782ea92efa18 100644
--- a/test/fdct4x4_test.cc
+++ b/test/fdct4x4_test.cc
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./av1_rtcd.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/fdct8x8_test.cc b/test/fdct8x8_test.cc
index bbfb7f1a2a5f6e131887340ec88823dc6af6f733..61d8da378f199b42736f2931bdd9070f4f4e79bf 100644
--- a/test/fdct8x8_test.cc
+++ b/test/fdct8x8_test.cc
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./av1_rtcd.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/fht32x32_test.cc b/test/fht32x32_test.cc
index 039a9ecd015689ed88127f57297be37a56218616..160bd5b5400cd00452bc761d140563e0a632054d 100644
--- a/test/fht32x32_test.cc
+++ b/test/fht32x32_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./av1_rtcd.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/filterintra_predictors_test.cc b/test/filterintra_predictors_test.cc
index d09b63dfb9e252694e92e970d6a0c9b0171f739c..d722f53d2b3ad57ddba119e3f6c84f1cc4bf342f 100644
--- a/test/filterintra_predictors_test.cc
+++ b/test/filterintra_predictors_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./av1_rtcd.h"
 #include "test/acm_random.h"
diff --git a/test/frame_size_tests.cc b/test/frame_size_tests.cc
index 843c68bd30f970210110a0fd7166957082b4bda1..1b58fecedf0eebadc2d1a58b23d868dc8f96c88b 100644
--- a/test/frame_size_tests.cc
+++ b/test/frame_size_tests.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/codec_factory.h"
 #include "test/video_source.h"
 
diff --git a/test/function_equivalence_test.h b/test/function_equivalence_test.h
index 472d4ce8627797b09db47dfcfb9acba2286d5d9d..4b22c74a2b30c4f4916678bec1d0e43e569c5ce4 100644
--- a/test/function_equivalence_test.h
+++ b/test/function_equivalence_test.h
@@ -12,7 +12,7 @@
 #ifndef TEST_FUNCTION_EQUIVALENCE_TEST_H_
 #define TEST_FUNCTION_EQUIVALENCE_TEST_H_
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/acm_random.h"
 #include "test/clear_system_state.h"
 #include "test/util.h"
diff --git a/test/hadamard_test.cc b/test/hadamard_test.cc
index 792e0abc4144ff6374a7362a2620b2df987d343b..db5cb7474726e3fbfcea97c77d5934fe307325f0 100644
--- a/test/hadamard_test.cc
+++ b/test/hadamard_test.cc
@@ -11,7 +11,7 @@
 
 #include <algorithm>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_dsp_rtcd.h"
 
diff --git a/test/hbd_metrics_test.cc b/test/hbd_metrics_test.cc
index 455e180be7d4582394db495507a8d1930e383fe6..4def53b215dd371eab6ea33ccbfb02576a7788bf 100644
--- a/test/hbd_metrics_test.cc
+++ b/test/hbd_metrics_test.cc
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <new>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/acm_random.h"
 #include "test/util.h"
 #include "./aom_config.h"
diff --git a/test/idct8x8_test.cc b/test/idct8x8_test.cc
index ff43464f78ed8b98b098a361c44559a2c5eecdc3..f99a4075f8933e4af9c2ae278eab7e79a1c29ee5 100644
--- a/test/idct8x8_test.cc
+++ b/test/idct8x8_test.cc
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_dsp_rtcd.h"
 #include "test/acm_random.h"
diff --git a/test/idct_test.cc b/test/idct_test.cc
index 009f4b0c392f34a3fca101cf161e50acfa747452..a880a91825ad63b2b9fa89b2928596878121bfec 100644
--- a/test/idct_test.cc
+++ b/test/idct_test.cc
@@ -12,7 +12,7 @@
 #include "./aom_config.h"
 #include "./aom_rtcd.h"
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "test/clear_system_state.h"
 #include "test/register_state_check.h"
diff --git a/test/intrapred_test.cc b/test/intrapred_test.cc
index 12eabcffc19567afdec4e38c962a1f101ba7ca45..e3bd763499e9fc49a32b2133b01b2b995014ab44 100644
--- a/test/intrapred_test.cc
+++ b/test/intrapred_test.cc
@@ -11,7 +11,7 @@
 
 #include <string>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/level_test.cc b/test/level_test.cc
index af6355624c3b3849005b1c2aa1708237a7552966..1049d4901e7336a1c450737611becfcee301a6c7 100644
--- a/test/level_test.cc
+++ b/test/level_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/i420_video_source.h"
diff --git a/test/lossless_test.cc b/test/lossless_test.cc
index 9fd5bea3cfdb6b4c0a5298a55c83b9305c807bb9..5c5b32d9320ef2b052e152aba226fb3b98ddf931 100644
--- a/test/lossless_test.cc
+++ b/test/lossless_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #include "test/codec_factory.h"
diff --git a/test/lpf_8_test.cc b/test/lpf_8_test.cc
index dfaaed598037391ba80ae9dc9c10dbda64cc499c..be6afbf69a72c08cb74f5e3a65de2299be823810 100644
--- a/test/lpf_8_test.cc
+++ b/test/lpf_8_test.cc
@@ -13,7 +13,7 @@
 #include <cstdlib>
 #include <string>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/masked_sad_test.cc b/test/masked_sad_test.cc
index 95b4544391660410df32d02c8c280997e4c9ea7a..996f912cb0c59b0bb4934367370c80e26e7d897a 100644
--- a/test/masked_sad_test.cc
+++ b/test/masked_sad_test.cc
@@ -12,7 +12,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/acm_random.h"
 #include "test/clear_system_state.h"
 #include "test/register_state_check.h"
diff --git a/test/masked_variance_test.cc b/test/masked_variance_test.cc
index cecaf275923b673126b27b60d4752a2a1c9d65e5..8515c7e8110c20e5281485b2625e945f8e5bcc45 100644
--- a/test/masked_variance_test.cc
+++ b/test/masked_variance_test.cc
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/acm_random.h"
 #include "test/clear_system_state.h"
 #include "test/register_state_check.h"
diff --git a/test/minmax_test.cc b/test/minmax_test.cc
index 8613f4b280608d014ec3508d60681d766d310dfe..f825291927b08cbc7ba3b086ef67dd958d91cd33 100644
--- a/test/minmax_test.cc
+++ b/test/minmax_test.cc
@@ -12,7 +12,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_dsp_rtcd.h"
 #include "aom/aom_integer.h"
diff --git a/test/obmc_sad_test.cc b/test/obmc_sad_test.cc
index 1814cddb3e5ede0f51b5d5af9cdea4423cc33521..811c35b81ef3d9659b8636a33ed132845d40a1f7 100644
--- a/test/obmc_sad_test.cc
+++ b/test/obmc_sad_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "test/function_equivalence_test.h"
 #include "test/register_state_check.h"
diff --git a/test/obmc_variance_test.cc b/test/obmc_variance_test.cc
index 41e399a16a67b014bd41038b76c718334d8da497..777e8f31893c7f8b6eb62dc37bed7e72f9d3f441 100644
--- a/test/obmc_variance_test.cc
+++ b/test/obmc_variance_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/acm_random.h"
 
 #include "test/function_equivalence_test.h"
diff --git a/test/partial_idct_test.cc b/test/partial_idct_test.cc
index 7eedfaf3cd02c25456da4f47c323438c0cf37f7a..22750c31f1d5ef2bdffc974e60c248a575bec5ad 100644
--- a/test/partial_idct_test.cc
+++ b/test/partial_idct_test.cc
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./av1_rtcd.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/quantize_test.cc b/test/quantize_test.cc
index 4908e995f39749f63834b3c8b484957b64bf8be2..4f61484a269aad2ba87f7b513748c4d77bce03d9 100644
--- a/test/quantize_test.cc
+++ b/test/quantize_test.cc
@@ -11,7 +11,7 @@
 
 #include <string.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #include "test/acm_random.h"
diff --git a/test/realtime_test.cc b/test/realtime_test.cc
index f6f3f52b89dd315fc1ead5c36a904f0969694188..ffe4a3146b78e9caf48cb67713ff659f4b2d1092 100644
--- a/test/realtime_test.cc
+++ b/test/realtime_test.cc
@@ -13,7 +13,7 @@
 #include "test/encode_test_driver.h"
 #include "test/util.h"
 #include "test/video_source.h"
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 namespace {
 
diff --git a/test/register_state_check.h b/test/register_state_check.h
index 3ff41d1bc4d1841faa2c265c9be570618dbec57a..33082017398974fb0b1b05a558401d6cc5fd377d 100644
--- a/test/register_state_check.h
+++ b/test/register_state_check.h
@@ -12,7 +12,7 @@
 #ifndef TEST_REGISTER_STATE_CHECK_H_
 #define TEST_REGISTER_STATE_CHECK_H_
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "./aom_config.h"
 #include "aom/aom_integer.h"
 
diff --git a/test/resize_test.cc b/test/resize_test.cc
index 9cee841a035e433566127cac1360643bc612050e..9932e99aad05e75eb7ff5937d270928163d62970 100644
--- a/test/resize_test.cc
+++ b/test/resize_test.cc
@@ -11,7 +11,7 @@
 
 #include <climits>
 #include <vector>
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/i420_video_source.h"
diff --git a/test/sad_test.cc b/test/sad_test.cc
index bacf539362645021fef753c6f7e3a5c829d6c785..ef637fb16b5cfefe3e9fe20f82092ad30cf60d57 100644
--- a/test/sad_test.cc
+++ b/test/sad_test.cc
@@ -13,7 +13,7 @@
 #include <limits.h>
 #include <stdio.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/scan_test.cc b/test/scan_test.cc
index 57248838a69120445dbd80b163df578e228ddb0a..16c831c8ea8fbeb7fd1fb8be2579afe1542a3d42 100644
--- a/test/scan_test.cc
+++ b/test/scan_test.cc
@@ -11,7 +11,7 @@
 
 #include "av1/common/common_data.h"
 #include "av1/common/scan.h"
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 namespace {
 
diff --git a/test/simd_impl.h b/test/simd_impl.h
index 26a8c673b463d121ef99d46ebaa4aa3750c1fee5..dd09c88c7599fc31468f4595c7e81e0c90fd8b69 100644
--- a/test/simd_impl.h
+++ b/test/simd_impl.h
@@ -10,7 +10,7 @@
 */
 
 #define SIMD_CHECK 1
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/clear_system_state.h"
 #include "test/register_state_check.h"
 #include "aom_dsp/aom_simd_inline.h"
diff --git a/test/subtract_test.cc b/test/subtract_test.cc
index d1b51864e1cdf6a4ac67ab09ee3ee9d9bb9ae8ca..202594c481de323a62930f7954f8b8505776759a 100644
--- a/test/subtract_test.cc
+++ b/test/subtract_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/sum_squares_test.cc b/test/sum_squares_test.cc
index 943b28fd4043ef20ee6519a02fbb47e68d6e7a08..5f23a9970393b7d501f10dbc4c608c57f3aa5997 100644
--- a/test/sum_squares_test.cc
+++ b/test/sum_squares_test.cc
@@ -13,7 +13,7 @@
 #include <cstdlib>
 #include <string>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/superframe_test.cc b/test/superframe_test.cc
index e9b78269980a7f966f9f0e19bc8942fd848534b0..0f54baeaf4d3365db65675e7a9c9891341bbbd09 100644
--- a/test/superframe_test.cc
+++ b/test/superframe_test.cc
@@ -10,7 +10,7 @@
 */
 
 #include <climits>
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/i420_video_source.h"
diff --git a/test/test_intra_pred_speed.cc b/test/test_intra_pred_speed.cc
index ce4b3c1d24080eb25c55a45bdfdb649454eadddc..5c8c554c406ba05e0355081f910f2adf5afdd8b5 100644
--- a/test/test_intra_pred_speed.cc
+++ b/test/test_intra_pred_speed.cc
@@ -14,7 +14,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_dsp_rtcd.h"
 #include "test/acm_random.h"
diff --git a/test/test_libaom.cc b/test/test_libaom.cc
index 745ee631e723f8515906031bb40bb228d2e72704..6d83ce66e74a270ed0336c6fa884845b268e2b7d 100644
--- a/test/test_libaom.cc
+++ b/test/test_libaom.cc
@@ -11,7 +11,7 @@
 
 #include <string>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #if ARCH_X86 || ARCH_X86_64
diff --git a/test/tile_independence_test.cc b/test/tile_independence_test.cc
index f5f843648d6532723a01885238df0ab82bd6a4ef..a98faff69b167bf41c077ce3605150e9b6c74e5c 100644
--- a/test/tile_independence_test.cc
+++ b/test/tile_independence_test.cc
@@ -12,7 +12,7 @@
 #include <cstdio>
 #include <cstdlib>
 #include <string>
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/i420_video_source.h"
diff --git a/test/user_priv_test.cc b/test/user_priv_test.cc
index 11657fb8f4bab7157636ed1e025b11bbb89adf7e..3052b27b1cf006ef25c8708d5e958fa2fcbb5d57 100644
--- a/test/user_priv_test.cc
+++ b/test/user_priv_test.cc
@@ -12,7 +12,7 @@
 #include <cstdio>
 #include <cstdlib>
 #include <string>
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "./aom_config.h"
 #include "test/acm_random.h"
 #include "test/codec_factory.h"
diff --git a/test/util.h b/test/util.h
index f63fda100ff70180cfb17a996392db2cd01efe7d..a20fab65cca74e240daf3a1310fd9003a5d3bb42 100644
--- a/test/util.h
+++ b/test/util.h
@@ -14,7 +14,7 @@
 
 #include <stdio.h>
 #include <math.h>
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "aom/aom_image.h"
 
 // Macros
diff --git a/test/variance_test.cc b/test/variance_test.cc
index 7848e20f323dc6fcfe47c902345ec0ac8aa0f771..2ae9bd9ffda84a88e60b2b45c2c1a28991e5c27f 100644
--- a/test/variance_test.cc
+++ b/test/variance_test.cc
@@ -12,7 +12,7 @@
 #include <cstdlib>
 #include <new>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/warp_filter_test.cc b/test/warp_filter_test.cc
index 7e7aba6b93f28debefa62dd9aaa55b1136da0737..9dfee61006e99993a72de1403bc49fd3bc5225ee 100644
--- a/test/warp_filter_test.cc
+++ b/test/warp_filter_test.cc
@@ -9,7 +9,7 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./av1_rtcd.h"
 #include "./aom_dsp_rtcd.h"
diff --git a/test/y4m_test.cc b/test/y4m_test.cc
index c4755f78decd629898fdc0c96d11a393f660c503..fc9fff5142880786951fae31b561106cb900defa 100644
--- a/test/y4m_test.cc
+++ b/test/y4m_test.cc
@@ -11,7 +11,7 @@
 
 #include <string>
 
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
 #include "./y4menc.h"
diff --git a/third_party/googletest/gtest.mk b/third_party/googletest/gtest.mk
index 0de3113c7a50608c7a7a895e22a5ecaffaaf136a..fc4dbdc24019a613e9911332c3e67f0782b97a12 100644
--- a/third_party/googletest/gtest.mk
+++ b/third_party/googletest/gtest.mk
@@ -1 +1 @@
-GTEST_SRCS-yes += src/gtest-all.cc 
+GTEST_SRCS-yes += googletest/src/googletest/src/gtest-all.cc
diff --git a/third_party/googletest/src/.gitignore b/third_party/googletest/src/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..ce310bc3579d9ee6007fefd4fc8ed58575bcf1bd
--- /dev/null
+++ b/third_party/googletest/src/.gitignore
@@ -0,0 +1,2 @@
+# Ignore CI build directory
+build/
diff --git a/third_party/googletest/src/.travis.yml b/third_party/googletest/src/.travis.yml
new file mode 100644
index 0000000000000000000000000000000000000000..3204dfac17d7ce6b1f475c1acaea4ea9df382b71
--- /dev/null
+++ b/third_party/googletest/src/.travis.yml
@@ -0,0 +1,46 @@
+# Build matrix / environment variable are explained on:
+# http://about.travis-ci.org/docs/user/build-configuration/
+# This file can be validated on:
+# http://lint.travis-ci.org/
+
+install:
+# /usr/bin/gcc is 4.6 always, but gcc-X.Y is available.
+- if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi
+# /usr/bin/clang is 3.4, lets override with modern one.
+- if [ "$CXX" = "clang++" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi
+- echo ${PATH}
+- echo ${CXX}
+- ${CXX} --version
+- ${CXX} -v
+addons:
+  apt:
+    # List of whitelisted in travis packages for ubuntu-precise can be found here:
+    #   https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise
+    # List of whitelisted in travis apt-sources:
+    #   https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json
+    sources:
+    - ubuntu-toolchain-r-test
+    - llvm-toolchain-precise-3.7
+    packages:
+    - gcc-4.9
+    - g++-4.9
+    - clang-3.7
+    - valgrind
+os:
+  - linux
+  - osx
+language: cpp
+compiler:
+  - gcc
+  - clang
+script: ./travis.sh
+env:
+  matrix:
+    - GTEST_TARGET=googletest SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug   VERBOSE_MAKE=true VERBOSE
+    - GTEST_TARGET=googlemock SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug   VERBOSE_MAKE=true VERBOSE
+    - GTEST_TARGET=googlemock SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug CXX_FLAGS=-std=c++11  VERBOSE_MAKE=true VERBOSE
+#    - GTEST_TARGET=googletest SHARED_LIB=ON  STATIC_LIB=ON CMAKE_PKG=ON  BUILD_TYPE=release VERBOSE_MAKE=false
+#    - GTEST_TARGET=googlemock SHARED_LIB=ON  STATIC_LIB=ON CMAKE_PKG=ON  BUILD_TYPE=release VERBOSE_MAKE=false
+notifications:
+  email: false
+sudo: false
diff --git a/third_party/googletest/src/googletest/.gitignore b/third_party/googletest/src/googletest/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..4b7be4b91b701db9f3f89891e0bdb1279fb153b6
--- /dev/null
+++ b/third_party/googletest/src/googletest/.gitignore
@@ -0,0 +1,2 @@
+# python
+*.pyc
diff --git a/third_party/googletest/src/CHANGES b/third_party/googletest/src/googletest/CHANGES
similarity index 100%
rename from third_party/googletest/src/CHANGES
rename to third_party/googletest/src/googletest/CHANGES
diff --git a/third_party/googletest/src/googletest/CMakeLists.txt b/third_party/googletest/src/googletest/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..621d0f0421543eba41e1d69f497814104bb9c6a7
--- /dev/null
+++ b/third_party/googletest/src/googletest/CMakeLists.txt
@@ -0,0 +1,286 @@
+########################################################################
+# CMake build script for Google Test.
+#
+# To run the tests for Google Test itself on Linux, use 'make test' or
+# ctest.  You can select which tests to run using 'ctest -R regex'.
+# For more options, run 'ctest --help'.
+
+# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to
+# make it prominent in the GUI.
+option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF)
+
+# When other libraries are using a shared version of runtime libraries,
+# Google Test also has to use one.
+option(
+  gtest_force_shared_crt
+  "Use shared (DLL) run-time lib even when Google Test is built as static lib."
+  OFF)
+
+option(gtest_build_tests "Build all of gtest's own tests." OFF)
+
+option(gtest_build_samples "Build gtest's sample programs." OFF)
+
+option(gtest_disable_pthreads "Disable uses of pthreads in gtest." OFF)
+
+option(
+  gtest_hide_internal_symbols
+  "Build gtest with internal symbols hidden in shared libraries."
+  OFF)
+
+# Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build().
+include(cmake/hermetic_build.cmake OPTIONAL)
+
+if (COMMAND pre_project_set_up_hermetic_build)
+  pre_project_set_up_hermetic_build()
+endif()
+
+########################################################################
+#
+# Project-wide settings
+
+# Name of the project.
+#
+# CMake files in this project can refer to the root source directory
+# as ${gtest_SOURCE_DIR} and to the root binary directory as
+# ${gtest_BINARY_DIR}.
+# Language "C" is required for find_package(Threads).
+project(gtest CXX C)
+cmake_minimum_required(VERSION 2.6.2)
+
+if (COMMAND set_up_hermetic_build)
+  set_up_hermetic_build()
+endif()
+
+if (gtest_hide_internal_symbols)
+  set(CMAKE_CXX_VISIBILITY_PRESET hidden)
+  set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
+endif()
+
+# Define helper functions and macros used by Google Test.
+include(cmake/internal_utils.cmake)
+
+config_compiler_and_linker()  # Defined in internal_utils.cmake.
+
+# Where Google Test's .h files can be found.
+include_directories(
+  ${gtest_SOURCE_DIR}/include
+  ${gtest_SOURCE_DIR})
+
+# Where Google Test's libraries can be found.
+link_directories(${gtest_BINARY_DIR}/src)
+
+# Summary of tuple support for Microsoft Visual Studio:
+# Compiler    version(MS)  version(cmake)  Support
+# ----------  -----------  --------------  -----------------------------
+# <= VS 2010  <= 10        <= 1600         Use Google Tests's own tuple.
+# VS 2012     11           1700            std::tr1::tuple + _VARIADIC_MAX=10
+# VS 2013     12           1800            std::tr1::tuple
+if (MSVC AND MSVC_VERSION EQUAL 1700)
+  add_definitions(/D _VARIADIC_MAX=10)
+endif()
+
+########################################################################
+#
+# Defines the gtest & gtest_main libraries.  User tests should link
+# with one of them.
+
+# Google Test libraries.  We build them using more strict warnings than what
+# are used for other targets, to ensure that gtest can be compiled by a user
+# aggressive about warnings.
+cxx_library(gtest "${cxx_strict}" src/gtest-all.cc)
+cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc)
+target_link_libraries(gtest_main gtest)
+
+# If the CMake version supports it, attach header directory information
+# to the targets for when we are part of a parent build (ie being pulled
+# in via add_subdirectory() rather than being a standalone build).
+if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
+  target_include_directories(gtest      INTERFACE "${gtest_SOURCE_DIR}/include")
+  target_include_directories(gtest_main INTERFACE "${gtest_SOURCE_DIR}/include")
+endif()
+
+########################################################################
+#
+# Install rules
+install(TARGETS gtest gtest_main
+  DESTINATION lib)
+install(DIRECTORY ${gtest_SOURCE_DIR}/include/gtest
+  DESTINATION include)
+
+########################################################################
+#
+# Samples on how to link user tests with gtest or gtest_main.
+#
+# They are not built by default.  To build them, set the
+# gtest_build_samples option to ON.  You can do it by running ccmake
+# or specifying the -Dgtest_build_samples=ON flag when running cmake.
+
+if (gtest_build_samples)
+  cxx_executable(sample1_unittest samples gtest_main samples/sample1.cc)
+  cxx_executable(sample2_unittest samples gtest_main samples/sample2.cc)
+  cxx_executable(sample3_unittest samples gtest_main)
+  cxx_executable(sample4_unittest samples gtest_main samples/sample4.cc)
+  cxx_executable(sample5_unittest samples gtest_main samples/sample1.cc)
+  cxx_executable(sample6_unittest samples gtest_main)
+  cxx_executable(sample7_unittest samples gtest_main)
+  cxx_executable(sample8_unittest samples gtest_main)
+  cxx_executable(sample9_unittest samples gtest)
+  cxx_executable(sample10_unittest samples gtest)
+endif()
+
+########################################################################
+#
+# Google Test's own tests.
+#
+# You can skip this section if you aren't interested in testing
+# Google Test itself.
+#
+# The tests are not built by default.  To build them, set the
+# gtest_build_tests option to ON.  You can do it by running ccmake
+# or specifying the -Dgtest_build_tests=ON flag when running cmake.
+
+if (gtest_build_tests)
+  # This must be set in the root directory for the tests to be run by
+  # 'make test' or ctest.
+  enable_testing()
+
+  ############################################################
+  # C++ tests built with standard compiler flags.
+
+  cxx_test(gtest-death-test_test gtest_main)
+  cxx_test(gtest_environment_test gtest)
+  cxx_test(gtest-filepath_test gtest_main)
+  cxx_test(gtest-linked_ptr_test gtest_main)
+  cxx_test(gtest-listener_test gtest_main)
+  cxx_test(gtest_main_unittest gtest_main)
+  cxx_test(gtest-message_test gtest_main)
+  cxx_test(gtest_no_test_unittest gtest)
+  cxx_test(gtest-options_test gtest_main)
+  cxx_test(gtest-param-test_test gtest
+    test/gtest-param-test2_test.cc)
+  cxx_test(gtest-port_test gtest_main)
+  cxx_test(gtest_pred_impl_unittest gtest_main)
+  cxx_test(gtest_premature_exit_test gtest
+    test/gtest_premature_exit_test.cc)
+  cxx_test(gtest-printers_test gtest_main)
+  cxx_test(gtest_prod_test gtest_main
+    test/production.cc)
+  cxx_test(gtest_repeat_test gtest)
+  cxx_test(gtest_sole_header_test gtest_main)
+  cxx_test(gtest_stress_test gtest)
+  cxx_test(gtest-test-part_test gtest_main)
+  cxx_test(gtest_throw_on_failure_ex_test gtest)
+  cxx_test(gtest-typed-test_test gtest_main
+    test/gtest-typed-test2_test.cc)
+  cxx_test(gtest_unittest gtest_main)
+  cxx_test(gtest-unittest-api_test gtest)
+
+  ############################################################
+  # C++ tests built with non-standard compiler flags.
+
+  # MSVC 7.1 does not support STL with exceptions disabled.
+  if (NOT MSVC OR MSVC_VERSION GREATER 1310)
+    cxx_library(gtest_no_exception "${cxx_no_exception}"
+      src/gtest-all.cc)
+    cxx_library(gtest_main_no_exception "${cxx_no_exception}"
+      src/gtest-all.cc src/gtest_main.cc)
+  endif()
+  cxx_library(gtest_main_no_rtti "${cxx_no_rtti}"
+    src/gtest-all.cc src/gtest_main.cc)
+
+  cxx_test_with_flags(gtest-death-test_ex_nocatch_test
+    "${cxx_exception} -DGTEST_ENABLE_CATCH_EXCEPTIONS_=0"
+    gtest test/gtest-death-test_ex_test.cc)
+  cxx_test_with_flags(gtest-death-test_ex_catch_test
+    "${cxx_exception} -DGTEST_ENABLE_CATCH_EXCEPTIONS_=1"
+    gtest test/gtest-death-test_ex_test.cc)
+
+  cxx_test_with_flags(gtest_no_rtti_unittest "${cxx_no_rtti}"
+    gtest_main_no_rtti test/gtest_unittest.cc)
+
+  cxx_shared_library(gtest_dll "${cxx_default}"
+    src/gtest-all.cc src/gtest_main.cc)
+
+  cxx_executable_with_flags(gtest_dll_test_ "${cxx_default}"
+    gtest_dll test/gtest_all_test.cc)
+  set_target_properties(gtest_dll_test_
+                        PROPERTIES
+                        COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
+
+  if (NOT MSVC OR MSVC_VERSION LESS 1600)  # 1600 is Visual Studio 2010.
+    # Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that
+    # conflict with our own definitions. Therefore using our own tuple does not
+    # work on those compilers.
+    cxx_library(gtest_main_use_own_tuple "${cxx_use_own_tuple}"
+      src/gtest-all.cc src/gtest_main.cc)
+
+    cxx_test_with_flags(gtest-tuple_test "${cxx_use_own_tuple}"
+      gtest_main_use_own_tuple test/gtest-tuple_test.cc)
+
+    cxx_test_with_flags(gtest_use_own_tuple_test "${cxx_use_own_tuple}"
+      gtest_main_use_own_tuple
+      test/gtest-param-test_test.cc test/gtest-param-test2_test.cc)
+  endif()
+
+  ############################################################
+  # Python tests.
+
+  cxx_executable(gtest_break_on_failure_unittest_ test gtest)
+  py_test(gtest_break_on_failure_unittest)
+
+  # Visual Studio .NET 2003 does not support STL with exceptions disabled.
+  if (NOT MSVC OR MSVC_VERSION GREATER 1310)  # 1310 is Visual Studio .NET 2003
+    cxx_executable_with_flags(
+      gtest_catch_exceptions_no_ex_test_
+      "${cxx_no_exception}"
+      gtest_main_no_exception
+      test/gtest_catch_exceptions_test_.cc)
+  endif()
+
+  cxx_executable_with_flags(
+    gtest_catch_exceptions_ex_test_
+    "${cxx_exception}"
+    gtest_main
+    test/gtest_catch_exceptions_test_.cc)
+  py_test(gtest_catch_exceptions_test)
+
+  cxx_executable(gtest_color_test_ test gtest)
+  py_test(gtest_color_test)
+
+  cxx_executable(gtest_env_var_test_ test gtest)
+  py_test(gtest_env_var_test)
+
+  cxx_executable(gtest_filter_unittest_ test gtest)
+  py_test(gtest_filter_unittest)
+
+  cxx_executable(gtest_help_test_ test gtest_main)
+  py_test(gtest_help_test)
+
+  cxx_executable(gtest_list_tests_unittest_ test gtest)
+  py_test(gtest_list_tests_unittest)
+
+  cxx_executable(gtest_output_test_ test gtest)
+  py_test(gtest_output_test)
+
+  cxx_executable(gtest_shuffle_test_ test gtest)
+  py_test(gtest_shuffle_test)
+
+  # MSVC 7.1 does not support STL with exceptions disabled.
+  if (NOT MSVC OR MSVC_VERSION GREATER 1310)
+    cxx_executable(gtest_throw_on_failure_test_ test gtest_no_exception)
+    set_target_properties(gtest_throw_on_failure_test_
+      PROPERTIES
+      COMPILE_FLAGS "${cxx_no_exception}")
+    py_test(gtest_throw_on_failure_test)
+  endif()
+
+  cxx_executable(gtest_uninitialized_test_ test gtest)
+  py_test(gtest_uninitialized_test)
+
+  cxx_executable(gtest_xml_outfile1_test_ test gtest_main)
+  cxx_executable(gtest_xml_outfile2_test_ test gtest_main)
+  py_test(gtest_xml_outfiles_test)
+
+  cxx_executable(gtest_xml_output_unittest_ test gtest)
+  py_test(gtest_xml_output_unittest)
+endif()
diff --git a/third_party/googletest/src/CONTRIBUTORS b/third_party/googletest/src/googletest/CONTRIBUTORS
similarity index 100%
rename from third_party/googletest/src/CONTRIBUTORS
rename to third_party/googletest/src/googletest/CONTRIBUTORS
diff --git a/third_party/googletest/src/LICENSE b/third_party/googletest/src/googletest/LICENSE
similarity index 100%
rename from third_party/googletest/src/LICENSE
rename to third_party/googletest/src/googletest/LICENSE
diff --git a/third_party/googletest/src/googletest/Makefile.am b/third_party/googletest/src/googletest/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..29797e4e9de4e1d5e5f93bba14288de87f623946
--- /dev/null
+++ b/third_party/googletest/src/googletest/Makefile.am
@@ -0,0 +1,310 @@
+# Automake file
+
+ACLOCAL_AMFLAGS = -I m4
+
+# Nonstandard package files for distribution
+EXTRA_DIST = \
+  CHANGES \
+  CONTRIBUTORS \
+  LICENSE \
+  include/gtest/gtest-param-test.h.pump \
+  include/gtest/internal/gtest-param-util-generated.h.pump \
+  include/gtest/internal/gtest-tuple.h.pump \
+  include/gtest/internal/gtest-type-util.h.pump \
+  make/Makefile \
+  scripts/fuse_gtest_files.py \
+  scripts/gen_gtest_pred_impl.py \
+  scripts/pump.py \
+  scripts/test/Makefile
+
+# gtest source files that we don't compile directly.  They are
+# #included by gtest-all.cc.
+GTEST_SRC = \
+  src/gtest-death-test.cc \
+  src/gtest-filepath.cc \
+  src/gtest-internal-inl.h \
+  src/gtest-port.cc \
+  src/gtest-printers.cc \
+  src/gtest-test-part.cc \
+  src/gtest-typed-test.cc \
+  src/gtest.cc
+
+EXTRA_DIST += $(GTEST_SRC)
+
+# Sample files that we don't compile.
+EXTRA_DIST += \
+  samples/prime_tables.h \
+  samples/sample2_unittest.cc \
+  samples/sample3_unittest.cc \
+  samples/sample4_unittest.cc \
+  samples/sample5_unittest.cc \
+  samples/sample6_unittest.cc \
+  samples/sample7_unittest.cc \
+  samples/sample8_unittest.cc \
+  samples/sample9_unittest.cc
+
+# C++ test files that we don't compile directly.
+EXTRA_DIST += \
+  test/gtest-death-test_ex_test.cc \
+  test/gtest-death-test_test.cc \
+  test/gtest-filepath_test.cc \
+  test/gtest-linked_ptr_test.cc \
+  test/gtest-listener_test.cc \
+  test/gtest-message_test.cc \
+  test/gtest-options_test.cc \
+  test/gtest-param-test2_test.cc \
+  test/gtest-param-test2_test.cc \
+  test/gtest-param-test_test.cc \
+  test/gtest-param-test_test.cc \
+  test/gtest-param-test_test.h \
+  test/gtest-port_test.cc \
+  test/gtest_premature_exit_test.cc \
+  test/gtest-printers_test.cc \
+  test/gtest-test-part_test.cc \
+  test/gtest-tuple_test.cc \
+  test/gtest-typed-test2_test.cc \
+  test/gtest-typed-test_test.cc \
+  test/gtest-typed-test_test.h \
+  test/gtest-unittest-api_test.cc \
+  test/gtest_break_on_failure_unittest_.cc \
+  test/gtest_catch_exceptions_test_.cc \
+  test/gtest_color_test_.cc \
+  test/gtest_env_var_test_.cc \
+  test/gtest_environment_test.cc \
+  test/gtest_filter_unittest_.cc \
+  test/gtest_help_test_.cc \
+  test/gtest_list_tests_unittest_.cc \
+  test/gtest_main_unittest.cc \
+  test/gtest_no_test_unittest.cc \
+  test/gtest_output_test_.cc \
+  test/gtest_pred_impl_unittest.cc \
+  test/gtest_prod_test.cc \
+  test/gtest_repeat_test.cc \
+  test/gtest_shuffle_test_.cc \
+  test/gtest_sole_header_test.cc \
+  test/gtest_stress_test.cc \
+  test/gtest_throw_on_failure_ex_test.cc \
+  test/gtest_throw_on_failure_test_.cc \
+  test/gtest_uninitialized_test_.cc \
+  test/gtest_unittest.cc \
+  test/gtest_unittest.cc \
+  test/gtest_xml_outfile1_test_.cc \
+  test/gtest_xml_outfile2_test_.cc \
+  test/gtest_xml_output_unittest_.cc \
+  test/production.cc \
+  test/production.h
+
+# Python tests that we don't run.
+EXTRA_DIST += \
+  test/gtest_break_on_failure_unittest.py \
+  test/gtest_catch_exceptions_test.py \
+  test/gtest_color_test.py \
+  test/gtest_env_var_test.py \
+  test/gtest_filter_unittest.py \
+  test/gtest_help_test.py \
+  test/gtest_list_tests_unittest.py \
+  test/gtest_output_test.py \
+  test/gtest_output_test_golden_lin.txt \
+  test/gtest_shuffle_test.py \
+  test/gtest_test_utils.py \
+  test/gtest_throw_on_failure_test.py \
+  test/gtest_uninitialized_test.py \
+  test/gtest_xml_outfiles_test.py \
+  test/gtest_xml_output_unittest.py \
+  test/gtest_xml_test_utils.py
+
+# CMake script
+EXTRA_DIST += \
+  CMakeLists.txt \
+  cmake/internal_utils.cmake
+
+# MSVC project files
+EXTRA_DIST += \
+  msvc/gtest-md.sln \
+  msvc/gtest-md.vcproj \
+  msvc/gtest.sln \
+  msvc/gtest.vcproj \
+  msvc/gtest_main-md.vcproj \
+  msvc/gtest_main.vcproj \
+  msvc/gtest_prod_test-md.vcproj \
+  msvc/gtest_prod_test.vcproj \
+  msvc/gtest_unittest-md.vcproj \
+  msvc/gtest_unittest.vcproj
+
+# xcode project files
+EXTRA_DIST += \
+  xcode/Config/DebugProject.xcconfig \
+  xcode/Config/FrameworkTarget.xcconfig \
+  xcode/Config/General.xcconfig \
+  xcode/Config/ReleaseProject.xcconfig \
+  xcode/Config/StaticLibraryTarget.xcconfig \
+  xcode/Config/TestTarget.xcconfig \
+  xcode/Resources/Info.plist \
+  xcode/Scripts/runtests.sh \
+  xcode/Scripts/versiongenerate.py \
+  xcode/gtest.xcodeproj/project.pbxproj
+
+# xcode sample files
+EXTRA_DIST += \
+  xcode/Samples/FrameworkSample/Info.plist \
+  xcode/Samples/FrameworkSample/WidgetFramework.xcodeproj/project.pbxproj \
+  xcode/Samples/FrameworkSample/runtests.sh \
+  xcode/Samples/FrameworkSample/widget.cc \
+  xcode/Samples/FrameworkSample/widget.h \
+  xcode/Samples/FrameworkSample/widget_test.cc
+
+# C++Builder project files
+EXTRA_DIST += \
+  codegear/gtest.cbproj \
+  codegear/gtest.groupproj \
+  codegear/gtest_all.cc \
+  codegear/gtest_link.cc \
+  codegear/gtest_main.cbproj \
+  codegear/gtest_unittest.cbproj
+
+# Distribute and install M4 macro
+m4datadir = $(datadir)/aclocal
+m4data_DATA = m4/gtest.m4
+EXTRA_DIST += $(m4data_DATA)
+
+# We define the global AM_CPPFLAGS as everything we compile includes from these
+# directories.
+AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/include
+
+# Modifies compiler and linker flags for pthreads compatibility.
+if HAVE_PTHREADS
+  AM_CXXFLAGS = @PTHREAD_CFLAGS@ -DGTEST_HAS_PTHREAD=1
+  AM_LIBS = @PTHREAD_LIBS@
+else
+  AM_CXXFLAGS = -DGTEST_HAS_PTHREAD=0
+endif
+
+# Build rules for libraries.
+lib_LTLIBRARIES = lib/libgtest.la lib/libgtest_main.la
+
+lib_libgtest_la_SOURCES = src/gtest-all.cc
+
+pkginclude_HEADERS = \
+  include/gtest/gtest-death-test.h \
+  include/gtest/gtest-message.h \
+  include/gtest/gtest-param-test.h \
+  include/gtest/gtest-printers.h \
+  include/gtest/gtest-spi.h \
+  include/gtest/gtest-test-part.h \
+  include/gtest/gtest-typed-test.h \
+  include/gtest/gtest.h \
+  include/gtest/gtest_pred_impl.h \
+  include/gtest/gtest_prod.h
+
+pkginclude_internaldir = $(pkgincludedir)/internal
+pkginclude_internal_HEADERS = \
+  include/gtest/internal/gtest-death-test-internal.h \
+  include/gtest/internal/gtest-filepath.h \
+  include/gtest/internal/gtest-internal.h \
+  include/gtest/internal/gtest-linked_ptr.h \
+  include/gtest/internal/gtest-param-util-generated.h \
+  include/gtest/internal/gtest-param-util.h \
+  include/gtest/internal/gtest-port.h \
+  include/gtest/internal/gtest-port-arch.h \
+  include/gtest/internal/gtest-string.h \
+  include/gtest/internal/gtest-tuple.h \
+  include/gtest/internal/gtest-type-util.h \
+  include/gtest/internal/custom/gtest.h \
+  include/gtest/internal/custom/gtest-port.h \
+  include/gtest/internal/custom/gtest-printers.h
+
+lib_libgtest_main_la_SOURCES = src/gtest_main.cc
+lib_libgtest_main_la_LIBADD = lib/libgtest.la
+
+# Bulid rules for samples and tests. Automake's naming for some of
+# these variables isn't terribly obvious, so this is a brief
+# reference:
+#
+# TESTS -- Programs run automatically by "make check"
+# check_PROGRAMS -- Programs built by "make check" but not necessarily run
+
+noinst_LTLIBRARIES = samples/libsamples.la
+
+samples_libsamples_la_SOURCES = \
+  samples/sample1.cc \
+  samples/sample1.h \
+  samples/sample2.cc \
+  samples/sample2.h \
+  samples/sample3-inl.h \
+  samples/sample4.cc \
+  samples/sample4.h
+
+TESTS=
+TESTS_ENVIRONMENT = GTEST_SOURCE_DIR="$(srcdir)/test" \
+                    GTEST_BUILD_DIR="$(top_builddir)/test"
+check_PROGRAMS=
+
+# A simple sample on using gtest.
+TESTS += samples/sample1_unittest
+check_PROGRAMS += samples/sample1_unittest
+samples_sample1_unittest_SOURCES = samples/sample1_unittest.cc
+samples_sample1_unittest_LDADD = lib/libgtest_main.la \
+                                 lib/libgtest.la \
+                                 samples/libsamples.la
+
+# Another sample.  It also verifies that libgtest works.
+TESTS += samples/sample10_unittest
+check_PROGRAMS += samples/sample10_unittest
+samples_sample10_unittest_SOURCES = samples/sample10_unittest.cc
+samples_sample10_unittest_LDADD = lib/libgtest.la
+
+# This tests most constructs of gtest and verifies that libgtest_main
+# and libgtest work.
+TESTS += test/gtest_all_test
+check_PROGRAMS += test/gtest_all_test
+test_gtest_all_test_SOURCES = test/gtest_all_test.cc
+test_gtest_all_test_LDADD = lib/libgtest_main.la \
+                            lib/libgtest.la
+
+# Tests that fused gtest files compile and work.
+FUSED_GTEST_SRC = \
+  fused-src/gtest/gtest-all.cc \
+  fused-src/gtest/gtest.h \
+  fused-src/gtest/gtest_main.cc
+
+if HAVE_PYTHON
+TESTS += test/fused_gtest_test
+check_PROGRAMS += test/fused_gtest_test
+test_fused_gtest_test_SOURCES = $(FUSED_GTEST_SRC) \
+                                samples/sample1.cc samples/sample1_unittest.cc
+test_fused_gtest_test_CPPFLAGS = -I"$(srcdir)/fused-src"
+
+# Build rules for putting fused Google Test files into the distribution
+# package. The user can also create those files by manually running
+# scripts/fuse_gtest_files.py.
+$(test_fused_gtest_test_SOURCES): fused-gtest
+
+fused-gtest: $(pkginclude_HEADERS) $(pkginclude_internal_HEADERS) \
+             $(GTEST_SRC) src/gtest-all.cc src/gtest_main.cc \
+             scripts/fuse_gtest_files.py
+	mkdir -p "$(srcdir)/fused-src"
+	chmod -R u+w "$(srcdir)/fused-src"
+	rm -f "$(srcdir)/fused-src/gtest/gtest-all.cc"
+	rm -f "$(srcdir)/fused-src/gtest/gtest.h"
+	"$(srcdir)/scripts/fuse_gtest_files.py" "$(srcdir)/fused-src"
+	cp -f "$(srcdir)/src/gtest_main.cc" "$(srcdir)/fused-src/gtest/"
+
+maintainer-clean-local:
+	rm -rf "$(srcdir)/fused-src"
+endif
+
+# Death tests may produce core dumps in the build directory. In case
+# this happens, clean them to keep distcleancheck happy.
+CLEANFILES = core
+
+# Disables 'make install' as installing a compiled version of Google
+# Test can lead to undefined behavior due to violation of the
+# One-Definition Rule.
+
+install-exec-local:
+	echo "'make install' is dangerous and not supported. Instead, see README for how to integrate Google Test into your build system."
+	false
+
+install-data-local:
+	echo "'make install' is dangerous and not supported. Instead, see README for how to integrate Google Test into your build system."
+	false
diff --git a/third_party/googletest/src/README.md b/third_party/googletest/src/googletest/README.md
similarity index 100%
rename from third_party/googletest/src/README.md
rename to third_party/googletest/src/googletest/README.md
diff --git a/third_party/googletest/src/googletest/cmake/internal_utils.cmake b/third_party/googletest/src/googletest/cmake/internal_utils.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..777b91ed4b8caa226ea55cfa61fe7ec433ffb452
--- /dev/null
+++ b/third_party/googletest/src/googletest/cmake/internal_utils.cmake
@@ -0,0 +1,254 @@
+# Defines functions and macros useful for building Google Test and
+# Google Mock.
+#
+# Note:
+#
+# - This file will be run twice when building Google Mock (once via
+#   Google Test's CMakeLists.txt, and once via Google Mock's).
+#   Therefore it shouldn't have any side effects other than defining
+#   the functions and macros.
+#
+# - The functions/macros defined in this file may depend on Google
+#   Test and Google Mock's option() definitions, and thus must be
+#   called *after* the options have been defined.
+
+# Tweaks CMake's default compiler/linker settings to suit Google Test's needs.
+#
+# This must be a macro(), as inside a function string() can only
+# update variables in the function scope.
+macro(fix_default_compiler_settings_)
+  if (MSVC)
+    # For MSVC, CMake sets certain flags to defaults we want to override.
+    # This replacement code is taken from sample in the CMake Wiki at
+    # http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace.
+    foreach (flag_var
+             CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+             CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+      if (NOT BUILD_SHARED_LIBS AND NOT gtest_force_shared_crt)
+        # When Google Test is built as a shared library, it should also use
+        # shared runtime libraries.  Otherwise, it may end up with multiple
+        # copies of runtime library data in different modules, resulting in
+        # hard-to-find crashes. When it is built as a static library, it is
+        # preferable to use CRT as static libraries, as we don't have to rely
+        # on CRT DLLs being available. CMake always defaults to using shared
+        # CRT libraries, so we override that default here.
+        string(REPLACE "/MD" "-MT" ${flag_var} "${${flag_var}}")
+      endif()
+
+      # We prefer more strict warning checking for building Google Test.
+      # Replaces /W3 with /W4 in defaults.
+      string(REPLACE "/W3" "/W4" ${flag_var} "${${flag_var}}")
+    endforeach()
+  endif()
+endmacro()
+
+# Defines the compiler/linker flags used to build Google Test and
+# Google Mock.  You can tweak these definitions to suit your need.  A
+# variable's value is empty before it's explicitly assigned to.
+macro(config_compiler_and_linker)
+  if (NOT gtest_disable_pthreads)
+    # Defines CMAKE_USE_PTHREADS_INIT and CMAKE_THREAD_LIBS_INIT.
+    find_package(Threads)
+  endif()
+
+  fix_default_compiler_settings_()
+  if (MSVC)
+    # Newlines inside flags variables break CMake's NMake generator.
+    # TODO(vladl@google.com): Add -RTCs and -RTCu to debug builds.
+    set(cxx_base_flags "-GS -W4 -WX -wd4251 -wd4275 -nologo -J -Zi")
+    if (MSVC_VERSION LESS 1400)  # 1400 is Visual Studio 2005
+      # Suppress spurious warnings MSVC 7.1 sometimes issues.
+      # Forcing value to bool.
+      set(cxx_base_flags "${cxx_base_flags} -wd4800")
+      # Copy constructor and assignment operator could not be generated.
+      set(cxx_base_flags "${cxx_base_flags} -wd4511 -wd4512")
+      # Compatibility warnings not applicable to Google Test.
+      # Resolved overload was found by argument-dependent lookup.
+      set(cxx_base_flags "${cxx_base_flags} -wd4675")
+    endif()
+    if (MSVC_VERSION LESS 1500)  # 1500 is Visual Studio 2008
+      # Conditional expression is constant.
+      # When compiling with /W4, we get several instances of C4127
+      # (Conditional expression is constant). In our code, we disable that
+      # warning on a case-by-case basis. However, on Visual Studio 2005,
+      # the warning fires on std::list. Therefore on that compiler and earlier,
+      # we disable the warning project-wide.
+      set(cxx_base_flags "${cxx_base_flags} -wd4127")
+    endif()
+    if (NOT (MSVC_VERSION LESS 1700))  # 1700 is Visual Studio 2012.
+      # Suppress "unreachable code" warning on VS 2012 and later.
+      # http://stackoverflow.com/questions/3232669 explains the issue.
+      set(cxx_base_flags "${cxx_base_flags} -wd4702")
+    endif()
+    if (NOT (MSVC_VERSION GREATER 1900))  # 1900 is Visual Studio 2015
+      # BigObj required for tests.
+      set(cxx_base_flags "${cxx_base_flags} -bigobj")
+    endif()
+
+    set(cxx_base_flags "${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32")
+    set(cxx_base_flags "${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN")
+    set(cxx_exception_flags "-EHsc -D_HAS_EXCEPTIONS=1")
+    set(cxx_no_exception_flags "-D_HAS_EXCEPTIONS=0")
+    set(cxx_no_rtti_flags "-GR-")
+  elseif (CMAKE_COMPILER_IS_GNUCXX)
+    set(cxx_base_flags "-Wall -Wshadow")
+    set(cxx_exception_flags "-fexceptions")
+    set(cxx_no_exception_flags "-fno-exceptions")
+    # Until version 4.3.2, GCC doesn't define a macro to indicate
+    # whether RTTI is enabled.  Therefore we define GTEST_HAS_RTTI
+    # explicitly.
+    set(cxx_no_rtti_flags "-fno-rtti -DGTEST_HAS_RTTI=0")
+    set(cxx_strict_flags
+      "-Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
+  elseif (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
+    set(cxx_exception_flags "-features=except")
+    # Sun Pro doesn't provide macros to indicate whether exceptions and
+    # RTTI are enabled, so we define GTEST_HAS_* explicitly.
+    set(cxx_no_exception_flags "-features=no%except -DGTEST_HAS_EXCEPTIONS=0")
+    set(cxx_no_rtti_flags "-features=no%rtti -DGTEST_HAS_RTTI=0")
+  elseif (CMAKE_CXX_COMPILER_ID STREQUAL "VisualAge" OR
+      CMAKE_CXX_COMPILER_ID STREQUAL "XL")
+    # CMake 2.8 changes Visual Age's compiler ID to "XL".
+    set(cxx_exception_flags "-qeh")
+    set(cxx_no_exception_flags "-qnoeh")
+    # Until version 9.0, Visual Age doesn't define a macro to indicate
+    # whether RTTI is enabled.  Therefore we define GTEST_HAS_RTTI
+    # explicitly.
+    set(cxx_no_rtti_flags "-qnortti -DGTEST_HAS_RTTI=0")
+  elseif (CMAKE_CXX_COMPILER_ID STREQUAL "HP")
+    set(cxx_base_flags "-AA -mt")
+    set(cxx_exception_flags "-DGTEST_HAS_EXCEPTIONS=1")
+    set(cxx_no_exception_flags "+noeh -DGTEST_HAS_EXCEPTIONS=0")
+    # RTTI can not be disabled in HP aCC compiler.
+    set(cxx_no_rtti_flags "")
+  endif()
+
+  if (CMAKE_USE_PTHREADS_INIT)  # The pthreads library is available and allowed.
+    set(cxx_base_flags "${cxx_base_flags} -DGTEST_HAS_PTHREAD=1")
+  else()
+    set(cxx_base_flags "${cxx_base_flags} -DGTEST_HAS_PTHREAD=0")
+  endif()
+
+  # For building gtest's own tests and samples.
+  set(cxx_exception "${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_exception_flags}")
+  set(cxx_no_exception
+    "${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_no_exception_flags}")
+  set(cxx_default "${cxx_exception}")
+  set(cxx_no_rtti "${cxx_default} ${cxx_no_rtti_flags}")
+  set(cxx_use_own_tuple "${cxx_default} -DGTEST_USE_OWN_TR1_TUPLE=1")
+
+  # For building the gtest libraries.
+  set(cxx_strict "${cxx_default} ${cxx_strict_flags}")
+endmacro()
+
+# Defines the gtest & gtest_main libraries.  User tests should link
+# with one of them.
+function(cxx_library_with_type name type cxx_flags)
+  # type can be either STATIC or SHARED to denote a static or shared library.
+  # ARGN refers to additional arguments after 'cxx_flags'.
+  add_library(${name} ${type} ${ARGN})
+  set_target_properties(${name}
+    PROPERTIES
+    COMPILE_FLAGS "${cxx_flags}")
+  if (BUILD_SHARED_LIBS OR type STREQUAL "SHARED")
+    set_target_properties(${name}
+      PROPERTIES
+      COMPILE_DEFINITIONS "GTEST_CREATE_SHARED_LIBRARY=1")
+  endif()
+  if (CMAKE_USE_PTHREADS_INIT)
+    target_link_libraries(${name} ${CMAKE_THREAD_LIBS_INIT})
+  endif()
+endfunction()
+
+########################################################################
+#
+# Helper functions for creating build targets.
+
+function(cxx_shared_library name cxx_flags)
+  cxx_library_with_type(${name} SHARED "${cxx_flags}" ${ARGN})
+endfunction()
+
+function(cxx_library name cxx_flags)
+  cxx_library_with_type(${name} "" "${cxx_flags}" ${ARGN})
+endfunction()
+
+# cxx_executable_with_flags(name cxx_flags libs srcs...)
+#
+# creates a named C++ executable that depends on the given libraries and
+# is built from the given source files with the given compiler flags.
+function(cxx_executable_with_flags name cxx_flags libs)
+  add_executable(${name} ${ARGN})
+  if (cxx_flags)
+    set_target_properties(${name}
+      PROPERTIES
+      COMPILE_FLAGS "${cxx_flags}")
+  endif()
+  if (BUILD_SHARED_LIBS)
+    set_target_properties(${name}
+      PROPERTIES
+      COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
+  endif()
+  # To support mixing linking in static and dynamic libraries, link each
+  # library in with an extra call to target_link_libraries.
+  foreach (lib "${libs}")
+    target_link_libraries(${name} ${lib})
+  endforeach()
+endfunction()
+
+# cxx_executable(name dir lib srcs...)
+#
+# creates a named target that depends on the given libs and is built
+# from the given source files.  dir/name.cc is implicitly included in
+# the source file list.
+function(cxx_executable name dir libs)
+  cxx_executable_with_flags(
+    ${name} "${cxx_default}" "${libs}" "${dir}/${name}.cc" ${ARGN})
+endfunction()
+
+# Sets PYTHONINTERP_FOUND and PYTHON_EXECUTABLE.
+find_package(PythonInterp)
+
+# cxx_test_with_flags(name cxx_flags libs srcs...)
+#
+# creates a named C++ test that depends on the given libs and is built
+# from the given source files with the given compiler flags.
+function(cxx_test_with_flags name cxx_flags libs)
+  cxx_executable_with_flags(${name} "${cxx_flags}" "${libs}" ${ARGN})
+  add_test(${name} ${name})
+endfunction()
+
+# cxx_test(name libs srcs...)
+#
+# creates a named test target that depends on the given libs and is
+# built from the given source files.  Unlike cxx_test_with_flags,
+# test/name.cc is already implicitly included in the source file list.
+function(cxx_test name libs)
+  cxx_test_with_flags("${name}" "${cxx_default}" "${libs}"
+    "test/${name}.cc" ${ARGN})
+endfunction()
+
+# py_test(name)
+#
+# creates a Python test with the given name whose main module is in
+# test/name.py.  It does nothing if Python is not installed.
+function(py_test name)
+  # We are not supporting Python tests on Linux yet as they consider
+  # all Linux environments to be google3 and try to use google3 features.
+  if (PYTHONINTERP_FOUND)
+    # ${CMAKE_BINARY_DIR} is known at configuration time, so we can
+    # directly bind it from cmake. ${CTEST_CONFIGURATION_TYPE} is known
+    # only at ctest runtime (by calling ctest -c <Configuration>), so
+    # we have to escape $ to delay variable substitution here.
+    if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1)
+      add_test(
+        NAME ${name}
+        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
+            --build_dir=${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>)
+    else (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1)
+      add_test(
+        ${name}
+        ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
+          --build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE})
+    endif (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1)
+  endif()
+endfunction()
diff --git a/third_party/googletest/src/include/gtest/gtest-death-test.h b/third_party/googletest/src/googletest/include/gtest/gtest-death-test.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/gtest-death-test.h
rename to third_party/googletest/src/googletest/include/gtest/gtest-death-test.h
diff --git a/third_party/googletest/src/include/gtest/gtest-message.h b/third_party/googletest/src/googletest/include/gtest/gtest-message.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/gtest-message.h
rename to third_party/googletest/src/googletest/include/gtest/gtest-message.h
diff --git a/third_party/googletest/src/include/gtest/gtest-param-test.h b/third_party/googletest/src/googletest/include/gtest/gtest-param-test.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/gtest-param-test.h
rename to third_party/googletest/src/googletest/include/gtest/gtest-param-test.h
diff --git a/third_party/googletest/src/include/gtest/gtest-param-test.h.pump b/third_party/googletest/src/googletest/include/gtest/gtest-param-test.h.pump
similarity index 100%
rename from third_party/googletest/src/include/gtest/gtest-param-test.h.pump
rename to third_party/googletest/src/googletest/include/gtest/gtest-param-test.h.pump
diff --git a/third_party/googletest/src/include/gtest/gtest-printers.h b/third_party/googletest/src/googletest/include/gtest/gtest-printers.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/gtest-printers.h
rename to third_party/googletest/src/googletest/include/gtest/gtest-printers.h
diff --git a/third_party/googletest/src/include/gtest/gtest-spi.h b/third_party/googletest/src/googletest/include/gtest/gtest-spi.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/gtest-spi.h
rename to third_party/googletest/src/googletest/include/gtest/gtest-spi.h
diff --git a/third_party/googletest/src/include/gtest/gtest-test-part.h b/third_party/googletest/src/googletest/include/gtest/gtest-test-part.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/gtest-test-part.h
rename to third_party/googletest/src/googletest/include/gtest/gtest-test-part.h
diff --git a/third_party/googletest/src/include/gtest/gtest-typed-test.h b/third_party/googletest/src/googletest/include/gtest/gtest-typed-test.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/gtest-typed-test.h
rename to third_party/googletest/src/googletest/include/gtest/gtest-typed-test.h
diff --git a/third_party/googletest/src/include/gtest/gtest.h b/third_party/googletest/src/googletest/include/gtest/gtest.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/gtest.h
rename to third_party/googletest/src/googletest/include/gtest/gtest.h
diff --git a/third_party/googletest/src/include/gtest/gtest_pred_impl.h b/third_party/googletest/src/googletest/include/gtest/gtest_pred_impl.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/gtest_pred_impl.h
rename to third_party/googletest/src/googletest/include/gtest/gtest_pred_impl.h
diff --git a/third_party/googletest/src/include/gtest/gtest_prod.h b/third_party/googletest/src/googletest/include/gtest/gtest_prod.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/gtest_prod.h
rename to third_party/googletest/src/googletest/include/gtest/gtest_prod.h
diff --git a/third_party/googletest/src/include/gtest/internal/custom/gtest-port.h b/third_party/googletest/src/googletest/include/gtest/internal/custom/gtest-port.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/internal/custom/gtest-port.h
rename to third_party/googletest/src/googletest/include/gtest/internal/custom/gtest-port.h
diff --git a/third_party/googletest/src/include/gtest/internal/custom/gtest-printers.h b/third_party/googletest/src/googletest/include/gtest/internal/custom/gtest-printers.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/internal/custom/gtest-printers.h
rename to third_party/googletest/src/googletest/include/gtest/internal/custom/gtest-printers.h
diff --git a/third_party/googletest/src/include/gtest/internal/custom/gtest.h b/third_party/googletest/src/googletest/include/gtest/internal/custom/gtest.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/internal/custom/gtest.h
rename to third_party/googletest/src/googletest/include/gtest/internal/custom/gtest.h
diff --git a/third_party/googletest/src/include/gtest/internal/gtest-death-test-internal.h b/third_party/googletest/src/googletest/include/gtest/internal/gtest-death-test-internal.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/internal/gtest-death-test-internal.h
rename to third_party/googletest/src/googletest/include/gtest/internal/gtest-death-test-internal.h
diff --git a/third_party/googletest/src/include/gtest/internal/gtest-filepath.h b/third_party/googletest/src/googletest/include/gtest/internal/gtest-filepath.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/internal/gtest-filepath.h
rename to third_party/googletest/src/googletest/include/gtest/internal/gtest-filepath.h
diff --git a/third_party/googletest/src/include/gtest/internal/gtest-internal.h b/third_party/googletest/src/googletest/include/gtest/internal/gtest-internal.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/internal/gtest-internal.h
rename to third_party/googletest/src/googletest/include/gtest/internal/gtest-internal.h
diff --git a/third_party/googletest/src/include/gtest/internal/gtest-linked_ptr.h b/third_party/googletest/src/googletest/include/gtest/internal/gtest-linked_ptr.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/internal/gtest-linked_ptr.h
rename to third_party/googletest/src/googletest/include/gtest/internal/gtest-linked_ptr.h
diff --git a/third_party/googletest/src/include/gtest/internal/gtest-param-util-generated.h b/third_party/googletest/src/googletest/include/gtest/internal/gtest-param-util-generated.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/internal/gtest-param-util-generated.h
rename to third_party/googletest/src/googletest/include/gtest/internal/gtest-param-util-generated.h
diff --git a/third_party/googletest/src/include/gtest/internal/gtest-param-util-generated.h.pump b/third_party/googletest/src/googletest/include/gtest/internal/gtest-param-util-generated.h.pump
similarity index 100%
rename from third_party/googletest/src/include/gtest/internal/gtest-param-util-generated.h.pump
rename to third_party/googletest/src/googletest/include/gtest/internal/gtest-param-util-generated.h.pump
diff --git a/third_party/googletest/src/include/gtest/internal/gtest-param-util.h b/third_party/googletest/src/googletest/include/gtest/internal/gtest-param-util.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/internal/gtest-param-util.h
rename to third_party/googletest/src/googletest/include/gtest/internal/gtest-param-util.h
diff --git a/third_party/googletest/src/include/gtest/internal/gtest-port-arch.h b/third_party/googletest/src/googletest/include/gtest/internal/gtest-port-arch.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/internal/gtest-port-arch.h
rename to third_party/googletest/src/googletest/include/gtest/internal/gtest-port-arch.h
diff --git a/third_party/googletest/src/include/gtest/internal/gtest-port.h b/third_party/googletest/src/googletest/include/gtest/internal/gtest-port.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/internal/gtest-port.h
rename to third_party/googletest/src/googletest/include/gtest/internal/gtest-port.h
diff --git a/third_party/googletest/src/include/gtest/internal/gtest-string.h b/third_party/googletest/src/googletest/include/gtest/internal/gtest-string.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/internal/gtest-string.h
rename to third_party/googletest/src/googletest/include/gtest/internal/gtest-string.h
diff --git a/third_party/googletest/src/include/gtest/internal/gtest-tuple.h b/third_party/googletest/src/googletest/include/gtest/internal/gtest-tuple.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/internal/gtest-tuple.h
rename to third_party/googletest/src/googletest/include/gtest/internal/gtest-tuple.h
diff --git a/third_party/googletest/src/include/gtest/internal/gtest-tuple.h.pump b/third_party/googletest/src/googletest/include/gtest/internal/gtest-tuple.h.pump
similarity index 100%
rename from third_party/googletest/src/include/gtest/internal/gtest-tuple.h.pump
rename to third_party/googletest/src/googletest/include/gtest/internal/gtest-tuple.h.pump
diff --git a/third_party/googletest/src/include/gtest/internal/gtest-type-util.h b/third_party/googletest/src/googletest/include/gtest/internal/gtest-type-util.h
similarity index 100%
rename from third_party/googletest/src/include/gtest/internal/gtest-type-util.h
rename to third_party/googletest/src/googletest/include/gtest/internal/gtest-type-util.h
diff --git a/third_party/googletest/src/include/gtest/internal/gtest-type-util.h.pump b/third_party/googletest/src/googletest/include/gtest/internal/gtest-type-util.h.pump
similarity index 100%
rename from third_party/googletest/src/include/gtest/internal/gtest-type-util.h.pump
rename to third_party/googletest/src/googletest/include/gtest/internal/gtest-type-util.h.pump
diff --git a/third_party/googletest/src/src/gtest-all.cc b/third_party/googletest/src/googletest/src/gtest-all.cc
similarity index 100%
rename from third_party/googletest/src/src/gtest-all.cc
rename to third_party/googletest/src/googletest/src/gtest-all.cc
diff --git a/third_party/googletest/src/src/gtest-death-test.cc b/third_party/googletest/src/googletest/src/gtest-death-test.cc
similarity index 100%
rename from third_party/googletest/src/src/gtest-death-test.cc
rename to third_party/googletest/src/googletest/src/gtest-death-test.cc
diff --git a/third_party/googletest/src/src/gtest-filepath.cc b/third_party/googletest/src/googletest/src/gtest-filepath.cc
similarity index 100%
rename from third_party/googletest/src/src/gtest-filepath.cc
rename to third_party/googletest/src/googletest/src/gtest-filepath.cc
diff --git a/third_party/googletest/src/src/gtest-internal-inl.h b/third_party/googletest/src/googletest/src/gtest-internal-inl.h
similarity index 100%
rename from third_party/googletest/src/src/gtest-internal-inl.h
rename to third_party/googletest/src/googletest/src/gtest-internal-inl.h
diff --git a/third_party/googletest/src/src/gtest-port.cc b/third_party/googletest/src/googletest/src/gtest-port.cc
similarity index 100%
rename from third_party/googletest/src/src/gtest-port.cc
rename to third_party/googletest/src/googletest/src/gtest-port.cc
diff --git a/third_party/googletest/src/src/gtest-printers.cc b/third_party/googletest/src/googletest/src/gtest-printers.cc
similarity index 100%
rename from third_party/googletest/src/src/gtest-printers.cc
rename to third_party/googletest/src/googletest/src/gtest-printers.cc
diff --git a/third_party/googletest/src/src/gtest-test-part.cc b/third_party/googletest/src/googletest/src/gtest-test-part.cc
similarity index 100%
rename from third_party/googletest/src/src/gtest-test-part.cc
rename to third_party/googletest/src/googletest/src/gtest-test-part.cc
diff --git a/third_party/googletest/src/src/gtest-typed-test.cc b/third_party/googletest/src/googletest/src/gtest-typed-test.cc
similarity index 100%
rename from third_party/googletest/src/src/gtest-typed-test.cc
rename to third_party/googletest/src/googletest/src/gtest-typed-test.cc
diff --git a/third_party/googletest/src/src/gtest.cc b/third_party/googletest/src/googletest/src/gtest.cc
similarity index 100%
rename from third_party/googletest/src/src/gtest.cc
rename to third_party/googletest/src/googletest/src/gtest.cc
diff --git a/third_party/googletest/src/src/gtest_main.cc b/third_party/googletest/src/googletest/src/gtest_main.cc
similarity index 100%
rename from third_party/googletest/src/src/gtest_main.cc
rename to third_party/googletest/src/googletest/src/gtest_main.cc