Add patch to fix gmock segfaults (rhbz#1513522)

- Add patch to properly version the libraries
- Move the documentation to the right place
- Drop unneeded ldconfig scriptlets
  - See https://fedoraproject.org/wiki/Changes/Removing_ldconfig_scriptlets
epel9
Neal Gompa 7 years ago
parent 7ec8af2a4b
commit 3b40a241cb

@ -0,0 +1,98 @@
From 0663ce9024c9b78ddf6eb3fc1ceb45361ed91767 Mon Sep 17 00:00:00 2001
From: Romain Geissler <romain.geissler@gmail.com>
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 724fdd5..f7bad8a 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)
--
2.14.3

@ -0,0 +1,28 @@
diff --git a/googlemock/CMakeLists.txt b/googlemock/CMakeLists.txt
index 4304995..5ca735b 100644
--- a/googlemock/CMakeLists.txt
+++ b/googlemock/CMakeLists.txt
@@ -99,6 +99,9 @@ else()
target_link_libraries(gmock_main gmock)
endif()
+set_target_properties(gmock PROPERTIES VERSION 1.8.0)
+set_target_properties(gmock_main PROPERTIES VERSION 1.8.0)
+
# 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
# in via add_subdirectory() rather than being a standalone build).
diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt
index ab82f23..97f7554 100644
--- a/googletest/CMakeLists.txt
+++ b/googletest/CMakeLists.txt
@@ -88,7 +88,9 @@ endif()
# are used for other targets, to ensure that gtest can be compiled by a user
# aggressive about warnings.
cxx_library(gtest "${cxx_strict}" src/gtest-all.cc)
+set_target_properties(gtest PROPERTIES VERSION 1.8.0)
cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc)
+set_target_properties(gtest_main PROPERTIES VERSION 1.8.0)
target_link_libraries(gtest_main gtest)
# If the CMake version supports it, attach header directory information

@ -1,7 +1,7 @@
Summary: Google C++ testing framework
Name: gtest
Version: 1.8.0
Release: 2%{?dist}
Release: 3%{?dist}
License: BSD
URL: https://github.com/google/googletest
Source0: https://github.com/google/googletest/archive/release-%{version}.tar.gz
@ -9,6 +9,15 @@ Source0: https://github.com/google/googletest/archive/release-%{version}.
Patch0: gtest-1.8.0-libdir.patch
# https://github.com/google/googletest/issues/845
Patch1: gtest-1.8.0-null-pointer.patch
# https://github.com/google/googletest/issues/930
# https://bugzilla.redhat.com/show_bug.cgi?id=1513522
Patch2: gtest-1.8.0-fix-double-free-with-shared-libs.patch
# Fedora-specific patches
## Set libversion for libraries to version of gtest
## WARNING: must be rediffed for each version bump
Patch100: gtest-1.8.0-libversion.patch
BuildRequires: cmake
BuildRequires: python-devel
%description
@ -70,32 +79,39 @@ cd build
cd build
make test
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%license googletest/LICENSE
%doc googletest/{CHANGES,CONTRIBUTORS,README.md}
%doc googletest/docs/
%{_libdir}/libgtest.so
%{_libdir}/libgtest_main.so
%{_libdir}/libgtest.so.%{version}
%{_libdir}/libgtest_main.so.%{version}
%files -n gtest-devel
%doc googletest/{CHANGES,CONTRIBUTORS,README.md}
%doc googletest/docs/
%doc googletest/samples
%{_includedir}/gtest/
%{_libdir}/libgtest.so
%{_libdir}/libgtest_main.so
%files -n gmock
%license googlemock/LICENSE
%{_libdir}/libgmock.so.%{version}
%{_libdir}/libgmock_main.so.%{version}
%files -n gmock-devel
%doc googlemock/{CHANGES,CONTRIBUTORS,README.md}
%doc googlemock/docs/
%{_includedir}/gmock/
%{_libdir}/libgmock.so
%{_libdir}/libgmock_main.so
%files -n gmock-devel
%{_includedir}/gmock/
%changelog
* Wed Feb 14 2018 Neal Gompa <ngompa13@gmail.com> - 1.8.0-3
- Add patch to fix gmock segfaults (rhbz#1513522)
- Add patch to properly version the libraries
- Move the documentation to the right place
- Drop unneeded ldconfig scriptlets
- See https://fedoraproject.org/wiki/Changes/Removing_ldconfig_scriptlets
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.8.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

Loading…
Cancel
Save