From 5ce060a95ce4f777368973e08118e14c122c19b9 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Tue, 27 Feb 2024 21:41:29 +0100 Subject: [PATCH] GH-40181: [C++] Support glog 0.7 build (#40230) Fixes #40181 ### Are these changes tested? These changes have been tested as part of the conda feedstocks for Arrow. * GitHub Issue: #40181 Authored-by: Uwe L. Korn Signed-off-by: Sutou Kouhei --- cpp/cmake_modules/FindGLOG.cmake | 8 +++++++- cpp/src/arrow/util/logging.cc | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cpp/cmake_modules/FindGLOG.cmake b/cpp/cmake_modules/FindGLOG.cmake index 61b7d0694efd4..62b235ee917ca 100644 --- a/cpp/cmake_modules/FindGLOG.cmake +++ b/cpp/cmake_modules/FindGLOG.cmake @@ -17,6 +17,11 @@ # # find_package(GLOG) +find_package(glog CONFIG) +if(glog_FOUND) + return() +endif() + if(GLOG_FOUND) return() endif() @@ -56,5 +61,6 @@ if(GLOG_FOUND) add_library(glog::glog UNKNOWN IMPORTED) set_target_properties(glog::glog PROPERTIES IMPORTED_LOCATION "${GLOG_LIB}" - INTERFACE_INCLUDE_DIRECTORIES "${GLOG_INCLUDE_DIR}") + INTERFACE_INCLUDE_DIRECTORIES "${GLOG_INCLUDE_DIR}" + INTERFACE_COMPILE_DEFINITIONS "GLOG_USE_GLOG_EXPORT") endif() diff --git a/cpp/src/arrow/util/logging.cc b/cpp/src/arrow/util/logging.cc index d2931132372a7..25c336a6d2111 100644 --- a/cpp/src/arrow/util/logging.cc +++ b/cpp/src/arrow/util/logging.cc @@ -116,7 +116,7 @@ static std::unique_ptr log_dir_; #ifdef ARROW_USE_GLOG // Glog's severity map. -static int GetMappedSeverity(ArrowLogLevel severity) { +static google::LogSeverity GetMappedSeverity(ArrowLogLevel severity) { switch (severity) { case ArrowLogLevel::ARROW_DEBUG: return google::GLOG_INFO; @@ -148,7 +148,7 @@ void ArrowLog::StartArrowLog(const std::string& app_name, app_name_.reset(new std::string(app_name)); log_dir_.reset(new std::string(log_dir)); #ifdef ARROW_USE_GLOG - int mapped_severity_threshold = GetMappedSeverity(severity_threshold_); + google::LogSeverity mapped_severity_threshold = GetMappedSeverity(severity_threshold_); google::SetStderrLogging(mapped_severity_threshold); // Enable log file if log_dir is not empty. if (!log_dir.empty()) { @@ -173,7 +173,7 @@ void ArrowLog::StartArrowLog(const std::string& app_name, google::SetLogFilenameExtension(app_name_without_path.c_str()); for (int i = static_cast(severity_threshold_); i <= static_cast(ArrowLogLevel::ARROW_FATAL); ++i) { - int level = GetMappedSeverity(static_cast(i)); + google::LogSeverity level = GetMappedSeverity(static_cast(i)); google::SetLogDestination(level, dir_ends_with_slash.c_str()); } }