summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-10-27 21:12:28 +0000
committerZachary Turner <zturner@google.com>2017-10-27 21:12:28 +0000
commit94f5032aedbd49e2f828e2bb31c006332c2bcaa7 (patch)
tree3f371f35dd0b90cc8654779aba139d995f54adcd
parentd69453290ebeb65dd7d5411166aba0b1443d53f2 (diff)
downloadbcm5719-llvm-94f5032aedbd49e2f828e2bb31c006332c2bcaa7.tar.gz
bcm5719-llvm-94f5032aedbd49e2f828e2bb31c006332c2bcaa7.zip
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. llvm-svn: 316798
-rw-r--r--llvm/cmake/modules/AddLLVM.cmake7
-rw-r--r--llvm/lib/Testing/Support/CMakeLists.txt3
-rw-r--r--llvm/utils/unittest/CMakeLists.txt5
3 files changed, 15 insertions, 0 deletions
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 3952d041344..f52b1c44ab2 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1037,6 +1037,13 @@ function(add_unittest test_suite test_name)
set(EXCLUDE_FROM_ALL ON)
endif()
+ # Our current version of gtest does not properly recognize C++11 support
+ # with MSVC, so it falls back to tr1 / experimental classes. Since LLVM
+ # itself requires C++11, we can safely force it on unconditionally so that
+ # we don't have to fight with the buggy gtest check.
+ add_definitions(-DGTEST_LANG_CXX11=1)
+ add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
+
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include)
if (NOT LLVM_ENABLE_THREADS)
diff --git a/llvm/lib/Testing/Support/CMakeLists.txt b/llvm/lib/Testing/Support/CMakeLists.txt
index fa8dfe59c8b..8ab6fd9a25a 100644
--- a/llvm/lib/Testing/Support/CMakeLists.txt
+++ b/llvm/lib/Testing/Support/CMakeLists.txt
@@ -1,3 +1,6 @@
+add_definitions(-DGTEST_LANG_CXX11=1)
+add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
+
add_llvm_library(LLVMTestingSupport
Error.cpp
diff --git a/llvm/utils/unittest/CMakeLists.txt b/llvm/utils/unittest/CMakeLists.txt
index b42ac834e3a..5b5cbf5d745 100644
--- a/llvm/utils/unittest/CMakeLists.txt
+++ b/llvm/utils/unittest/CMakeLists.txt
@@ -19,6 +19,11 @@ include_directories(
googlemock
)
+# LLVM requires C++11 but gtest doesn't correctly detect the availability
+# of C++11 on MSVC, so we force it on.
+add_definitions(-DGTEST_LANG_CXX11=1)
+add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
+
if(WIN32)
add_definitions(-DGTEST_OS_WINDOWS=1)
endif()
OpenPOWER on IntegriCloud