Build benchmarks with Bazel

Change-Id: I559cc1aa17d5be01dcff931e05b22e0dd9e248b6
diff --git a/BUILD b/BUILD
index 9c6a48c..25949c1 100644
--- a/BUILD
+++ b/BUILD
@@ -199,3 +199,15 @@
 ) for test_filename in glob([
     "internal/ceres/generated_bundle_adjustment_tests/*_test.cc",
 ])]
+
+# Build the benchmarks.
+[cc_binary(
+    name = benchmark_name,
+    srcs = ["internal/ceres/" + benchmark_name + ".cc"],
+    copts = TEST_COPTS,
+    deps = TEST_DEPS + ["@com_github_google_benchmark//:benchmark"],
+) for benchmark_name in [
+    "autodiff_cost_function_benchmark",
+    "small_blas_gemm_benchmark",
+    "small_blas_gemv_benchmark",
+]]
diff --git a/WORKSPACE b/WORKSPACE
index 78c0e74..7598813 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -63,3 +63,29 @@
         "http://bitbucket.org/eigen/eigen/get/3.3.4.tar.bz2",
     ],
 )
+
+# External dependency: Google Benchmark; has no Bazel build.
+new_http_archive(
+    name = "com_github_google_benchmark",
+    urls = ["https://github.com/google/benchmark/archive/56f52ee228783547f544d9ac4a533574b9010e3f.zip"],
+    sha256 = "8c1c6e90cd320b07504fabb86400f390faff2e599183ebd9396908817968ae79",
+    strip_prefix = "benchmark-56f52ee228783547f544d9ac4a533574b9010e3f",
+    build_file_content =
+"""
+cc_library(
+    name = "benchmark",
+    srcs = glob([
+        "src/*.h",
+        "src/*.cc",
+    ]),
+    hdrs = glob(["include/benchmark/*.h"]),
+    copts = [
+        "-DHAVE_STD_REGEX",
+    ],
+    includes = [
+        "include",
+    ],
+    visibility = ["//visibility:public"],
+)
+"""
+)