HandleBoost.cmake 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ###############################################################################
  2. # Find boost
  3. # To change the path for boost, you will need to set:
  4. # BOOST_ROOT: path to install prefix for boost
  5. # Boost_NO_SYSTEM_PATHS: set to true to keep the find script from ignoring BOOST_ROOT
  6. if(MSVC)
  7. # By default, boost only builds static libraries on windows
  8. set(Boost_USE_STATIC_LIBS ON) # only find static libs
  9. # If we ever reset above on windows and, ...
  10. # If we use Boost shared libs, disable auto linking.
  11. # Some libraries, at least Boost Program Options, rely on this to export DLL symbols.
  12. if(NOT Boost_USE_STATIC_LIBS)
  13. list_append_cache(GTSAM_COMPILE_DEFINITIONS_PUBLIC BOOST_ALL_NO_LIB BOOST_ALL_DYN_LINK)
  14. endif()
  15. # Virtual memory range for PCH exceeded on VS2015
  16. if(MSVC_VERSION LESS 1910) # older than VS2017
  17. list_append_cache(GTSAM_COMPILE_OPTIONS_PRIVATE -Zm295)
  18. endif()
  19. endif()
  20. # Store these in variables so they are automatically replicated in GTSAMConfig.cmake and such.
  21. set(BOOST_FIND_MINIMUM_VERSION 1.65)
  22. set(BOOST_FIND_MINIMUM_COMPONENTS serialization system filesystem thread program_options date_time timer chrono regex)
  23. find_package(Boost ${BOOST_FIND_MINIMUM_VERSION} COMPONENTS ${BOOST_FIND_MINIMUM_COMPONENTS})
  24. # Required components
  25. if(NOT Boost_SERIALIZATION_LIBRARY OR NOT Boost_SYSTEM_LIBRARY OR NOT Boost_FILESYSTEM_LIBRARY OR
  26. NOT Boost_THREAD_LIBRARY OR NOT Boost_DATE_TIME_LIBRARY)
  27. message(FATAL_ERROR "Missing required Boost components >= v1.65, please install/upgrade Boost or configure your search paths.")
  28. endif()
  29. option(GTSAM_DISABLE_NEW_TIMERS "Disables using Boost.chrono for timing" OFF)
  30. # Allow for not using the timer libraries on boost < 1.48 (GTSAM timing code falls back to old timer library)
  31. set(GTSAM_BOOST_LIBRARIES
  32. Boost::serialization
  33. Boost::system
  34. Boost::filesystem
  35. Boost::thread
  36. Boost::date_time
  37. Boost::regex
  38. )
  39. if (GTSAM_DISABLE_NEW_TIMERS)
  40. message("WARNING: GTSAM timing instrumentation manually disabled")
  41. list_append_cache(GTSAM_COMPILE_DEFINITIONS_PUBLIC DGTSAM_DISABLE_NEW_TIMERS)
  42. else()
  43. if(Boost_TIMER_LIBRARY)
  44. list(APPEND GTSAM_BOOST_LIBRARIES Boost::timer Boost::chrono)
  45. else()
  46. list(APPEND GTSAM_BOOST_LIBRARIES rt) # When using the header-only boost timer library, need -lrt
  47. message("WARNING: GTSAM timing instrumentation will use the older, less accurate, Boost timer library because boost older than 1.48 was found.")
  48. endif()
  49. endif()