Force gtest to expose ::testing::Combine
authorDavid Neto <dneto@google.com>
Mon, 11 Dec 2017 17:05:04 +0000 (12:05 -0500)
committerLei Zhang <antiagainst@google.com>
Tue, 12 Dec 2017 13:58:51 +0000 (08:58 -0500)
Work around faulty logic in googletest, where ::testing::Combine
is accidentally disabled for VS 2017.
See https://github.com/google/googletest/issues/1352

external/CMakeLists.txt
test/CMakeLists.txt

index f31a367..a43c3f8 100644 (file)
@@ -39,6 +39,13 @@ if (NOT ${SPIRV_SKIP_TESTS})
   else()
     set(GMOCK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest/googlemock)
     if(EXISTS ${GMOCK_DIR})
+      if(MSVC)
+        # Our tests use ::testing::Combine.  Work around a compiler
+        # detection problem in googletest, where that template is
+        # accidentally disabled for VS 2017.
+        # See https://github.com/google/googletest/issues/1352
+        add_definitions(-DGTEST_HAS_COMBINE=1)
+      endif()
       if(WIN32)
         option(gtest_force_shared_crt
           "Use shared (DLL) run-time lib even when Google Test is built as static lib."
index f979403..fb8c4b5 100644 (file)
@@ -48,6 +48,10 @@ function(add_spvtools_unittest)
       # We don't care much about that in test code.
       # Important to do since we have warnings-as-errors.
       target_compile_options(${target} PRIVATE /wd4503)
+      # Googletest accidentally turns off support for ::testing::Combine
+      # in VS 2017.  See https://github.com/google/googletest/issues/1352
+      # Forcibly turn it on again.
+      target_compile_options(${target} PRIVATE /DGTEST_HAS_COMBINE=1)
     endif()
     target_include_directories(${target} PRIVATE
       ${SPIRV_HEADER_INCLUDE_DIR}