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 ] 39 } 40 41 pw_source_set("googletest") { 42 public_configs = [ ":includes" ] 43 public = [ 44 "$dir_pw_third_party_googletest/googlemock/include/gmock/gmock.h", 45 "$dir_pw_third_party_googletest/googletest/include/gtest/gtest-spi.h", 46 "$dir_pw_third_party_googletest/googletest/include/gtest/gtest.h", 47 ] 48 49 # Only add the "*-all.cc" files (and no headers) to improve maintainability 50 # from upstream refactoring. The "*-all.cc" files include the respective 51 # source files. 52 sources = [ 53 "$dir_pw_third_party_googletest/googlemock/src/gmock-all.cc", 54 "$dir_pw_third_party_googletest/googletest/src/gtest-all.cc", 55 ] 56 } 57 58 pw_source_set("gtest_main") { 59 public_deps = [ ":googletest" ] 60 sources = [ "$dir_pw_third_party_googletest/googletest/src/gtest_main.cc" ] 61 } 62 63 pw_source_set("gmock_main") { 64 public_deps = [ ":googletest" ] 65 sources = [ "$dir_pw_third_party_googletest/googlemock/src/gmock_main.cc" ] 66 } 67} else { 68 group("googletest") { 69 } 70} 71 72pw_doc_group("docs") { 73 sources = [ "docs.rst" ] 74} 75