From 62a9d756eacf28b5be59429d25f1fae3e202e5e3 Mon Sep 17 00:00:00 2001 From: Alex Strelnikov Date: Wed, 2 May 2018 06:23:18 -0400 Subject: [PATCH] Update bazel WORKSPACE and BUILD files to work better on Windows. (#581) Note, bazel only supports MSVC on Windows, and not MinGW, so linking against shlwapi.lib only needs to follow MSVC conventions. git_repository() did not work in local testing, so is swapped for http_archive(). The latter is also documented as the preferred way to depend on an external library in bazel. --- BUILD.bazel | 2 +- README.md | 4 ++-- WORKSPACE | 10 ++++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 7a9bac7a..76b85d88 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -16,7 +16,7 @@ cc_library( ]), hdrs = ["include/benchmark/benchmark.h"], linkopts = select({ - ":windows": [], + ":windows": ["-DEFAULTLIB:shlwapi.lib"], "//conditions:default": ["-pthread"], }), strip_include_prefix = "include", diff --git a/README.md b/README.md index c8f8c01f..dbf59d7f 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ We need to install the library globally now sudo make install ``` -Now you have google/benchmark installed in your machine +Now you have google/benchmark installed in your machine Note: Don't forget to link to pthread library while building ## Stable and Experimental Library Versions @@ -933,7 +933,7 @@ sudo cpupower frequency-set --governor powersave # Known Issues -### Windows +### Windows with CMake * Users must manually link `shlwapi.lib`. Failure to do so may result in unresolved symbols. diff --git a/WORKSPACE b/WORKSPACE index 9ba32fd7..54734f1e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,9 +1,7 @@ workspace(name = "com_github_google_benchmark") -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") - -git_repository( - name = "com_google_googletest", - commit = "3f0cf6b62ad1eb50d8736538363d3580dd640c3e", # HEAD - remote = "https://github.com/google/googletest", +http_archive( + name = "com_google_googletest", + urls = ["https://github.com/google/googletest/archive/3f0cf6b62ad1eb50d8736538363d3580dd640c3e.zip"], + strip_prefix = "googletest-3f0cf6b62ad1eb50d8736538363d3580dd640c3e", )