diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -1405,13 +1405,6 @@ 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/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -421,6 +421,12 @@ append("/Zc:inline" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + # Some projects use the __cplusplus preprocessor macro to check support for + # a particular version of the C++ standard. When this option is not specified + # explicitly, macro's value is "199711L" that implies C++98 Standard. + # https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ + append("/Zc:__cplusplus" CMAKE_CXX_FLAGS) + # Allow users to request PDBs in release mode. CMake offeres the # RelWithDebInfo configuration, but it uses different optimization settings # (/Ob1 vs /Ob2 or -O2 vs -O3). LLVM provides this flag so that users can get diff --git a/llvm/utils/unittest/CMakeLists.txt b/llvm/utils/unittest/CMakeLists.txt --- a/llvm/utils/unittest/CMakeLists.txt +++ b/llvm/utils/unittest/CMakeLists.txt @@ -19,11 +19,6 @@ 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()