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