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.h", 47 "$dir_pw_third_party_googletest/googletest/include/gtest/gtest-spi.h", 48 "$dir_pw_third_party_googletest/googletest/include/gtest/gtest.h", 49 ] 50 51 # Only add the "*-all.cc" files (and no headers) to improve maintainability 52 # from upstream refactoring. The "*-all.cc" files include the respective 53 # source files. 54 sources = [ 55 "$dir_pw_third_party_googletest/googlemock/src/gmock-all.cc", 56 "$dir_pw_third_party_googletest/googletest/src/gtest-all.cc", 57 ] 58 } 59 60 pw_source_set("gtest_main") { 61 public_deps = [ ":googletest" ] 62 sources = [ "$dir_pw_third_party_googletest/googletest/src/gtest_main.cc" ] 63 } 64 65 pw_source_set("gmock_main") { 66 public_deps = [ ":googletest" ] 67 sources = [ "$dir_pw_third_party_googletest/googlemock/src/gmock_main.cc" ] 68 } 69 70 # Alias that matches the Bazel target, i.e. "@com_google_googletest//:gtest". 71 # This is needed by some third party deps generated from Bazel, e.g. FuzzTest. 72 group("gtest") { 73 public_deps = [ ":googletest" ] 74 } 75} else { 76 group("googletest") { 77 } 78} 79 80pw_doc_group("docs") { 81 sources = [ "docs.rst" ] 82} 83