Add CMake configuration for iree::testing

Closes #240

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/iree/pull/240 from marbre:cmake-testing 516e7a5f3ee24c2abb74f7f6231e7af747546827
PiperOrigin-RevId: 287355185
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f71ec76..c714526 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -94,6 +94,10 @@
   add_subdirectory(build_tools/third_party/dear_imgui EXCLUDE_FROM_ALL)
 endif()
 
+if(${IREE_BUILD_TESTS})
+  add_subdirectory(third_party/benchmark EXCLUDE_FROM_ALL)
+endif()
+
 #-------------------------------------------------------------------------------
 # IREE top-level libraries
 #-------------------------------------------------------------------------------
@@ -104,6 +108,7 @@
 add_subdirectory(iree/hal)
 add_subdirectory(iree/rt)
 add_subdirectory(iree/schemas)
+add_subdirectory(iree/testing)
 add_subdirectory(iree/vm)
 
 if(${IREE_BUILD_COMPILER})
diff --git a/iree/testing/CMakeLists.txt b/iree/testing/CMakeLists.txt
new file mode 100644
index 0000000..14db582
--- /dev/null
+++ b/iree/testing/CMakeLists.txt
@@ -0,0 +1,55 @@
+# Copyright 2019 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Testing utilities for IREE.
+
+add_subdirectory(internal)
+
+if(${IREE_BUILD_TESTS})
+
+  iree_cc_library(
+    NAME
+      benchmark_main
+    SRCS
+      "benchmark_main.cc"
+    DEPS
+      iree::base::init
+      benchmark
+    ALWAYSLINK
+    PUBLIC
+  )
+
+  iree_cc_library(
+    NAME
+      gtest
+    HDRS
+      "gtest.h"
+    DEPS
+      iree::testing::internal::gtest_internal
+      iree::testing::internal::gtest_main_internal
+    PUBLIC
+  )
+
+  iree_cc_library(
+    NAME
+      gtest_main
+    HDRS
+      "gtest.h"
+    DEPS
+      iree::testing::internal::gtest_internal
+      iree::testing::internal::gtest_main_internal
+    PUBLIC
+  )
+
+endif()
diff --git a/iree/testing/internal/CMakeLists.txt b/iree/testing/internal/CMakeLists.txt
new file mode 100644
index 0000000..9d5339b
--- /dev/null
+++ b/iree/testing/internal/CMakeLists.txt
@@ -0,0 +1,42 @@
+# Copyright 2019 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Implementations for iree/testing/
+
+if(${IREE_BUILD_TESTS})
+
+  iree_cc_library(
+    NAME
+      gtest_internal
+    HDRS
+      "gtest_internal.h"
+    DEPS
+      gtest
+    PUBLIC
+  )
+
+  iree_cc_library(
+    NAME
+      gtest_main_internal
+    HDRS
+      "gtest_internal.h"
+    SRCS
+      "gtest_main_internal.cc"
+    DEPS
+      iree::base::init
+      gtest
+    PUBLIC
+  )
+
+endif()