Make Google Test build cleanly on Visual Studio 2010, 2012, 2013.
Also improve an error message in gtest_test_utils.py.
This commit is contained in:
		@@ -59,6 +59,16 @@ include_directories(
 | 
			
		||||
# Where Google Test's libraries can be found.
 | 
			
		||||
link_directories(${gtest_BINARY_DIR}/src)
 | 
			
		||||
 | 
			
		||||
# Summary of tuple support for Microsoft Visual Studio:
 | 
			
		||||
# Compiler    version(MS)  version(cmake)  Support
 | 
			
		||||
# ----------  -----------  --------------  -----------------------------
 | 
			
		||||
# <= 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
 | 
			
		||||
if (MSVC AND MSVC_VERSION EQUAL 1700)
 | 
			
		||||
  add_definitions(/D _VARIADIC_MAX=10)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
########################################################################
 | 
			
		||||
#
 | 
			
		||||
# Defines the gtest & gtest_main libraries.  User tests should link
 | 
			
		||||
@@ -171,12 +181,10 @@ if (gtest_build_tests)
 | 
			
		||||
                        PROPERTIES
 | 
			
		||||
                        COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
 | 
			
		||||
 | 
			
		||||
  if (NOT MSVC OR NOT MSVC_VERSION EQUAL 1600)
 | 
			
		||||
    # The C++ Standard specifies tuple_element<int, class>.
 | 
			
		||||
    # Yet MSVC 10's <utility> declares tuple_element<size_t, class>.
 | 
			
		||||
    # That declaration conflicts with our own standard-conforming
 | 
			
		||||
    # tuple implementation.  Therefore using our own tuple with
 | 
			
		||||
    # MSVC 10 doesn't compile.
 | 
			
		||||
  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(gtest_main_use_own_tuple "${cxx_use_own_tuple}"
 | 
			
		||||
      src/gtest-all.cc src/gtest_main.cc)
 | 
			
		||||
 | 
			
		||||
@@ -194,8 +202,8 @@ if (gtest_build_tests)
 | 
			
		||||
  cxx_executable(gtest_break_on_failure_unittest_ test gtest)
 | 
			
		||||
  py_test(gtest_break_on_failure_unittest)
 | 
			
		||||
 | 
			
		||||
  # MSVC 7.1 does not support STL with exceptions disabled.
 | 
			
		||||
  if (NOT MSVC OR MSVC_VERSION GREATER 1310)
 | 
			
		||||
  # Visual Studio .NET 2003 does not support STL with exceptions disabled.
 | 
			
		||||
  if (NOT MSVC OR MSVC_VERSION GREATER 1310)  # 1310 is Visual Studio .NET 2003
 | 
			
		||||
    cxx_executable_with_flags(
 | 
			
		||||
      gtest_catch_exceptions_no_ex_test_
 | 
			
		||||
      "${cxx_no_exception}"
 | 
			
		||||
 
 | 
			
		||||
@@ -37,7 +37,7 @@ macro(fix_default_compiler_settings_)
 | 
			
		||||
 | 
			
		||||
      # We prefer more strict warning checking for building Google Test.
 | 
			
		||||
      # Replaces /W3 with /W4 in defaults.
 | 
			
		||||
      string(REPLACE "/W3" "-W4" ${flag_var} "${${flag_var}}")
 | 
			
		||||
      string(REPLACE "/W3" "/W4" ${flag_var} "${${flag_var}}")
 | 
			
		||||
    endforeach()
 | 
			
		||||
  endif()
 | 
			
		||||
endmacro()
 | 
			
		||||
@@ -56,7 +56,7 @@ macro(config_compiler_and_linker)
 | 
			
		||||
    # 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 -wd4127 -wd4251 -wd4275 -nologo -J -Zi")
 | 
			
		||||
    if (MSVC_VERSION LESS 1400)
 | 
			
		||||
    if (MSVC_VERSION LESS 1400)  # 1400 is Visual Studio 2005
 | 
			
		||||
      # Suppress spurious warnings MSVC 7.1 sometimes issues.
 | 
			
		||||
      # Forcing value to bool.
 | 
			
		||||
      set(cxx_base_flags "${cxx_base_flags} -wd4800")
 | 
			
		||||
@@ -66,6 +66,12 @@ macro(config_compiler_and_linker)
 | 
			
		||||
      # Resolved overload was found by argument-dependent lookup.
 | 
			
		||||
      set(cxx_base_flags "${cxx_base_flags} -wd4675")
 | 
			
		||||
    endif()
 | 
			
		||||
    if (NOT (MSVC_VERSION LESS 1700))  # 1700 is Visual Studio 2012.
 | 
			
		||||
      # Suppress "unreachable code" warning on VS 2012 and later.
 | 
			
		||||
      # http://stackoverflow.com/questions/3232669 explains the issue.
 | 
			
		||||
      set(cxx_base_flags "${cxx_base_flags} -wd4702")
 | 
			
		||||
    endif()
 | 
			
		||||
 | 
			
		||||
    set(cxx_base_flags "${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32")
 | 
			
		||||
    set(cxx_base_flags "${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN")
 | 
			
		||||
    set(cxx_exception_flags "-EHsc -D_HAS_EXCEPTIONS=1")
 | 
			
		||||
 
 | 
			
		||||
@@ -53,6 +53,14 @@
 | 
			
		||||
   private:
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// 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.
 | 
			
		||||
#if defined(_MSC_VER) && _MSC_VER >= 1600  /* 1600 is Visual Studio 2010 */
 | 
			
		||||
# error "gtest's tuple doesn't compile on Visual Studio 2010 or later. \
 | 
			
		||||
GTEST_USE_OWN_TR1_TUPLE must be set to 0 on those compilers."
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// GTEST_n_TUPLE_(T) is the type of an n-tuple.
 | 
			
		||||
#define GTEST_0_TUPLE_(T) tuple<>
 | 
			
		||||
#define GTEST_1_TUPLE_(T) tuple<T##0, void, void, void, void, void, void, \
 | 
			
		||||
 
 | 
			
		||||
@@ -52,6 +52,14 @@ $$ This meta comment fixes auto-indentation in Emacs. }}
 | 
			
		||||
   private:
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// 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.
 | 
			
		||||
#if defined(_MSC_VER) && _MSC_VER >= 1600  /* 1600 is Visual Studio 2010 */
 | 
			
		||||
# error "gtest's tuple doesn't compile on Visual Studio 2010 or later. \
 | 
			
		||||
GTEST_USE_OWN_TR1_TUPLE must be set to 0 on those compilers."
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
$range i 0..n-1
 | 
			
		||||
$range j 0..n
 | 
			
		||||
 
 | 
			
		||||
@@ -29,10 +29,11 @@
 | 
			
		||||
//
 | 
			
		||||
// Author: wan@google.com (Zhanyong Wan)
 | 
			
		||||
 | 
			
		||||
#include "test/gtest-typed-test_test.h"
 | 
			
		||||
 | 
			
		||||
#include <set>
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
#include "test/gtest-typed-test_test.h"
 | 
			
		||||
#include "gtest/gtest.h"
 | 
			
		||||
 | 
			
		||||
using testing::Test;
 | 
			
		||||
 
 | 
			
		||||
@@ -175,9 +175,9 @@ def GetTestExecutablePath(executable_name, build_dir=None):
 | 
			
		||||
 | 
			
		||||
  if not os.path.exists(path):
 | 
			
		||||
    message = (
 | 
			
		||||
        'Unable to find the test binary. Please make sure to provide path\n'
 | 
			
		||||
        'to the binary via the --build_dir flag or the BUILD_DIR\n'
 | 
			
		||||
        'environment variable.')
 | 
			
		||||
        'Unable to find the test binary "%s". Please make sure to provide\n'
 | 
			
		||||
        'a path to the binary via the --build_dir flag or the BUILD_DIR\n'
 | 
			
		||||
        'environment variable.' % path)
 | 
			
		||||
    print >> sys.stderr, message
 | 
			
		||||
    sys.exit(1)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user