Add bazel target for benchmark_release (#1078)
Fixes google#1077
Bazel clients currently cannot build the benchmark library in Release
mode. This commit adds a new target ":benchmark_release" to enable this.
diff --git a/BUILD.bazel b/BUILD.bazel
index eb35b62..2d87177 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -10,8 +10,8 @@
visibility = [":__subpackages__"],
)
-cc_library(
- name = "benchmark",
+filegroup(
+ name = "benchmark_srcs",
srcs = glob(
[
"src/*.cc",
@@ -19,6 +19,11 @@
],
exclude = ["src/benchmark_main.cc"],
),
+)
+
+cc_library(
+ name = "benchmark",
+ srcs = [":benchmark_srcs"],
hdrs = ["include/benchmark/benchmark.h"],
linkopts = select({
":windows": ["-DEFAULTLIB:shlwapi.lib"],
@@ -29,6 +34,19 @@
)
cc_library(
+ name = "benchmark_release",
+ srcs = [":benchmark_srcs"],
+ hdrs = ["include/benchmark/benchmark.h"],
+ defines = ["NDEBUG"],
+ linkopts = select({
+ ":windows": ["-DEFAULTLIB:shlwapi.lib"],
+ "//conditions:default": ["-pthread"],
+ }),
+ strip_include_prefix = "include",
+ visibility = ["//visibility:public"],
+)
+
+cc_library(
name = "benchmark_main",
srcs = ["src/benchmark_main.cc"],
hdrs = ["include/benchmark/benchmark.h"],