Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failures with gtest 1.13+ #529

Open
doronbehar opened this issue Mar 15, 2024 · 1 comment
Open

failures with gtest 1.13+ #529

doronbehar opened this issue Mar 15, 2024 · 1 comment

Comments

@doronbehar
Copy link

At NixOS we are experiencing this error with our own gtest 1.14:

       > /build/source/googletest/googletest/include/gtest/gtest.h:302:41: error: expected '>' before '<' token
       >   302 |   template <typename T, std::enable_if_t<std::is_convertible<T, int64_t>::value,
       >       |                                         ^
       > make[3]: *** [tests/src/CMakeFiles/wpa2_decrypt_test.dir/build.make:76: tests/src/CMakeFiles/wpa2_decrypt_test.dir/wpa2_decrypt_test.cpp.o] Error 1
       > make[3]: Leaving directory '/build/source/build'
       > make[2]: *** [CMakeFiles/Makefile2:2383: tests/src/CMakeFiles/wpa2_decrypt_test.dir/all] Error 2
       > make[2]: Leaving directory '/build/source/build'
       > make[1]: *** [CMakeFiles/Makefile2:830: tests/src/CMakeFiles/tests.dir/rule] Error 2
       > make[1]: Leaving directory '/build/source/build'
       > make: *** [Makefile:439: tests] Error 2

We managed to fix the tests with this patch:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 902233e676ee..49ac8a1010a4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -103,17 +103,9 @@ ENDIF()
 # C++11 support
 OPTION(LIBTINS_ENABLE_CXX11 "Compile libtins with c++11 features" ON)
 IF(LIBTINS_ENABLE_CXX11)
-    # We only use declval and decltype on gcc/clang as VC fails to build that code,
-    # at least on VC2013
-    IF(HAS_CXX11_RVALUE_REFERENCES AND HAS_CXX11_FUNCTIONAL AND HAS_CXX11_CHRONO AND
-       HAS_CXX11_NOEXCEPT AND ((HAS_CXX11_DECLVAL AND HAS_CXX11_DECLTYPE) OR MSVC))
-        SET(TINS_HAVE_CXX11 ON)
-        MESSAGE(STATUS "Enabling C++11 features")
-        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS}")
-    ELSE()
-        MESSAGE(WARNING "The compiler doesn't support the necessary C++11 features. "
-                        "Disabling C++11 on this build")
-    ENDIF()
+    SET(TINS_HAVE_CXX11 ON)
+    MESSAGE(STATUS "Using C++11 features")
+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
 ELSE(LIBTINS_ENABLE_CXX11)
     MESSAGE(
         WARNING

But it's a bit hard coding. I'm not the downstream maintainer, so I might not have time to help you debug this on our end, but I'm ought to tell you.

@GiulioCocconi
Copy link

GiulioCocconi commented Mar 17, 2024

Maybe you could keep the check logic and call set_property(TARGET tests PROPERTY CXX_STANDARD 14) in tests/src/CMakeLists.txt. This way the library keeps using C++11 for the actual code and switches to C++14 only for gtests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants