add CMAKE_CXX_STANDARD to CMakeLists.txt
this fixes errors related to enabling C++11 like `no member named 'make_tuple' in namespace 'std'` and like `deleted function definitions are a C++11 extension` in googletest/googletest/include/gtest/internal/gtest-port.h
This commit is contained in:
parent
e588eb1ff9
commit
4f12908f43
@ -11,8 +11,17 @@ project(googletest-distribution)
|
|||||||
set(GOOGLETEST_VERSION 1.10.0)
|
set(GOOGLETEST_VERSION 1.10.0)
|
||||||
|
|
||||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.1")
|
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.1")
|
||||||
if(NOT CYGWIN AND NOT MSYS)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_STANDARD_REQUIRED OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
if(MSVC)
|
||||||
|
if(MSVC_TOOLSET_VERSION EQUAL 140 OR MSVC_TOOLSET_VERSION EQUAL 141)
|
||||||
|
# there is a bug reported on https://developercommunity.visualstudio.com/content/problem/9696/c17-not-available-by-default.html
|
||||||
|
# string_view is not available unless we use the /std:c++latest switch
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -2234,21 +2234,38 @@ using StringView = ::absl::string_view;
|
|||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace testing
|
} // namespace testing
|
||||||
#else
|
#else
|
||||||
# ifdef __has_include
|
#ifdef __has_include
|
||||||
# if __has_include(<string_view>) && __cplusplus >= 201703L
|
#if __has_include(<string_view>) && __cplusplus > 201402L
|
||||||
// Otherwise for C++17 and higher use std::string_view for Matcher<>
|
// Otherwise for C++17 and higher use std::string_view for Matcher<>
|
||||||
// specializations.
|
// specializations.
|
||||||
# define GTEST_INTERNAL_HAS_STRING_VIEW 1
|
# define GTEST_INTERNAL_HAS_STRING_VIEW 1
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
namespace testing {
|
namespace testing {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
using StringView = ::std::string_view;
|
using StringView = ::std::string_view;
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace testing
|
} // namespace testing
|
||||||
// The case where absl is configured NOT to alias std::string_view is not
|
// The case where absl is configured NOT to alias std::string_view is not
|
||||||
// supported.
|
// supported.
|
||||||
# endif // __has_include(<string_view>) && __cplusplus >= 201703L
|
# endif // __has_include(<string_view>) && __cplusplus > 201402L
|
||||||
# endif // __has_include
|
#else
|
||||||
|
// well, what if __has_include is not supported by the compiler ? that may be the case with older msvc ?
|
||||||
|
// it might not make sense to actually check for that, since string_view is available from c++17
|
||||||
|
// but uh, let me fix msvc tests for now
|
||||||
|
#if __cplusplus > 201402L
|
||||||
|
// Otherwise for C++17 and higher use std::string_view for Matcher<>
|
||||||
|
// specializations.
|
||||||
|
# define GTEST_INTERNAL_HAS_STRING_VIEW 1
|
||||||
|
#include <string_view>
|
||||||
|
namespace testing {
|
||||||
|
namespace internal {
|
||||||
|
using StringView = ::std::string_view;
|
||||||
|
} // namespace internal
|
||||||
|
} // namespace testing
|
||||||
|
// The case where absl is configured NOT to alias std::string_view is not
|
||||||
|
// supported.
|
||||||
|
#endif
|
||||||
|
# endif // __has_include
|
||||||
#endif // GTEST_HAS_ABSL
|
#endif // GTEST_HAS_ABSL
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
|
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
|
||||||
|
Loading…
x
Reference in New Issue
Block a user