1# Copyright 2014 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5config("gtest_config") {
6  visibility = [
7    ":*",
8    "//testing/gmock:*",  # gmock also shares this config.
9  ]
10
11  defines = [
12
13    # In order to allow regex matches in gtest to be shared between Windows
14    # and other systems, we tell gtest to always use it's internal engine.
15    "GTEST_HAS_POSIX_RE=0",
16    # Chrome doesn't support / require C++11, yet.
17    "GTEST_LANG_CXX11=0",
18  ]
19
20  # Gtest headers need to be able to find themselves.
21  include_dirs = [ "include" ]
22
23  if (is_win) {
24    cflags = [ "/wd4800" ]  # Unused variable warning.
25  }
26
27  if (is_posix) {
28    defines += [
29      # gtest isn't able to figure out when RTTI is disabled for gcc
30      # versions older than 4.3.2, and assumes it's enabled.  Our Mac
31      # and Linux builds disable RTTI, and cannot guarantee that the
32      # compiler will be 4.3.2. or newer.  The Mac, for example, uses
33      # 4.2.1 as that is the latest available on that platform.  gtest
34      # must be instructed that RTTI is disabled here, and for any
35      # direct dependents that might include gtest headers.
36      "GTEST_HAS_RTTI=0",
37    ]
38  }
39
40  if (is_android) {
41    defines += [
42      # We want gtest features that use tr1::tuple, but we currently
43      # don't support the variadic templates used by libstdc++'s
44      # implementation. gtest supports this scenario by providing its
45      # own implementation but we must opt in to it.
46      "GTEST_USE_OWN_TR1_TUPLE=1",
47
48      # GTEST_USE_OWN_TR1_TUPLE only works if GTEST_HAS_TR1_TUPLE is set.
49      # gtest r625 made it so that GTEST_HAS_TR1_TUPLE is set to 0
50      # automatically on android, so it has to be set explicitly here.
51      "GTEST_HAS_TR1_TUPLE=1",
52    ]
53  }
54}
55
56config("gtest_direct_config") {
57  visibility = [ ":*" ]
58  defines = [ "UNIT_TEST" ]
59}
60
61static_library("gtest") {
62  # TODO http://crbug.com/412064 enable this flag all the time.
63  testonly = !is_component_build
64  sources = [
65    "include/gtest/gtest-death-test.h",
66    "include/gtest/gtest-message.h",
67    "include/gtest/gtest-param-test.h",
68    "include/gtest/gtest-printers.h",
69    "include/gtest/gtest-spi.h",
70    "include/gtest/gtest-test-part.h",
71    "include/gtest/gtest-typed-test.h",
72    "include/gtest/gtest.h",
73    "include/gtest/gtest_pred_impl.h",
74    "include/gtest/internal/gtest-death-test-internal.h",
75    "include/gtest/internal/gtest-filepath.h",
76    "include/gtest/internal/gtest-internal.h",
77    "include/gtest/internal/gtest-linked_ptr.h",
78    "include/gtest/internal/gtest-param-util-generated.h",
79    "include/gtest/internal/gtest-param-util.h",
80    "include/gtest/internal/gtest-port.h",
81    "include/gtest/internal/gtest-string.h",
82    "include/gtest/internal/gtest-tuple.h",
83    "include/gtest/internal/gtest-type-util.h",
84    #"gtest/src/gtest-all.cc",  # Not needed by our build.
85    "src/gtest-death-test.cc",
86    "src/gtest-filepath.cc",
87    "src/gtest-internal-inl.h",
88    "src/gtest-port.cc",
89    "src/gtest-printers.cc",
90    "src/gtest-test-part.cc",
91    "src/gtest-typed-test.cc",
92    "src/gtest.cc",
93    "../multiprocess_func_list.cc",
94    "../multiprocess_func_list.h",
95    "../platform_test.h",
96  ]
97
98  if (is_mac) {
99    sources += [
100      "../gtest_mac.h",
101      "../gtest_mac.mm",
102      "../platform_test_mac.mm",
103    ]
104  }
105
106  include_dirs = [ "." ]
107
108  all_dependent_configs = [ ":gtest_config" ]
109  public_configs = [ ":gtest_direct_config" ]
110
111  configs -= [ "//build/config/compiler:chromium_code" ]
112  configs += [ "//build/config/compiler:no_chromium_code" ]
113}
114
115source_set("gtest_main") {
116  # TODO http://crbug.com/412064 enable this flag all the time.
117  testonly = !is_component_build
118  sources = [ "src/gtest_main.cc" ]
119  deps = [ ":gtest" ]
120}
121