summaryrefslogtreecommitdiffstats
path: root/BUILD.bazel
diff options
context:
space:
mode:
authorPavel Samolysov <samolisov@gmail.com>2019-01-14 12:42:36 (GMT)
committerPavel Samolysov <samolisov@gmail.com>2019-01-14 13:20:56 (GMT)
commitc868da198834e61cce051775b7e0f9bafd594d89 (patch)
treea0a0d4bbf127a45cacf633f3e346a7aee03d2c21 /BUILD.bazel
parent0599a7b8410dc5cfdb477900b280475ae775d7f9 (diff)
downloadgoogletest-c868da198834e61cce051775b7e0f9bafd594d89.zip
googletest-c868da198834e61cce051775b7e0f9bafd594d89.tar.gz
googletest-c868da198834e61cce051775b7e0f9bafd594d89.tar.bz2
Enable building as a shared library (dll) on Windows with Bazel
While the google test library is being built as a shared library using Bazel, so that there is a rule like cc_test( name = "iterator_traits_test", linkstatic = 0, deps = ["@gtest//:gtest_main"], ... ) in a BUILD file, the following error appears on Windows: INFO: Found 1 test target... ERROR: C:/../external/gtest/BUILD.bazel:55:1: output 'external/gtest/gtest.if.lib' was not created ERROR: C:/../external/gtest/BUILD.bazel:55:1: not all outputs were created or valid Target //test:iterator_traits_test failed to build The reason is a missing "win_def_file" attribute of the "gtest" and "gtest_main" rules in the BUILD.bazel inside the google test library package. The "windows_export_all_symbols" feature is added to the rules, this feature forces Bazel to export all symbols from the google test library to linker. I believe exporting all symbols from a testing library makes no problem for the application from a point of view on encapsulation. Signed-off-by: Pavel Samolysov <samolisov@gmail.com>
Diffstat (limited to 'BUILD.bazel')
-rw-r--r--BUILD.bazel8
1 files changed, 8 insertions, 0 deletions
diff --git a/BUILD.bazel b/BUILD.bazel
index 4dbaa27..a000471 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -104,12 +104,20 @@ cc_library(
],
"//conditions:default": [],
}),
+ features = select({
+ ":windows": ["windows_export_all_symbols"],
+ "//conditions:default": [],
+ })
)
cc_library(
name = "gtest_main",
srcs = ["googlemock/src/gmock_main.cc"],
deps = [":gtest"],
+ features = select({
+ ":windows": ["windows_export_all_symbols"],
+ "//conditions:default": [],
+ })
)
# The following rules build samples of how to use gTest.