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
5import("//build_overrides/gtest.gni")
6if (is_ios) {
7  import("//build/config/coverage/coverage.gni")
8  import("//build/config/ios/ios_sdk.gni")
9  import("//build/buildflag_header.gni")
10}
11
12config("gtest_direct_config") {
13  visibility = [ ":*" ]
14  defines = [ "UNIT_TEST" ]
15}
16
17# The file/directory layout of Google Test is not yet considered stable. Until
18# it stabilizes, Chromium code MUST use this target instead of reaching directly
19# into //third_party/googletest.
20static_library("gtest") {
21  testonly = true
22
23  sources = [
24    "include/gtest/gtest-death-test.h",
25    "include/gtest/gtest-message.h",
26    "include/gtest/gtest-param-test.h",
27    "include/gtest/gtest-spi.h",
28    "include/gtest/gtest.h",
29    "include/gtest/gtest_prod.h",
30
31    # This is a workaround for the issues below.
32    #
33    # 1) This target needs to be a static_library (not a source set) on Mac to
34    #    avoid the build errors in
35    #    https://codereview.chromium.org/2779193002#msg82.
36    # 2) A static_library must have at least one source file, to avoid build
37    #    errors on Mac and Windows. https://crbug.com/710334
38    # 3) A static_library with complete_static_lib = true, which would not
39    #    require adding the empty file, will result in duplicate symbols on
40    #    Android. https://codereview.chromium.org/2852613002/#ps20001
41    "empty.cc",
42  ]
43  public_deps = [
44    "//third_party/googletest:gtest",
45  ]
46
47  public_configs = [ ":gtest_direct_config" ]
48
49  if (gtest_include_multiprocess) {
50    sources += [
51      "../multiprocess_func_list.cc",
52      "../multiprocess_func_list.h",
53    ]
54  }
55
56  if (gtest_include_platform_test) {
57    sources += [ "../platform_test.h" ]
58  }
59
60  if ((is_mac || is_ios) && gtest_include_objc_support) {
61    if (is_ios) {
62      set_sources_assignment_filter([])
63    }
64    sources += [
65      "../gtest_mac.h",
66      "../gtest_mac.mm",
67    ]
68    if (gtest_include_platform_test) {
69      sources += [ "../platform_test_mac.mm" ]
70    }
71    set_sources_assignment_filter(sources_assignment_filter)
72  }
73
74  if (is_ios && gtest_include_ios_coverage) {
75    sources += [
76      "../coverage_util_ios.h",
77      "../coverage_util_ios.mm",
78    ]
79    deps = [
80      ":ios_enable_coverage",
81    ]
82  }
83}
84
85# The file/directory layout of Google Test is not yet considered stable. Until
86# it stabilizes, Chromium code MUST use this target instead of reaching directly
87# into //third_party/googletest.
88source_set("gtest_main") {
89  testonly = true
90  deps = [
91    "//third_party/googletest:gtest_main",
92  ]
93}
94
95if (is_ios) {
96  buildflag_header("ios_enable_coverage") {
97    header = "ios_enable_coverage.h"
98    flags = [ "IOS_ENABLE_COVERAGE=$use_clang_coverage" ]
99  }
100}
101