From 1ae4096b9c5de4429663e6b0c09bf00e5fb46b16 Mon Sep 17 00:00:00 2001 From: Bryan Zimmerman Date: Fri, 27 Oct 2017 14:01:16 -0400 Subject: [PATCH] fix for VS2017 deprecation of ::tr1::tuple change static_cast to ImplicitCast_ for consitency fixes for building with path names containing spaces --- googlemock/CMakeLists.txt | 12 +++++++----- .../test/gmock-generated-matchers_test.cc | 9 +++++---- googletest/CMakeLists.txt | 18 ++++++++++-------- googletest/cmake/internal_utils.cmake | 3 ++- googletest/include/gtest/internal/gtest-port.h | 5 ++++- googletest/test/gtest-printers_test.cc | 6 +++--- 6 files changed, 31 insertions(+), 22 deletions(-) diff --git a/googlemock/CMakeLists.txt b/googlemock/CMakeLists.txt index 724fdd5f..2051f15b 100644 --- a/googlemock/CMakeLists.txt +++ b/googlemock/CMakeLists.txt @@ -74,6 +74,8 @@ include_directories("${gmock_SOURCE_DIR}/include" # <= VS 2010 <= 10 <= 1600 Use Google Tests's own tuple. # VS 2012 11 1700 std::tr1::tuple + _VARIADIC_MAX=10 # VS 2013 12 1800 std::tr1::tuple +# VS 2015 14 1900 std::tuple +# VS 2017 15 1910 std::tuple if (MSVC AND MSVC_VERSION EQUAL 1700) add_definitions(/D _VARIADIC_MAX=10) endif() @@ -110,11 +112,11 @@ endif() # Install rules if(INSTALL_GMOCK) install(TARGETS gmock gmock_main - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - install(DIRECTORY ${gmock_SOURCE_DIR}/include/gmock - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}") + install(DIRECTORY "${gmock_SOURCE_DIR}/include/gmock" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") # configure and install pkgconfig files configure_file( diff --git a/googlemock/test/gmock-generated-matchers_test.cc b/googlemock/test/gmock-generated-matchers_test.cc index 6cba726d..9eb4b258 100644 --- a/googlemock/test/gmock-generated-matchers_test.cc +++ b/googlemock/test/gmock-generated-matchers_test.cc @@ -64,6 +64,7 @@ using testing::ElementsAreArray; using testing::Eq; using testing::Ge; using testing::Gt; +using testing::internal::ImplicitCast_; using testing::Le; using testing::Lt; using testing::MakeMatcher; @@ -120,7 +121,7 @@ TEST(ArgsTest, AcceptsOneTemplateArg) { } TEST(ArgsTest, AcceptsTwoTemplateArgs) { - const tuple t(static_cast(4), 5, 6L); // NOLINT + const tuple t(ImplicitCast_(4), 5, 6L); // NOLINT EXPECT_THAT(t, (Args<0, 1>(Lt()))); EXPECT_THAT(t, (Args<1, 2>(Lt()))); @@ -128,13 +129,13 @@ TEST(ArgsTest, AcceptsTwoTemplateArgs) { } TEST(ArgsTest, AcceptsRepeatedTemplateArgs) { - const tuple t(static_cast(4), 5, 6L); // NOLINT + const tuple t(ImplicitCast_(4), 5, 6L); // NOLINT EXPECT_THAT(t, (Args<0, 0>(Eq()))); EXPECT_THAT(t, Not(Args<1, 1>(Ne()))); } TEST(ArgsTest, AcceptsDecreasingTemplateArgs) { - const tuple t(static_cast(4), 5, 6L); // NOLINT + const tuple t(ImplicitCast_(4), 5, 6L); // NOLINT EXPECT_THAT(t, (Args<2, 0>(Gt()))); EXPECT_THAT(t, Not(Args<2, 1>(Lt()))); } @@ -159,7 +160,7 @@ TEST(ArgsTest, AcceptsMoreTemplateArgsThanArityOfOriginalTuple) { } TEST(ArgsTest, CanBeNested) { - const tuple t(static_cast(4), 5, 6L, 6); // NOLINT + const tuple t(ImplicitCast_(4), 5, 6L, 6); // NOLINT EXPECT_THAT(t, (Args<1, 2, 3>(Args<1, 2>(Eq())))); EXPECT_THAT(t, (Args<0, 1, 3>(Args<0, 2>(Lt())))); } diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt index b9a920b7..8d4ab405 100644 --- a/googletest/CMakeLists.txt +++ b/googletest/CMakeLists.txt @@ -74,8 +74,8 @@ config_compiler_and_linker() # Defined in internal_utils.cmake. # Where Google Test's .h files can be found. include_directories( - ${gtest_SOURCE_DIR}/include - ${gtest_SOURCE_DIR}) + "${gtest_SOURCE_DIR}/include" + "${gtest_SOURCE_DIR}") # Summary of tuple support for Microsoft Visual Studio: # Compiler version(MS) version(cmake) Support @@ -83,10 +83,12 @@ include_directories( # <= VS 2010 <= 10 <= 1600 Use Google Tests's own tuple. # VS 2012 11 1700 std::tr1::tuple + _VARIADIC_MAX=10 # VS 2013 12 1800 std::tr1::tuple +# VS 2015 14 1900 std::tuple +# VS 2017 15 1910 std::tuple if (MSVC AND MSVC_VERSION EQUAL 1700) add_definitions(/D _VARIADIC_MAX=10) endif() - + ######################################################################## # # Defines the gtest & gtest_main libraries. User tests should link @@ -112,11 +114,11 @@ endif() # Install rules if(INSTALL_GTEST) install(TARGETS gtest gtest_main - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) - install(DIRECTORY ${gtest_SOURCE_DIR}/include/gtest - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") + install(DIRECTORY "${gtest_SOURCE_DIR}/include/gtest" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") # configure and install pkgconfig files configure_file( diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index c54bc94f..d1f81e63 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -62,7 +62,8 @@ macro(config_compiler_and_linker) if (MSVC) # Newlines inside flags variables break CMake's NMake generator. # TODO(vladl@google.com): Add -RTCs and -RTCu to debug builds. - set(cxx_base_flags "-GS -W4 -WX -wd4251 -wd4275 -nologo -J -Zi") + # -J does not set path correctly for pdb with spaces + set(cxx_base_flags "-GS -W4 -WX -wd4251 -wd4275 -nologo -Zi") if (MSVC_VERSION LESS 1400) # 1400 is Visual Studio 2005 # Suppress spurious warnings MSVC 7.1 sometimes issues. # Forcing value to bool. diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 0c360072..55f9237a 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -642,8 +642,11 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; # if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR) // STLport, provided with the Android NDK, has neither or . # define GTEST_HAS_TR1_TUPLE 0 +# elif _MSC_VER >= 1910 + // VS2017 deprecated ::tr1::tuple +# define GTEST_HAS_TR1_TUPLE 0 # else -// The user didn't tell us not to do it, so we assume it's OK. + // The user didn't tell us not to do it, so we assume it's OK. # define GTEST_HAS_TR1_TUPLE 1 # endif #endif // GTEST_HAS_TR1_TUPLE diff --git a/googletest/test/gtest-printers_test.cc b/googletest/test/gtest-printers_test.cc index 2a6c017e..d922ba69 100644 --- a/googletest/test/gtest-printers_test.cc +++ b/googletest/test/gtest-printers_test.cc @@ -1092,8 +1092,8 @@ TEST(PrintTr1TupleTest, VariousSizes) { ::std::tr1::tuple - t10(false, 'a', static_cast(3), 4, 5, 1.5F, -2.5, str, - ImplicitCast_(NULL), "10"); + t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str, ImplicitCast_(NULL), + "10"); EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) + " pointing to \"8\", NULL, \"10\")", Print(t10)); @@ -1152,7 +1152,7 @@ TEST(PrintStdTupleTest, VariousSizes) { ::std::tuple - t10(false, 'a', static_cast(3), 4, 5, 1.5F, -2.5, str, + t10(false, 'a', ImplicitCast_(3), 4, 5, 1.5F, -2.5, str, ImplicitCast_(NULL), "10"); EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) + " pointing to \"8\", NULL, \"10\")",