Skip to content
This repository was archived by the owner on May 17, 2023. It is now read-only.

Commit c6def63

Browse files
vshamporOleg Nabiullin
authored and
Oleg Nabiullin
committed
[build] Switch to self-hosted GTest/GMock
Fixes: #836
1 parent 58ad0c5 commit c6def63

File tree

334 files changed

+137515
-28
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

334 files changed

+137515
-28
lines changed

CMakeLists.txt

+14-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ include( ${BUILDER_ROOT}/FindMFX.cmake )
8888
include( ${BUILDER_ROOT}/FindPackages.cmake )
8989
include( ${BUILDER_ROOT}/FindInternals.cmake )
9090
include( ${BUILDER_ROOT}/FindITT.cmake )
91-
include( ${BUILDER_ROOT}/FindGTest.cmake )
9291
include( ${BUILDER_ROOT}/ConfTargets.cmake )
9392

9493
# should prepend others to define target mfx
@@ -110,6 +109,20 @@ endif()
110109

111110
if (BUILD_TESTS)
112111
enable_testing()
112+
113+
114+
set (INSTALL_GTEST OFF)
115+
add_subdirectory(${CMAKE_HOME_DIRECTORY}/googletest)
116+
117+
# For some Linux distro versions there is an unused-result warning
118+
# generated inside the Gtest code at a call to fwrite. Since Gtest sets -Werror
119+
# internally the only way to make it compile without modifying its source is to disable the
120+
# unused-result warnings for Gtest/Gmock only.
121+
target_compile_options (gtest PRIVATE "-Wno-unused-result")
122+
target_compile_options (gmock PRIVATE "-Wno-unused-result")
123+
target_compile_options (gtest_main PRIVATE "-Wno-unused-result")
124+
target_compile_options (gmock_main PRIVATE "-Wno-unused-result")
125+
113126
add_subdirectory(tests)
114127
endif()
115128

builder/FindFunctions.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,4 @@ function(msdk_install target dir)
325325
install( TARGETS ${target} LIBRARY DESTINATION ${dir} )
326326
endif()
327327
endfunction()
328+

googletest/.travis.yml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Build matrix / environment variable are explained on:
2+
# https://docs.travis-ci.com/user/customizing-the-build/
3+
# This file can be validated on:
4+
# http://lint.travis-ci.org/
5+
6+
sudo: false
7+
language: cpp
8+
9+
# Define the matrix explicitly, manually expanding the combinations of (os, compiler, env).
10+
# It is more tedious, but grants us far more flexibility.
11+
matrix:
12+
include:
13+
- os: linux
14+
compiler: gcc
15+
sudo : true
16+
install: ./ci/install-linux.sh && ./ci/log-config.sh
17+
script: ./ci/build-linux-bazel.sh
18+
- os: linux
19+
compiler: clang
20+
sudo : true
21+
install: ./ci/install-linux.sh && ./ci/log-config.sh
22+
script: ./ci/build-linux-bazel.sh
23+
- os: linux
24+
group: deprecated-2017Q4
25+
compiler: gcc
26+
install: ./ci/install-linux.sh && ./ci/log-config.sh
27+
script: ./ci/build-linux-autotools.sh
28+
- os: linux
29+
group: deprecated-2017Q4
30+
compiler: gcc
31+
env: BUILD_TYPE=Debug VERBOSE=1 CXX_FLAGS=-std=c++11
32+
- os: linux
33+
group: deprecated-2017Q4
34+
compiler: clang
35+
env: BUILD_TYPE=Debug VERBOSE=1
36+
- os: linux
37+
group: deprecated-2017Q4
38+
compiler: clang
39+
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11
40+
- os: linux
41+
compiler: clang
42+
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 NO_EXCEPTION=ON NO_RTTI=ON COMPILER_IS_GNUCXX=ON
43+
- os: osx
44+
compiler: gcc
45+
env: BUILD_TYPE=Debug VERBOSE=1
46+
- os: osx
47+
compiler: gcc
48+
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11
49+
- os: osx
50+
compiler: clang
51+
env: BUILD_TYPE=Debug VERBOSE=1
52+
if: type != pull_request
53+
- os: osx
54+
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11
55+
if: type != pull_request
56+
57+
# These are the install and build (script) phases for the most common entries in the matrix. They could be included
58+
# in each entry in the matrix, but that is just repetitive.
59+
install:
60+
- ./ci/install-${TRAVIS_OS_NAME}.sh
61+
- . ./ci/env-${TRAVIS_OS_NAME}.sh
62+
- ./ci/log-config.sh
63+
64+
script: ./ci/travis.sh
65+
66+
# For sudo=false builds this section installs the necessary dependencies.
67+
addons:
68+
apt:
69+
# List of whitelisted in travis packages for ubuntu-precise can be found here:
70+
# https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise
71+
# List of whitelisted in travis apt-sources:
72+
# https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json
73+
sources:
74+
- ubuntu-toolchain-r-test
75+
- llvm-toolchain-precise-3.9
76+
packages:
77+
- g++-4.9
78+
- clang-3.9
79+
80+
notifications:
81+
email: false

googletest/BUILD.bazel

+180
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# Copyright 2017 Google Inc.
2+
# All Rights Reserved.
3+
#
4+
#
5+
# Redistribution and use in source and binary forms, with or without
6+
# modification, are permitted provided that the following conditions are
7+
# met:
8+
#
9+
# * Redistributions of source code must retain the above copyright
10+
# notice, this list of conditions and the following disclaimer.
11+
# * Redistributions in binary form must reproduce the above
12+
# copyright notice, this list of conditions and the following disclaimer
13+
# in the documentation and/or other materials provided with the
14+
# distribution.
15+
# * Neither the name of Google Inc. nor the names of its
16+
# contributors may be used to endorse or promote products derived from
17+
# this software without specific prior written permission.
18+
#
19+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
#
31+
# Author: misterg@google.com (Gennadiy Civil)
32+
#
33+
# Bazel Build for Google C++ Testing Framework(Google Test)
34+
35+
package(default_visibility = ["//visibility:public"])
36+
37+
licenses(["notice"])
38+
39+
config_setting(
40+
name = "windows",
41+
values = {"cpu": "x64_windows"},
42+
)
43+
44+
config_setting(
45+
name = "windows_msvc",
46+
values = {"cpu": "x64_windows_msvc"},
47+
)
48+
49+
config_setting(
50+
name = "has_absl",
51+
values = {"define": "absl=1"},
52+
)
53+
54+
# Google Test including Google Mock
55+
cc_library(
56+
name = "gtest",
57+
srcs = glob(
58+
include = [
59+
"googletest/src/*.cc",
60+
"googletest/src/*.h",
61+
"googletest/include/gtest/**/*.h",
62+
"googlemock/src/*.cc",
63+
"googlemock/include/gmock/**/*.h",
64+
],
65+
exclude = [
66+
"googletest/src/gtest-all.cc",
67+
"googletest/src/gtest_main.cc",
68+
"googlemock/src/gmock-all.cc",
69+
"googlemock/src/gmock_main.cc",
70+
],
71+
),
72+
hdrs = glob([
73+
"googletest/include/gtest/*.h",
74+
"googlemock/include/gmock/*.h",
75+
]),
76+
copts = select(
77+
{
78+
":windows": [],
79+
":windows_msvc": [],
80+
"//conditions:default": ["-pthread"],
81+
},
82+
),
83+
defines = select(
84+
{
85+
":has_absl": [
86+
"GTEST_HAS_ABSL=1",
87+
],
88+
"//conditions:default": [],
89+
},
90+
),
91+
includes = [
92+
"googlemock",
93+
"googlemock/include",
94+
"googletest",
95+
"googletest/include",
96+
],
97+
linkopts = select({
98+
":windows": [],
99+
":windows_msvc": [],
100+
"//conditions:default": [
101+
"-pthread",
102+
],
103+
}),
104+
deps = select(
105+
{
106+
":has_absl": [
107+
"@com_google_absl//absl/debugging:failure_signal_handler",
108+
"@com_google_absl//absl/debugging:stacktrace",
109+
"@com_google_absl//absl/debugging:symbolize",
110+
"@com_google_absl//absl/strings",
111+
"@com_google_absl//absl/types:optional",
112+
"@com_google_absl//absl/types:variant",
113+
],
114+
"//conditions:default": [],
115+
},
116+
),
117+
)
118+
119+
cc_library(
120+
name = "gtest_main",
121+
srcs = [
122+
"googlemock/src/gmock_main.cc",
123+
],
124+
deps = [":gtest"],
125+
)
126+
127+
# The following rules build samples of how to use gTest.
128+
cc_library(
129+
name = "gtest_sample_lib",
130+
srcs = [
131+
"googletest/samples/sample1.cc",
132+
"googletest/samples/sample2.cc",
133+
"googletest/samples/sample4.cc",
134+
],
135+
hdrs = [
136+
"googletest/samples/prime_tables.h",
137+
"googletest/samples/sample1.h",
138+
"googletest/samples/sample2.h",
139+
"googletest/samples/sample3-inl.h",
140+
"googletest/samples/sample4.h",
141+
],
142+
)
143+
144+
cc_test(
145+
name = "gtest_samples",
146+
size = "small",
147+
#All Samples except:
148+
#sample9 ( main )
149+
#sample10 (main and takes a command line option and needs to be separate)
150+
srcs = [
151+
"googletest/samples/sample1_unittest.cc",
152+
"googletest/samples/sample2_unittest.cc",
153+
"googletest/samples/sample3_unittest.cc",
154+
"googletest/samples/sample4_unittest.cc",
155+
"googletest/samples/sample5_unittest.cc",
156+
"googletest/samples/sample6_unittest.cc",
157+
"googletest/samples/sample7_unittest.cc",
158+
"googletest/samples/sample8_unittest.cc",
159+
],
160+
deps = [
161+
"gtest_sample_lib",
162+
":gtest_main",
163+
],
164+
)
165+
166+
cc_test(
167+
name = "sample9_unittest",
168+
size = "small",
169+
srcs = ["googletest/samples/sample9_unittest.cc"],
170+
deps = [":gtest"],
171+
)
172+
173+
cc_test(
174+
name = "sample10_unittest",
175+
size = "small",
176+
srcs = ["googletest/samples/sample10_unittest.cc"],
177+
deps = [
178+
":gtest",
179+
],
180+
)

googletest/CMakeLists.txt

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
cmake_minimum_required(VERSION 2.8.8)
2+
3+
if (POLICY CMP0048)
4+
cmake_policy(SET CMP0048 NEW)
5+
endif (POLICY CMP0048)
6+
7+
project(googletest-distribution)
8+
set(GOOGLETEST_VERSION 1.9.0)
9+
10+
enable_testing()
11+
12+
include(CMakeDependentOption)
13+
include(GNUInstallDirs)
14+
15+
#Note that googlemock target already builds googletest
16+
option(BUILD_GMOCK "Builds the googlemock subproject" ON)
17+
option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON)
18+
19+
if(BUILD_GMOCK)
20+
add_subdirectory( googlemock )
21+
else()
22+
add_subdirectory( googletest )
23+
endif()

0 commit comments

Comments
 (0)