Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 67384e3

Browse files
author
Zachary Turner
committed
Force #define GTEST_LANG_CXX11.
gtest depends on this #define to determine whether it can use various classes like std::tuple, or whether it has to fall back to experimental classes in the std::tr1 namespace. The check in the current version of gtest relies on the value of the `__cplusplus` macro, but MSVC provides a non-conformant value of this macro, making it effectively impossible to detect C++11. In short, LLVM compiled with MSVC has been silently using the tr1 versions of several classes since the beginning of time. This would normally be pretty benign, except that in the latest preview of MSVC they have marked all of the tr1 classes deprecated, so it spews thousands of warnings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316798 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 35ac462 commit 67384e3

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

cmake/modules/AddLLVM.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,13 @@ function(add_unittest test_suite test_name)
10371037
set(EXCLUDE_FROM_ALL ON)
10381038
endif()
10391039

1040+
# Our current version of gtest does not properly recognize C++11 support
1041+
# with MSVC, so it falls back to tr1 / experimental classes. Since LLVM
1042+
# itself requires C++11, we can safely force it on unconditionally so that
1043+
# we don't have to fight with the buggy gtest check.
1044+
add_definitions(-DGTEST_LANG_CXX11=1)
1045+
add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
1046+
10401047
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
10411048
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include)
10421049
if (NOT LLVM_ENABLE_THREADS)

lib/Testing/Support/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
add_definitions(-DGTEST_LANG_CXX11=1)
2+
add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
3+
14
add_llvm_library(LLVMTestingSupport
25
Error.cpp
36

utils/unittest/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ include_directories(
1919
googlemock
2020
)
2121

22+
# LLVM requires C++11 but gtest doesn't correctly detect the availability
23+
# of C++11 on MSVC, so we force it on.
24+
add_definitions(-DGTEST_LANG_CXX11=1)
25+
add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
26+
2227
if(WIN32)
2328
add_definitions(-DGTEST_OS_WINDOWS=1)
2429
endif()

0 commit comments

Comments
 (0)