google / s2geometry

Computational geometry and spatial indexing on the sphere
http://s2geometry.io/
Apache License 2.0
2.29k stars 302 forks source link

s2loop_test: Build fails with recent versions of abseil #357

Open benstadin opened 5 months ago

benstadin commented 5 months ago

https://github.com/google/s2geometry/blob/7940c9f791819211782bd7df51632657172c17c2/src/s2/s2loop_test.cc#L1146

S2 fails to build with recent versions of abseil at places where HasSubstr ist used. Replacing the string_view with a string works (as a workaround): EXPECT_THAT(error.text(), testing::HasSubstr(std::string(snippet)));

jmr commented 5 months ago

Please include the error you're getting.

Is absl::string_view == std::string_view for you?

benstadin commented 5 months ago

Yes. Abseil is built from source using the current LTS version (git tag 20240116.1)

In file included from /root/s2geometry/googletest/googlemock/include/gmock/gmock-spec-builders.h:75,
                 from /root/s2geometry/googletest/googlemock/include/gmock/gmock-generated-function-mockers.h:47,
                 from /root/s2geometry/googletest/googlemock/include/gmock/gmock-function-mocker.h:39,
                 from /root/s2geometry/googletest/googlemock/include/gmock/gmock.h:61,
                 from /root/s2geometry/src/s2/s2error_test.cc:22:
/root/s2geometry/googletest/googlemock/include/gmock/gmock-matchers.h: In instantiation of 'bool testing::internal::HasSubstrMatcher<StringType>::MatchAndExplain(const MatcheeStringType&, testing::MatchResultListener*) const [with MatcheeStringType = std::basic_string_view<char>; StringType = std::__cxx11::basic_string<char>]':
/root/s2geometry/googletest/googletest/include/gtest/gtest-matchers.h:484:35:   required from 'bool testing::PolymorphicMatcher<Impl>::MonomorphicImpl<T>::MatchAndExplain(T, testing::MatchResultListener*) const [with T = const std::basic_string_view<char>&; Impl = testing::internal::HasSubstrMatcher<std::__cxx11::basic_string<char> >]'
/root/s2geometry/googletest/googletest/include/gtest/gtest-matchers.h:483:18:   required from here
/root/s2geometry/googletest/googlemock/include/gmock/gmock-matchers.h:760:23: error: invalid initialization of reference of type 'const std::__cxx11::basic_string<char>&' from expression of type 'const std::basic_string_view<char>'
  760 |     const StringType& s2(s);
      |                       ^~
jmr commented 5 months ago

Same commands to compile as #356 ?

Which googletest? Does this one work with 1.14.0?

benstadin commented 5 months ago

Yes, same commands. Cmake actually fails with more recent versions of gtest. So this was build with 1.10.0.

The error I get with 1.14.0 versions of test is (as far as I can remember, all recent versions show the same error, and 1.11.0 showed either this error when running cmake or the same error as with v1.10.0 when compiling):

root@9c6c06ec56a8:~/tmp/s2geometry/build# cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=/usr/local -DBUILD_SHARED_LIBS=OFF -Dabsl_DIR=/usr/local/lib -DGOOGLETEST_ROOT="/root/tmp/s2geometry/googletest" ..
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The following features have been disabled:

 * SHARED_LIBS, builds shared libraries instead of static.
 * PYTHON, provides python interface to S2
 * S2_USE_SYSTEM_INCLUDES, Silence warnings in s2 headers by marking them as SYSTEM includes.

-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found OpenSSL: /usr/lib/aarch64-linux-gnu/libcrypto.so (found version "3.0.2")  
GOOGLETEST_ROOT: /root/tmp/s2geometry/googletest
CMake Warning at googletest/googlemock/CMakeLists.txt:40 (project):
  VERSION keyword not followed by a value or was followed by a value that
  expanded to nothing.

CMake Warning at googletest/googletest/CMakeLists.txt:50 (project):
  VERSION keyword not followed by a value or was followed by a value that
  expanded to nothing.

-- Found Python3: /usr/bin/python3.10 (found version "3.10.12") found components: Interpreter 
CMake Error at googletest/googletest/CMakeLists.txt:124 (set_target_properties):
  set_target_properties called with incorrect number of arguments.

CMake Error at googletest/googletest/CMakeLists.txt:142 (set_target_properties):
  set_target_properties called with incorrect number of arguments.

CMake Error at googletest/googlemock/CMakeLists.txt:98 (set_target_properties):
  set_target_properties called with incorrect number of arguments.

CMake Error at googletest/googlemock/CMakeLists.txt:101 (set_target_properties):
  set_target_properties called with incorrect number of arguments.

-- Configuring incomplete, errors occurred!
See also "/root/tmp/s2geometry/build/CMakeFiles/CMakeOutput.log".
jmr commented 5 months ago

The error I get with 1.14.0 versions of test is

CMake Warning at googletest/googlemock/CMakeLists.txt:40 (project):
  VERSION keyword not followed by a value or was followed by a value that
 expanded to nothing.

What's around line 40 for you? I have:

    10  
    11  set(GOOGLETEST_VERSION 1.14.0)
    12  
...
    40  # Language "C" is required for find_package(Threads).
    41  cmake_minimum_required(VERSION 3.13)
    42  project(gmock VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)

What's your cmake version? I have 3.28.1.

SkyTik commented 2 months ago

Yes, same commands. Cmake actually fails with more recent versions of gtest. So this was build with 1.10.0.

The error I get with 1.14.0 versions of test is (as far as I can remember, all recent versions show the same error, and 1.11.0 showed either this error when running cmake or the same error as with v1.10.0 when compiling):

root@9c6c06ec56a8:~/tmp/s2geometry/build# cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=/usr/local -DBUILD_SHARED_LIBS=OFF -Dabsl_DIR=/usr/local/lib -DGOOGLETEST_ROOT="/root/tmp/s2geometry/googletest" ..
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The following features have been disabled:

 * SHARED_LIBS, builds shared libraries instead of static.
 * PYTHON, provides python interface to S2
 * S2_USE_SYSTEM_INCLUDES, Silence warnings in s2 headers by marking them as SYSTEM includes.

-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found OpenSSL: /usr/lib/aarch64-linux-gnu/libcrypto.so (found version "3.0.2")  
GOOGLETEST_ROOT: /root/tmp/s2geometry/googletest
CMake Warning at googletest/googlemock/CMakeLists.txt:40 (project):
  VERSION keyword not followed by a value or was followed by a value that
  expanded to nothing.

CMake Warning at googletest/googletest/CMakeLists.txt:50 (project):
  VERSION keyword not followed by a value or was followed by a value that
  expanded to nothing.

-- Found Python3: /usr/bin/python3.10 (found version "3.10.12") found components: Interpreter 
CMake Error at googletest/googletest/CMakeLists.txt:124 (set_target_properties):
  set_target_properties called with incorrect number of arguments.

CMake Error at googletest/googletest/CMakeLists.txt:142 (set_target_properties):
  set_target_properties called with incorrect number of arguments.

CMake Error at googletest/googlemock/CMakeLists.txt:98 (set_target_properties):
  set_target_properties called with incorrect number of arguments.

CMake Error at googletest/googlemock/CMakeLists.txt:101 (set_target_properties):
  set_target_properties called with incorrect number of arguments.

-- Configuring incomplete, errors occurred!
See also "/root/tmp/s2geometry/build/CMakeFiles/CMakeOutput.log".

you need to pass -DGOOGLETEST_VERSION=1.14.0 in cmake command when build googletest and s2geometry also