From 7940c9f791819211782bd7df51632657172c17c2 Mon Sep 17 00:00:00 2001 From: Deev Patel Date: Fri, 1 Mar 2024 01:17:23 -0800 Subject: [PATCH] Use abseil-cpp VLOG (#354) Abseil-cpp LTS 20240116 now supports VLOG. https://github.com/abseil/abseil-cpp/releases/tag/20240116.1 Use it instead of making VLOG a no-op. --- CMakeLists.txt | 5 +++++ README.md | 2 +- src/s2/base/logging.h | 12 +++--------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f7b5e47a..fb5a1adf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,10 @@ find_package(OpenSSL REQUIRED) # pthreads isn't used directly, but this is still required for std::thread. find_package(Threads REQUIRED) +if (NOT TARGET absl::vlog_is_on) + message(FATAL_ERROR "Could not find absl vlog module. Are you using an older version?") +endif() + if (WITH_PYTHON) # Should be easy to make it work with swig3, but some args to %pythonprepend # seem to be different and were changed. @@ -227,6 +231,7 @@ target_link_libraries( absl::strings absl::type_traits absl::utility + absl::vlog_is_on ${CMAKE_THREAD_LIBS_INIT}) if (GOOGLETEST_ROOT) diff --git a/README.md b/README.md index e636dc4e..99bc2dca 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ cd s2geometry ### Building -First, [install Abseil](https://github.com/abseil/abseil-cpp/blob/master/CMake/README.md#traditional-cmake-set-up). +First, [install Abseil](https://github.com/abseil/abseil-cpp/blob/master/CMake/README.md#traditional-cmake-set-up). We require [20240116.1](https://github.com/abseil/abseil-cpp/releases/tag/20240116.1) as the minimal version. It must be configured with `-DCMAKE_POSITION_INDEPENDENT_CODE=ON`. s2geometry must be configured to use the same C++ version that abseil uses. The easiest way to achieve this is to pass diff --git a/src/s2/base/logging.h b/src/s2/base/logging.h index aac48a0a..49750096 100644 --- a/src/s2/base/logging.h +++ b/src/s2/base/logging.h @@ -20,6 +20,7 @@ // include the relevant absl file directly instead. #include "absl/log/check.h" #include "absl/log/log.h" +#include "absl/log/vlog_is_on.h" #include "s2/base/log_severity.h" // The names CHECK, etc. are too common and may conflict with other @@ -48,14 +49,7 @@ #define S2_DCHECK_GT DCHECK_GT #define S2_DCHECK_GE DCHECK_GE -// Logging stream that does nothing. -struct S2NullStream { - template - S2NullStream& operator<<(const T& v) { return *this; } -}; - -// Abseil-cpp doesn't support VLOG yet. Make VLOG a no-op. -#define S2_VLOG(verbose_level) S2NullStream() -#define S2_VLOG_IS_ON(verbose_level) (false) +#define S2_VLOG VLOG +#define S2_VLOG_IS_ON VLOG_IS_ON #endif // S2_BASE_LOGGING_H_