forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gtest-1.8.0-fix-doublefree.patch
98 lines (90 loc) · 4.08 KB
/
gtest-1.8.0-fix-doublefree.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
Bug: https://bugs.gentoo.org/631698
Upstream PR: https://github.com/google/googletest/pull/1339
From 0663ce9024c9b78ddf6eb3fc1ceb45361ed91767 Mon Sep 17 00:00:00 2001
From: Romain Geissler <[email protected]>
Date: Sat, 2 Dec 2017 22:47:20 +0100
Subject: [PATCH] Fix double free when building Gtest/GMock in shared libraries
and linking a test executable with both.
---
googlemock/CMakeLists.txt | 63 ++++++++++++++++++++++++++++++-----------------
1 file changed, 40 insertions(+), 23 deletions(-)
diff --git a/googlemock/CMakeLists.txt b/googlemock/CMakeLists.txt
index 724fdd5f0..f7bad8afc 100644
--- a/googlemock/CMakeLists.txt
+++ b/googlemock/CMakeLists.txt
@@ -86,16 +86,23 @@ endif()
# Google Mock libraries. We build them using more strict warnings than what
# are used for other targets, to ensure that Google Mock can be compiled by
# a user aggressive about warnings.
-cxx_library(gmock
- "${cxx_strict}"
- "${gtest_dir}/src/gtest-all.cc"
- src/gmock-all.cc)
-
-cxx_library(gmock_main
- "${cxx_strict}"
- "${gtest_dir}/src/gtest-all.cc"
- src/gmock-all.cc
- src/gmock_main.cc)
+if (MSVC)
+ cxx_library(gmock
+ "${cxx_strict}"
+ "${gtest_dir}/src/gtest-all.cc"
+ src/gmock-all.cc)
+
+ cxx_library(gmock_main
+ "${cxx_strict}"
+ "${gtest_dir}/src/gtest-all.cc"
+ src/gmock-all.cc
+ src/gmock_main.cc)
+else()
+ cxx_library(gmock "${cxx_strict}" src/gmock-all.cc)
+ target_link_libraries(gmock gtest)
+ cxx_library(gmock_main "${cxx_strict}" src/gmock_main.cc)
+ target_link_libraries(gmock_main gmock)
+endif()
# If the CMake version supports it, attach header directory information
# to the targets for when we are part of a parent build (ie being pulled
@@ -175,23 +182,33 @@ if (gmock_build_tests)
############################################################
# C++ tests built with non-standard compiler flags.
- cxx_library(gmock_main_no_exception "${cxx_no_exception}"
- "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
-
- cxx_library(gmock_main_no_rtti "${cxx_no_rtti}"
- "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
+ if (MSVC)
+ cxx_library(gmock_main_no_exception "${cxx_no_exception}"
+ "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
- if (NOT MSVC OR MSVC_VERSION LESS 1600) # 1600 is Visual Studio 2010.
- # Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that
- # conflict with our own definitions. Therefore using our own tuple does not
- # work on those compilers.
- cxx_library(gmock_main_use_own_tuple "${cxx_use_own_tuple}"
+ cxx_library(gmock_main_no_rtti "${cxx_no_rtti}"
"${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
- cxx_test_with_flags(gmock_use_own_tuple_test "${cxx_use_own_tuple}"
- gmock_main_use_own_tuple test/gmock-spec-builders_test.cc)
+ if (MSVC_VERSION LESS 1600) # 1600 is Visual Studio 2010.
+ # Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that
+ # conflict with our own definitions. Therefore using our own tuple does not
+ # work on those compilers.
+ cxx_library(gmock_main_use_own_tuple "${cxx_use_own_tuple}"
+ "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
+
+ cxx_test_with_flags(gmock_use_own_tuple_test "${cxx_use_own_tuple}"
+ gmock_main_use_own_tuple test/gmock-spec-builders_test.cc)
+ endif()
+ else()
+ cxx_library(gmock_main_no_exception "${cxx_no_exception}" src/gmock_main.cc)
+ target_link_libraries(gmock_main_no_exception gmock)
+
+ cxx_library(gmock_main_no_rtti "${cxx_no_rtti}" src/gmock_main.cc)
+ target_link_libraries(gmock_main_no_rtti gmock)
+
+ cxx_library(gmock_main_use_own_tuple "${cxx_use_own_tuple}" src/gmock_main.cc)
+ target_link_libraries(gmock_main_use_own_tuple gmock)
endif()
-
cxx_test_with_flags(gmock-more-actions_no_exception_test "${cxx_no_exception}"
gmock_main_no_exception test/gmock-more-actions_test.cc)