Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
7d1051ce
Commit
7d1051ce
authored
Jan 13, 2014
by
kosak
Browse files
Make Google Test build cleanly on Visual Studio 2010, 2012, 2013.
Also improve an error message in gtest_test_utils.py.
parent
6576c649
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
14 deletions
+45
-14
CMakeLists.txt
CMakeLists.txt
+16
-8
cmake/internal_utils.cmake
cmake/internal_utils.cmake
+8
-2
include/gtest/internal/gtest-tuple.h
include/gtest/internal/gtest-tuple.h
+8
-0
include/gtest/internal/gtest-tuple.h.pump
include/gtest/internal/gtest-tuple.h.pump
+8
-0
test/gtest-typed-test_test.cc
test/gtest-typed-test_test.cc
+2
-1
test/gtest_test_utils.py
test/gtest_test_utils.py
+3
-3
No files found.
CMakeLists.txt
View file @
7d1051ce
...
@@ -59,6 +59,16 @@ include_directories(
...
@@ -59,6 +59,16 @@ include_directories(
# Where Google Test's libraries can be found.
# Where Google Test's libraries can be found.
link_directories
(
${
gtest_BINARY_DIR
}
/src
)
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
# Defines the gtest & gtest_main libraries. User tests should link
...
@@ -171,12 +181,10 @@ if (gtest_build_tests)
...
@@ -171,12 +181,10 @@ if (gtest_build_tests)
PROPERTIES
PROPERTIES
COMPILE_DEFINITIONS
"GTEST_LINKED_AS_SHARED_LIBRARY=1"
)
COMPILE_DEFINITIONS
"GTEST_LINKED_AS_SHARED_LIBRARY=1"
)
if
(
NOT MSVC OR NOT MSVC_VERSION EQUAL 1600
)
if
(
NOT MSVC OR MSVC_VERSION LESS 1600
)
# 1600 is Visual Studio 2010.
# The C++ Standard specifies tuple_element<int, class>.
# Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that
# Yet MSVC 10's <utility> declares tuple_element<size_t, class>.
# conflict with our own definitions. Therefore using our own tuple does not
# That declaration conflicts with our own standard-conforming
# work on those compilers.
# tuple implementation. Therefore using our own tuple with
# MSVC 10 doesn't compile.
cxx_library
(
gtest_main_use_own_tuple
"
${
cxx_use_own_tuple
}
"
cxx_library
(
gtest_main_use_own_tuple
"
${
cxx_use_own_tuple
}
"
src/gtest-all.cc src/gtest_main.cc
)
src/gtest-all.cc src/gtest_main.cc
)
...
@@ -194,8 +202,8 @@ if (gtest_build_tests)
...
@@ -194,8 +202,8 @@ if (gtest_build_tests)
cxx_executable
(
gtest_break_on_failure_unittest_ test gtest
)
cxx_executable
(
gtest_break_on_failure_unittest_ test gtest
)
py_test
(
gtest_break_on_failure_unittest
)
py_test
(
gtest_break_on_failure_unittest
)
#
MSVC 7.1
does not support STL with exceptions disabled.
#
Visual Studio .NET 2003
does not support STL with exceptions disabled.
if
(
NOT MSVC OR MSVC_VERSION GREATER 1310
)
if
(
NOT MSVC OR MSVC_VERSION GREATER 1310
)
# 1310 is Visual Studio .NET 2003
cxx_executable_with_flags
(
cxx_executable_with_flags
(
gtest_catch_exceptions_no_ex_test_
gtest_catch_exceptions_no_ex_test_
"
${
cxx_no_exception
}
"
"
${
cxx_no_exception
}
"
...
...
cmake/internal_utils.cmake
View file @
7d1051ce
...
@@ -37,7 +37,7 @@ macro(fix_default_compiler_settings_)
...
@@ -37,7 +37,7 @@ macro(fix_default_compiler_settings_)
# We prefer more strict warning checking for building Google Test.
# We prefer more strict warning checking for building Google Test.
# Replaces /W3 with /W4 in defaults.
# Replaces /W3 with /W4 in defaults.
string
(
REPLACE
"/W3"
"
-
W4"
${
flag_var
}
"
${${
flag_var
}}
"
)
string
(
REPLACE
"/W3"
"
/
W4"
${
flag_var
}
"
${${
flag_var
}}
"
)
endforeach
()
endforeach
()
endif
()
endif
()
endmacro
()
endmacro
()
...
@@ -56,7 +56,7 @@ macro(config_compiler_and_linker)
...
@@ -56,7 +56,7 @@ macro(config_compiler_and_linker)
# Newlines inside flags variables break CMake's NMake generator.
# Newlines inside flags variables break CMake's NMake generator.
# TODO(vladl@google.com): Add -RTCs and -RTCu to debug builds.
# TODO(vladl@google.com): Add -RTCs and -RTCu to debug builds.
set
(
cxx_base_flags
"-GS -W4 -WX -wd4127 -wd4251 -wd4275 -nologo -J -Zi"
)
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.
# Suppress spurious warnings MSVC 7.1 sometimes issues.
# Forcing value to bool.
# Forcing value to bool.
set
(
cxx_base_flags
"
${
cxx_base_flags
}
-wd4800"
)
set
(
cxx_base_flags
"
${
cxx_base_flags
}
-wd4800"
)
...
@@ -66,6 +66,12 @@ macro(config_compiler_and_linker)
...
@@ -66,6 +66,12 @@ macro(config_compiler_and_linker)
# Resolved overload was found by argument-dependent lookup.
# Resolved overload was found by argument-dependent lookup.
set
(
cxx_base_flags
"
${
cxx_base_flags
}
-wd4675"
)
set
(
cxx_base_flags
"
${
cxx_base_flags
}
-wd4675"
)
endif
()
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
}
-D_UNICODE -DUNICODE -DWIN32 -D_WIN32"
)
set
(
cxx_base_flags
"
${
cxx_base_flags
}
-DSTRICT -DWIN32_LEAN_AND_MEAN"
)
set
(
cxx_base_flags
"
${
cxx_base_flags
}
-DSTRICT -DWIN32_LEAN_AND_MEAN"
)
set
(
cxx_exception_flags
"-EHsc -D_HAS_EXCEPTIONS=1"
)
set
(
cxx_exception_flags
"-EHsc -D_HAS_EXCEPTIONS=1"
)
...
...
include/gtest/internal/gtest-tuple.h
View file @
7d1051ce
...
@@ -53,6 +53,14 @@
...
@@ -53,6 +53,14 @@
private:
private:
#endif
#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.
// GTEST_n_TUPLE_(T) is the type of an n-tuple.
#define GTEST_0_TUPLE_(T) tuple<>
#define GTEST_0_TUPLE_(T) tuple<>
#define GTEST_1_TUPLE_(T) tuple<T##0, void, void, void, void, void, void, \
#define GTEST_1_TUPLE_(T) tuple<T##0, void, void, void, void, void, void, \
...
...
include/gtest/internal/gtest-tuple.h.pump
View file @
7d1051ce
...
@@ -52,6 +52,14 @@ $$ This meta comment fixes auto-indentation in Emacs. }}
...
@@ -52,6 +52,14 @@ $$ This meta comment fixes auto-indentation in Emacs. }}
private:
private:
#endif
#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
i
0.
.
n
-
1
$
range
j
0.
.
n
$
range
j
0.
.
n
...
...
test/gtest-typed-test_test.cc
View file @
7d1051ce
...
@@ -29,10 +29,11 @@
...
@@ -29,10 +29,11 @@
//
//
// Author: wan@google.com (Zhanyong Wan)
// Author: wan@google.com (Zhanyong Wan)
#include "test/gtest-typed-test_test.h"
#include <set>
#include <set>
#include <vector>
#include <vector>
#include "test/gtest-typed-test_test.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
using
testing
::
Test
;
using
testing
::
Test
;
...
...
test/gtest_test_utils.py
View file @
7d1051ce
...
@@ -175,9 +175,9 @@ def GetTestExecutablePath(executable_name, build_dir=None):
...
@@ -175,9 +175,9 @@ def GetTestExecutablePath(executable_name, build_dir=None):
if
not
os
.
path
.
exists
(
path
):
if
not
os
.
path
.
exists
(
path
):
message
=
(
message
=
(
'Unable to find the test binary. Please make sure to provide
path
\n
'
'Unable to find the test binary
"%s"
. Please make sure to provide
\n
'
'to the binary via the --build_dir flag or the BUILD_DIR
\n
'
'
a path
to the binary via the --build_dir flag or the BUILD_DIR
\n
'
'environment variable.'
)
'environment variable.'
%
path
)
print
>>
sys
.
stderr
,
message
print
>>
sys
.
stderr
,
message
sys
.
exit
(
1
)
sys
.
exit
(
1
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment