From e56080ea56840b1e8e43749d130a9b08148fec37 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Thu, 19 Jul 2012 21:15:25 -0700 Subject: [PATCH] Using libc++ with clang from now on This also applies a patch to gtest that resolves an issue with building gtest with libc++. The patch was taken from here: https://groups.google.com/d/topic/googletestframework/F1B9LArL9_U/discussion --- cpp/CMakeLists.txt | 1 + .../gtest/include/gtest/internal/gtest-port.h | 22 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 51b96bf7..67613c31 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -28,6 +28,7 @@ set( CMAKE_OSX_ARCHITECTURES "i386;x86_64" ) if ( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) set( COMPILER_IS_CLANG true ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++" ) endif() # Force release build by default, speed is of the essence diff --git a/cpp/ycm/tests/gmock/gtest/include/gtest/internal/gtest-port.h b/cpp/ycm/tests/gmock/gtest/include/gtest/internal/gtest-port.h index 04938929..faf2d759 100644 --- a/cpp/ycm/tests/gmock/gtest/include/gtest/internal/gtest-port.h +++ b/cpp/ycm/tests/gmock/gtest/include/gtest/internal/gtest-port.h @@ -250,6 +250,11 @@ # define GTEST_OS_QNX 1 #endif // __CYGWIN__ +#if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L +// Compiling in at least C++11 mode. +# define GTEST_LANG_CXX11 1 +#endif + // Brings in definitions for functions used in the testing::internal::posix // namespace (read, write, close, chdir, isatty, stat). We do not currently // use them on Windows Mobile. @@ -458,7 +463,8 @@ // Feature Pack download, which we cannot assume the user has. // QNX's QCC compiler is a modified GCC but it doesn't support TR1 tuple. # if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000) \ - && !GTEST_OS_QNX) || _MSC_VER >= 1600 + && !GTEST_OS_QNX && (GTEST_LANG_CXX11 || !defined(_LIBCPP_VERSION))) \ + || _MSC_VER >= 1600 # define GTEST_USE_OWN_TR1_TUPLE 0 # else # define GTEST_USE_OWN_TR1_TUPLE 1 @@ -473,6 +479,20 @@ # if GTEST_USE_OWN_TR1_TUPLE # include "gtest/internal/gtest-tuple.h" +# elif GTEST_LANG_CXX11 +# include +// C++11 puts its tuple into the ::std namespace rather than +// ::std::tr1. gtest expects tuple to live in ::std::tr1, so put it there. +namespace std { +namespace tr1 { +using ::std::get; +using ::std::make_tuple; +using ::std::tuple; +using ::std::tuple_element; +using ::std::tuple_size; +} +} + # elif GTEST_OS_SYMBIAN // On Symbian, BOOST_HAS_TR1_TUPLE causes Boost's TR1 tuple library to