diff --git a/CMakeLists.txt b/CMakeLists.txt index b5c1a3e..6c5f5c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 .) diff --git a/_pyceres/logging.h b/_pyceres/logging.h index bf6df04..ff8def4 100644 --- a/_pyceres/logging.h +++ b/_pyceres/logging.h @@ -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);