Home | History | Annotate | Download | only in gtest
      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 
      5 import("//build_overrides/gtest.gni")
      6 
      7 config("gtest_config") {
      8   visibility = [
      9     ":*",
     10     "//testing/gmock:*",  # gmock also shares this config.
     11   ]
     12 
     13   defines = [
     14     # In order to allow regex matches in gtest to be shared between Windows
     15     # and other systems, we tell gtest to always use it's internal engine.
     16     "GTEST_HAS_POSIX_RE=0",
     17 
     18     # Chrome doesn't support / require C++11, yet.
     19     "GTEST_LANG_CXX11=0",
     20   ]
     21 
     22   # Gtest headers need to be able to find themselves.
     23   include_dirs = [ "include" ]
     24 
     25   if (is_win) {
     26     cflags = [ "/wd4800" ]  # Unused variable warning.
     27   }
     28 
     29   if (is_posix) {
     30     defines += [
     31       # gtest isn't able to figure out when RTTI is disabled for gcc
     32       # versions older than 4.3.2, and assumes it's enabled.  Our Mac
     33       # and Linux builds disable RTTI, and cannot guarantee that the
     34       # compiler will be 4.3.2. or newer.  The Mac, for example, uses
     35       # 4.2.1 as that is the latest available on that platform.  gtest
     36       # must be instructed that RTTI is disabled here, and for any
     37       # direct dependents that might include gtest headers.
     38       "GTEST_HAS_RTTI=0",
     39     ]
     40   }
     41 
     42   if (is_android) {
     43     defines += [
     44       # We want gtest features that use tr1::tuple, but we currently
     45       # don't support the variadic templates used by libstdc++'s
     46       # implementation. gtest supports this scenario by providing its
     47       # own implementation but we must opt in to it.
     48       "GTEST_USE_OWN_TR1_TUPLE=1",
     49 
     50       # GTEST_USE_OWN_TR1_TUPLE only works if GTEST_HAS_TR1_TUPLE is set.
     51       # gtest r625 made it so that GTEST_HAS_TR1_TUPLE is set to 0
     52       # automatically on android, so it has to be set explicitly here.
     53       "GTEST_HAS_TR1_TUPLE=1",
     54     ]
     55   }
     56 }
     57 
     58 config("gtest_direct_config") {
     59   visibility = [ ":*" ]
     60   defines = [ "UNIT_TEST" ]
     61 }
     62 
     63 config("gtest_warnings") {
     64   if (is_win && is_clang) {
     65     # The Mutex constructor initializer list in gtest-port.cc is incorrectly
     66     # ordered. See
     67     # https://groups.google.com/d/msg/googletestframework/S5uSV8L2TX8/U1FaTDa6J6sJ.
     68     cflags = [ "-Wno-reorder" ]
     69   }
     70 }
     71 
     72 static_library("gtest") {
     73   testonly = true
     74   sources = [
     75     "include/gtest/gtest-death-test.h",
     76     "include/gtest/gtest-message.h",
     77     "include/gtest/gtest-param-test.h",
     78     "include/gtest/gtest-printers.h",
     79     "include/gtest/gtest-spi.h",
     80     "include/gtest/gtest-test-part.h",
     81     "include/gtest/gtest-typed-test.h",
     82     "include/gtest/gtest.h",
     83     "include/gtest/gtest_pred_impl.h",
     84     "include/gtest/internal/gtest-death-test-internal.h",
     85     "include/gtest/internal/gtest-filepath.h",
     86     "include/gtest/internal/gtest-internal.h",
     87     "include/gtest/internal/gtest-linked_ptr.h",
     88     "include/gtest/internal/gtest-param-util-generated.h",
     89     "include/gtest/internal/gtest-param-util.h",
     90     "include/gtest/internal/gtest-port.h",
     91     "include/gtest/internal/gtest-string.h",
     92     "include/gtest/internal/gtest-tuple.h",
     93     "include/gtest/internal/gtest-type-util.h",
     94 
     95     #"gtest/src/gtest-all.cc",  # Not needed by our build.
     96     "src/gtest-death-test.cc",
     97     "src/gtest-filepath.cc",
     98     "src/gtest-internal-inl.h",
     99     "src/gtest-port.cc",
    100     "src/gtest-printers.cc",
    101     "src/gtest-test-part.cc",
    102     "src/gtest-typed-test.cc",
    103     "src/gtest.cc",
    104   ]
    105 
    106   if (gtest_include_multiprocess) {
    107     sources += [
    108       "../multiprocess_func_list.cc",
    109       "../multiprocess_func_list.h",
    110     ]
    111   }
    112 
    113   if (gtest_include_platform_test) {
    114     sources += [ "../platform_test.h" ]
    115   }
    116 
    117   if ((is_mac || is_ios) && gtest_include_objc_support) {
    118     if (is_ios) {
    119       set_sources_assignment_filter([])
    120     }
    121     sources += [
    122       "../gtest_mac.h",
    123       "../gtest_mac.mm",
    124     ]
    125     if (gtest_include_platform_test) {
    126       sources += [ "../platform_test_mac.mm" ]
    127     }
    128     set_sources_assignment_filter(sources_assignment_filter)
    129   }
    130 
    131   if (is_ios && gtest_include_ios_coverage) {
    132     sources += [
    133       "../coverage_util_ios.cc",
    134       "../coverage_util_ios.h",
    135     ]
    136   }
    137 
    138   include_dirs = [ "." ]
    139 
    140   all_dependent_configs = [ ":gtest_config" ]
    141   public_configs = [ ":gtest_direct_config" ]
    142 
    143   configs -= [ "//build/config/compiler:chromium_code" ]
    144   configs += [
    145     "//build/config/compiler:no_chromium_code",
    146 
    147     # Must be after no_chromium_code for warning flags to be ordered correctly.
    148     ":gtest_warnings",
    149   ]
    150 }
    151 
    152 source_set("gtest_main") {
    153   testonly = true
    154   sources = [
    155     "src/gtest_main.cc",
    156   ]
    157   deps = [
    158     ":gtest",
    159   ]
    160 }
    161