-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix double free when building Gtest/GMock in shared libraries and lin… #1339
Changes from all commits
0663ce9
cdedd18
0e6da4c
f6887b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,16 +88,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 | ||
|
@@ -177,23 +184,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}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously |
||
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) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it necessary to keep doing it that way for MSVC? Wouldn't the
target_link_libraries
way work fine?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently not if I believe #1286. But the original build issue seems not available anymore. I have honestly not tried myself (and don't have any Windows machine beyond the continuous integration ones).