Skip to content

Commit

Permalink
Support glog <0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sarlinpe committed Feb 9, 2024
1 parent 762d2b7 commit 3c8ba14
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ find_package(pybind11 2.11.1 REQUIRED)
pybind11_add_module(pyceres _pyceres/bindings.cc)
target_include_directories(pyceres PRIVATE ${PROJECT_SOURCE_DIR})
target_link_libraries(pyceres PRIVATE glog::glog Ceres::ceres)
target_compile_definitions(pyceres PRIVATE VERSION_INFO="${PROJECT_VERSION}")
target_compile_definitions(
pyceres
PRIVATE VERSION_INFO="${PROJECT_VERSION}"
GLOG_VERSION_MAJOR=${glog_VERSION_MAJOR}
GLOG_VERSION_MINOR=${glog_VERSION_MINOR})
install(TARGETS pyceres LIBRARY DESTINATION .)
5 changes: 4 additions & 1 deletion _pyceres/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ void BindLogging(py::module& m) {
.value("ERROR", Logging::LogSeverity::GLOG_ERROR)
.value("FATAL", Logging::LogSeverity::GLOG_FATAL)
.export_values();
if (!google::IsGoogleLoggingInitialized()) {
#if GLOG_VERSION_MAJOR >= 0 && GLOG_VERSION_MINOR >= 6
if (!google::IsGoogleLoggingInitialized())
#endif
{
google::InitGoogleLogging("");
google::InstallFailureSignalHandler();
google::InstallFailureFunction(&PyBindLogTermination);
Expand Down

0 comments on commit 3c8ba14

Please sign in to comment.