BUILD.bazel 4.08 KB
Newer Older
misterg's avatar
WIP  
misterg committed
1
2
3
4
5
6
# Copyright 2017 Google Inc. All Rights Reserved.
# Author: misterg@google.com (Gennadiy Civil)
#
# Description:
#   Bazel BUILD file for googletest, initial revision
#
misterg's avatar
WIP  
misterg committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package(default_visibility = ["//visibility:public"])

licenses(["notice"])

cc_library(
    name = "gmock",
    srcs = glob(
        include = [
            "googlemock/src/*.cc",
            "googlemock/include/gmock/**/*.h",
        ],
        exclude = [
            "googlemock/src/gmock-all.cc",
        ],
    ),
    hdrs = glob([
        "googlemock/include/gmock/*.h",
    ]),
    includes = [
        "googlemock",
        "googlemock/include",
    ],
    linkopts = select({
        ":win": [],
        "//conditions:default": ["-pthread"],
    }),
    deps = [
        ":gtest",
    ],
)

misterg's avatar
WIP  
misterg committed
38
39
40
41
42
43
44
45
46
47
48
49
# gtest public API.
GTEST_HDRS = \
    glob([
        "googletest/include/gtest/*.h",
    ])

config_setting(
    name = "win",
    values = {"cpu": "x64_windows_msvc"},
)

# Google Test
misterg's avatar
WIP  
misterg committed
50
51
52
53
54
55
56
57
58
59
60
61
62
cc_library(
    name = "gtest",
    srcs = glob(
        include = [
            "googletest/src/*.cc",
            "googletest/src/*.h",
            "googletest/include/gtest/**/*.h",
        ],
        exclude = [
            "googletest/src/gtest-all.cc",
            "googletest/src/gtest_main.cc",
        ],
    ),
misterg's avatar
WIP  
misterg committed
63
    hdrs = GTEST_HDRS,
misterg's avatar
WIP  
misterg committed
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
    copts = select(
        {
            ":win": [],
            "//conditions:default": ["-pthread"],
        },
    ),
    includes = [
        "googletest",
        "googletest/include",
    ],
    linkopts = select({
        ":win": [],
        "//conditions:default": [
            "-pthread",
        ],
    }),
)

misterg's avatar
WIP  
misterg committed
82
## Google Test with exceptions enabled.
misterg's avatar
WIP  
misterg committed
83
cc_library(
misterg's avatar
WIP  
misterg committed
84
    name = "gtest_ex",
misterg's avatar
WIP  
misterg committed
85
86
    srcs = glob(
        include = [
misterg's avatar
WIP  
misterg committed
87
88
            "googletest/src/*.cc",
            "googletest/src/*.h",
misterg's avatar
WIP  
misterg committed
89
90
91
92
            "googletest/include/gtest/**/*.h",
        ],
        exclude = [
            "googletest/src/gtest-all.cc",
misterg's avatar
WIP  
misterg committed
93
            "googletest/src/gtest_main.cc",
misterg's avatar
WIP  
misterg committed
94
95
        ],
    ),
misterg's avatar
WIP  
misterg committed
96
    hdrs = GTEST_HDRS,
misterg's avatar
misterg committed
97
    copts = select(
misterg's avatar
WIP  
misterg committed
98
        {
misterg's avatar
misterg committed
99
100
            ":win": ["-DGTEST_ENABLE_CATCH_EXCEPTIONS_=1"],
            "//conditions:default": ["-fexceptions","-pthread"],
misterg's avatar
WIP  
misterg committed
101
        },
misterg's avatar
WIP  
misterg committed
102
103
104
105
106
107
108
109
110
111
112
113
114
    ),
    includes = [
        "googletest",
        "googletest/include",
    ],
    linkopts = select({
        ":win": [],
        "//conditions:default": [
            "-pthread",
        ],
    }),
)

misterg's avatar
WIP  
misterg committed
115
116
117
118
119
120
121
122
123
124
125
126
127
128
cc_library(
    name = "gtest_main",
    srcs = glob(
        include = [
            "googletest/src/gtest_main.cc",
        ],
    ),
    hdrs = glob([
        "googletest/include/gtest/*.h",
        "googletest/include/gtest/**/*.h",
    ]),
    includes = [
        "googletest",
        "googletest/include",
misterg's avatar
WIP  
misterg committed
129
    ],
misterg's avatar
WIP  
misterg committed
130
    deps = ["//:gtest"],
misterg's avatar
WIP  
misterg committed
131
132
)

misterg's avatar
WIP  
misterg committed
133
# The following rules build samples of how to use gTest.
misterg's avatar
WIP  
misterg committed
134
cc_library(
misterg's avatar
WIP  
misterg committed
135
    name = "gtest_sample_lib",
misterg's avatar
WIP  
misterg committed
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
    srcs = [
        "googletest/samples/sample1.cc",
        "googletest/samples/sample2.cc",
        "googletest/samples/sample4.cc",
    ],
    hdrs = [
        "googletest/samples/prime_tables.h",
        "googletest/samples/sample1.h",
        "googletest/samples/sample2.h",
        "googletest/samples/sample3-inl.h",
        "googletest/samples/sample4.h",
    ],
)

cc_test(
misterg's avatar
WIP  
misterg committed
151
    name = "gtest_samples",
misterg's avatar
WIP  
misterg committed
152
    size = "small",
misterg's avatar
WIP  
misterg committed
153
154
155
156
157
158
159
160
161
162
163
164
165
    #All Samples except:
    #sample9 ( main )
    #sample10 (main and takes a command line option and needs to be separate)
    srcs = [
        "googletest/samples/sample1_unittest.cc",
        "googletest/samples/sample2_unittest.cc",
        "googletest/samples/sample3_unittest.cc",
        "googletest/samples/sample4_unittest.cc",
        "googletest/samples/sample5_unittest.cc",
        "googletest/samples/sample6_unittest.cc",
        "googletest/samples/sample7_unittest.cc",
        "googletest/samples/sample8_unittest.cc",
    ],
misterg's avatar
WIP  
misterg committed
166
    deps = [
misterg's avatar
WIP  
misterg committed
167
        "gtest_sample_lib",
misterg's avatar
WIP  
misterg committed
168
169
170
171
172
        ":gtest_main",
    ],
)

cc_test(
misterg's avatar
WIP  
misterg committed
173
    name = "sample9_unittest",
misterg's avatar
WIP  
misterg committed
174
    size = "small",
misterg's avatar
WIP  
misterg committed
175
    srcs = ["googletest/samples/sample9_unittest.cc"],
misterg's avatar
WIP  
misterg committed
176
    deps = [":gtest"],
misterg's avatar
WIP  
misterg committed
177
178
179
)

cc_test(
misterg's avatar
WIP  
misterg committed
180
    name = "sample10_unittest",
misterg's avatar
WIP  
misterg committed
181
    size = "small",
misterg's avatar
WIP  
misterg committed
182
    srcs = ["googletest/samples/sample10_unittest.cc"],
misterg's avatar
WIP  
misterg committed
183
    deps = [
misterg's avatar
WIP  
misterg committed
184
        ":gtest",
misterg's avatar
WIP  
misterg committed
185
186
    ],
)