• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2021 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15import("//build_overrides/pigweed.gni")
16
17import("$dir_pw_build/target_types.gni")
18import("$dir_pw_docgen/docs.gni")
19import("googletest.gni")
20
21# This file defines a GN source_set for an external installation of googletest.
22# To use, checkout the googletest source into a directory, then set the build
23# arg dir_pw_third_party_googletest to point to that directory. The googletest
24# library will be available in GN at "$dir_pw_third_party/googletest".
25if (dir_pw_third_party_googletest != "") {
26  config("includes") {
27    include_dirs = [
28      "$dir_pw_third_party_googletest/googletest",
29      "$dir_pw_third_party_googletest/googletest/include",
30      "$dir_pw_third_party_googletest/googlemock",
31      "$dir_pw_third_party_googletest/googlemock/include",
32    ]
33
34    # Fix some compiler warnings.
35    cflags = [
36      "-Wno-undef",
37      "-Wno-conversion",
38      "-Wno-shadow-all",
39      "-Wno-switch-enum",
40    ]
41  }
42
43  pw_source_set("googletest") {
44    public_configs = [ ":includes" ]
45    public = [
46      "$dir_pw_third_party_googletest/googlemock/include/gmock/gmock-matchers.h",
47      "$dir_pw_third_party_googletest/googlemock/include/gmock/gmock.h",
48      "$dir_pw_third_party_googletest/googletest/include/gtest/gtest-spi.h",
49      "$dir_pw_third_party_googletest/googletest/include/gtest/gtest.h",
50    ]
51
52    # Only add the "*-all.cc" files (and no headers) to improve maintainability
53    # from upstream refactoring. The "*-all.cc" files include the respective
54    # source files.
55    sources = [
56      "$dir_pw_third_party_googletest/googlemock/src/gmock-all.cc",
57      "$dir_pw_third_party_googletest/googletest/src/gtest-all.cc",
58    ]
59  }
60
61  pw_source_set("gtest_main") {
62    public_deps = [ ":googletest" ]
63    sources = [ "$dir_pw_third_party_googletest/googletest/src/gtest_main.cc" ]
64  }
65
66  pw_source_set("gmock_main") {
67    public_deps = [ ":googletest" ]
68    sources = [ "$dir_pw_third_party_googletest/googlemock/src/gmock_main.cc" ]
69  }
70
71  # Alias that matches the Bazel target, i.e. "@com_google_googletest//:gtest".
72  # This is needed by some third party deps generated from Bazel, e.g. FuzzTest.
73  group("gtest") {
74    public_deps = [ ":googletest" ]
75  }
76} else {
77  group("googletest") {
78    if (pw_third_party_googletest_ALIAS != "") {
79      public_deps = [ pw_third_party_googletest_ALIAS ]
80    }
81  }
82}
83
84pw_doc_group("docs") {
85  sources = [ "docs.rst" ]
86}
87