diff --git a/CMakeLists.txt b/CMakeLists.txt index 3074f13cd..0346fa0f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,15 +121,22 @@ if(NOT Boost_SERIALIZATION_LIBRARY OR NOT Boost_SYSTEM_LIBRARY OR NOT Boost_FILE message(FATAL_ERROR "Missing required Boost components >= v1.43, please install/upgrade Boost or configure your search paths.") endif() +option(GTSAM_DISABLE_NEW_TIMERS "Disables using Boost.chrono for timing" OFF) # Allow for not using the timer libraries on boost < 1.48 (GTSAM timing code falls back to old timer library) set(GTSAM_BOOST_LIBRARIES ${Boost_SERIALIZATION_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY}) -if(Boost_TIMER_LIBRARY) - list(APPEND GTSAM_BOOST_LIBRARIES ${GTSAM_BOOST_LIBRARIES} ${Boost_TIMER_LIBRARY} ${Boost_CHRONO_LIBRARY}) +if (GTSAM_DISABLE_NEW_TIMERS) + message("WARNING: GTSAM timing instrumentation manually disabled") + add_definitions(-DGTSAM_DISABLE_NEW_TIMERS) else() - message("WARNING: Boost older than 1.48 was found, GTSAM timing instrumentation will use the older, less accurate, Boost timer library.") + if(Boost_TIMER_LIBRARY) + list(APPEND GTSAM_BOOST_LIBRARIES ${GTSAM_BOOST_LIBRARIES} ${Boost_TIMER_LIBRARY} ${Boost_CHRONO_LIBRARY}) + else() + message("WARNING: Boost older than 1.48 was found, GTSAM timing instrumentation will use the older, less accurate, Boost timer library.") + endif() endif() + ############################################################################### # Global compile options diff --git a/gtsam/base/timing.h b/gtsam/base/timing.h index 7bd030ed0..ecec413b1 100644 --- a/gtsam/base/timing.h +++ b/gtsam/base/timing.h @@ -26,8 +26,10 @@ // Automatically use the new Boost timers if version is recent enough. #if BOOST_VERSION >= 104800 +#if not GTSAM_DISABLE_NEW_TIMERS #define GTSAM_USING_NEW_BOOST_TIMERS #endif +#endif #ifdef GTSAM_USING_NEW_BOOST_TIMERS #include @@ -137,4 +139,4 @@ inline void tictoc_finishedIteration() {} inline void tictoc_print() {} #endif -} \ No newline at end of file +}