From 5a266545b483457957f8c30e7eb44d63dfb313a3 Mon Sep 17 00:00:00 2001 From: Omar Sherif Fathy <44799922+o-micron@users.noreply.github.com> Date: Wed, 4 Mar 2020 06:48:59 +0200 Subject: [PATCH 01/13] 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 --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d8834096..ad42eb85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,8 @@ set(GOOGLETEST_VERSION 1.10.0) if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.1") if(NOT CYGWIN AND NOT MSYS) + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) endif() endif() From 114d247f58bed8ba3d3d1ff6cc20ba756cbbed27 Mon Sep 17 00:00:00 2001 From: Omar Sherif Fathy <44799922+o-micron@users.noreply.github.com> Date: Wed, 4 Mar 2020 06:59:53 +0200 Subject: [PATCH 02/13] make sure it builds on macos at least --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad42eb85..3f6d6983 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,9 +12,11 @@ set(GOOGLETEST_VERSION 1.10.0) if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.1") if(NOT CYGWIN AND NOT MSYS) - set(CMAKE_CXX_STANDARD 11) - set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) + if(APPLE) + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + endif() endif() endif() From 6182cf55f9faca656b849bc64d6eed0566aa9087 Mon Sep 17 00:00:00 2001 From: Omar Sherif Fathy <44799922+o-micron@users.noreply.github.com> Date: Wed, 4 Mar 2020 14:23:27 +0200 Subject: [PATCH 03/13] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f6d6983..f59a78fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.1") set(CMAKE_CXX_EXTENSIONS OFF) if(APPLE) set(CMAKE_CXX_STANDARD 11) - set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_STANDARD_REQUIRED OFF) endif() endif() endif() From ac03919a37839851738a8352294b344c37d4a6bf Mon Sep 17 00:00:00 2001 From: Omar Sherif Fathy <44799922+o-micron@users.noreply.github.com> Date: Wed, 4 Mar 2020 06:48:59 +0200 Subject: [PATCH 04/13] 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 --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d8834096..f59a78fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,10 @@ set(GOOGLETEST_VERSION 1.10.0) if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.1") if(NOT CYGWIN AND NOT MSYS) set(CMAKE_CXX_EXTENSIONS OFF) + if(APPLE) + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED OFF) + endif() endif() endif() From ae5e0a101b401fbefcb9267ef1b95bc163f7fcfa Mon Sep 17 00:00:00 2001 From: o-micron Date: Mon, 9 Mar 2020 20:41:20 +0200 Subject: [PATCH 05/13] Probably double check even if absel ?? Maybe that's the problem ? --- googletest/include/gtest/internal/gtest-port.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 60ff4716..1299e705 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -2223,7 +2223,7 @@ const char* StringFromGTestEnv(const char* flag, const char* default_val); #endif // !defined(GTEST_INTERNAL_DEPRECATED) -#if GTEST_HAS_ABSL +#if GTEST_HAS_ABSL && __cplusplus >= 201703L // double check for c++17 support ? // Always use absl::string_view for Matcher<> specializations if googletest // is built with absl support. # define GTEST_INTERNAL_HAS_STRING_VIEW 1 From 5a5f3c116d17e94f6dbed428d06cee965ca7286d Mon Sep 17 00:00:00 2001 From: o-micron Date: Mon, 9 Mar 2020 21:01:14 +0200 Subject: [PATCH 06/13] possible fix --- googletest/include/gtest/gtest-matchers.h | 8 ++++++++ googletest/include/gtest/internal/gtest-port.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/googletest/include/gtest/gtest-matchers.h b/googletest/include/gtest/gtest-matchers.h index a61cef40..e34589c4 100644 --- a/googletest/include/gtest/gtest-matchers.h +++ b/googletest/include/gtest/gtest-matchers.h @@ -432,6 +432,14 @@ class GTEST_API_ Matcher #endif // GTEST_INTERNAL_HAS_STRING_VIEW // Prints a matcher in a human-readable format. +#if GTEST_INTERNAL_HAS_STRING_VIEW +template +std::ostream& operator<<(std::ostream& os, const Matcher& matcher) { + matcher.DescribeTo(&os); + return os; +} +#endif // GTEST_INTERNAL_HAS_STRING_VIEW + template std::ostream& operator<<(std::ostream& os, const Matcher& matcher) { matcher.DescribeTo(&os); diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 1299e705..60ff4716 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -2223,7 +2223,7 @@ const char* StringFromGTestEnv(const char* flag, const char* default_val); #endif // !defined(GTEST_INTERNAL_DEPRECATED) -#if GTEST_HAS_ABSL && __cplusplus >= 201703L // double check for c++17 support ? +#if GTEST_HAS_ABSL // Always use absl::string_view for Matcher<> specializations if googletest // is built with absl support. # define GTEST_INTERNAL_HAS_STRING_VIEW 1 From 20826e06651ee09a9ab7151c128b56d65f2ec1cb Mon Sep 17 00:00:00 2001 From: o-micron Date: Mon, 9 Mar 2020 21:45:06 +0200 Subject: [PATCH 07/13] reset and use local github workflow --- googletest/include/gtest/gtest-matchers.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/googletest/include/gtest/gtest-matchers.h b/googletest/include/gtest/gtest-matchers.h index e34589c4..a61cef40 100644 --- a/googletest/include/gtest/gtest-matchers.h +++ b/googletest/include/gtest/gtest-matchers.h @@ -432,14 +432,6 @@ class GTEST_API_ Matcher #endif // GTEST_INTERNAL_HAS_STRING_VIEW // Prints a matcher in a human-readable format. -#if GTEST_INTERNAL_HAS_STRING_VIEW -template -std::ostream& operator<<(std::ostream& os, const Matcher& matcher) { - matcher.DescribeTo(&os); - return os; -} -#endif // GTEST_INTERNAL_HAS_STRING_VIEW - template std::ostream& operator<<(std::ostream& os, const Matcher& matcher) { matcher.DescribeTo(&os); From 23af0d293eee069f2524b6c82c86b57eb91437af Mon Sep 17 00:00:00 2001 From: o-micron Date: Mon, 9 Mar 2020 22:50:10 +0200 Subject: [PATCH 08/13] I guess one msvc version might not support __has_include ? --- .../include/gtest/internal/gtest-port.h | 44 ++++++++++++------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 60ff4716..b4f76764 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -2234,21 +2234,35 @@ using StringView = ::absl::string_view; } // namespace internal } // namespace testing #else -# ifdef __has_include -# if __has_include() && __cplusplus >= 201703L -// Otherwise for C++17 and higher use std::string_view for Matcher<> -// specializations. -# define GTEST_INTERNAL_HAS_STRING_VIEW 1 -#include -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 // __has_include() && __cplusplus >= 201703L -# endif // __has_include + #ifdef __has_include + #if __has_include() && __cplusplus >= 201703L + // Otherwise for C++17 and higher use std::string_view for Matcher<> + // specializations. + # define GTEST_INTERNAL_HAS_STRING_VIEW 1 + #include + 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 // __has_include() && __cplusplus >= 201703L + #else // well, what if __has_include is not supported by the compiler ? that may be the case with older msvc ? + #if __cplusplus >= 201703L + // Otherwise for C++17 and higher use std::string_view for Matcher<> + // specializations. + # define GTEST_INTERNAL_HAS_STRING_VIEW 1 + #include + 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_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_ From aa35abcd043e0b5acb655dbf8e876b26b8d6fbba Mon Sep 17 00:00:00 2001 From: o-micron Date: Tue, 10 Mar 2020 02:10:18 +0200 Subject: [PATCH 09/13] set CMAKE_CXX_STANDARD=C++11 for all platforms --- CMakeLists.txt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f59a78fe..663bb864 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,13 +11,8 @@ project(googletest-distribution) set(GOOGLETEST_VERSION 1.10.0) if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.1") - if(NOT CYGWIN AND NOT MSYS) - set(CMAKE_CXX_EXTENSIONS OFF) - if(APPLE) - set(CMAKE_CXX_STANDARD 11) - set(CMAKE_CXX_STANDARD_REQUIRED OFF) - endif() - endif() + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED OFF) endif() enable_testing() From e83e5fb7ee7dc2de49d29b74603c504cc67768bc Mon Sep 17 00:00:00 2001 From: o-micron Date: Tue, 10 Mar 2020 03:04:41 +0200 Subject: [PATCH 10/13] replace 201703L with 201402L, for c++1z and 17 --- googletest/include/gtest/internal/gtest-port.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index b4f76764..866183a0 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -2235,7 +2235,7 @@ using StringView = ::absl::string_view; } // namespace testing #else #ifdef __has_include - #if __has_include() && __cplusplus >= 201703L + #if __has_include() && __cplusplus > 201402L // Otherwise for C++17 and higher use std::string_view for Matcher<> // specializations. # define GTEST_INTERNAL_HAS_STRING_VIEW 1 @@ -2247,9 +2247,12 @@ using StringView = ::absl::string_view; } // namespace testing // The case where absl is configured NOT to alias std::string_view is not // supported. - # endif // __has_include() && __cplusplus >= 201703L - #else // well, what if __has_include is not supported by the compiler ? that may be the case with older msvc ? - #if __cplusplus >= 201703L + # endif // __has_include() && __cplusplus > 201402L + #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 From c418b1d3f40855d068f34d6f9b8166962f0565e0 Mon Sep 17 00:00:00 2001 From: o-micron Date: Tue, 10 Mar 2020 04:12:35 +0200 Subject: [PATCH 11/13] Check for a bug fix on string_view and msvc 140 and 141 --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 663bb864..e5e3cd83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,16 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.1") set(CMAKE_CXX_STANDARD_REQUIRED OFF) endif() +if(WIN32) + if(MSVC) + if(MSVC_TOOLSET_VERSION EQUAL 140 OR MSVC_TOOLSET_VERSION EQUAL 140) + # 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() + enable_testing() include(CMakeDependentOption) From e0ff47922113f1877ab9fd39c38b190d22b3f96a Mon Sep 17 00:00:00 2001 From: o-micron Date: Tue, 10 Mar 2020 08:33:55 +0200 Subject: [PATCH 12/13] Small typo 140 OR 141 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5e3cd83..472bf2f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ endif() if(WIN32) if(MSVC) - if(MSVC_TOOLSET_VERSION EQUAL 140 OR MSVC_TOOLSET_VERSION EQUAL 140) + 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") From 7726e910fb4c0e4bda71875bd8bda44311e78c89 Mon Sep 17 00:00:00 2001 From: o-micron Date: Tue, 10 Mar 2020 09:03:59 +0200 Subject: [PATCH 13/13] Remove extra msvc settings from cmakelists for now --- CMakeLists.txt | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 472bf2f8..ad1693f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,18 +11,13 @@ project(googletest-distribution) set(GOOGLETEST_VERSION 1.10.0) if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.1") - set(CMAKE_CXX_STANDARD 11) - 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") + if(NOT CYGWIN AND NOT MSYS) + set(CMAKE_CXX_EXTENSIONS OFF) + if(APPLE) + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED OFF) + endif() endif() - endif() endif() enable_testing()