boost.cmake 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. if(TARGET Boost::boost)
  2. return()
  3. endif()
  4. message(STATUS "Third-party: creating targets 'Boost::boost'...")
  5. cmake_minimum_required(VERSION 3.24) # Ensure modern FetchContent features
  6. project(BoostFetchExample)
  7. include(FetchContent)
  8. # Define the Boost library to fetch
  9. FetchContent_Declare(
  10. Boost
  11. URL https://archives.boost.io/release/1.86.0/source/boost_1_86_0.tar.gz
  12. URL_HASH MD5=ac857d73bb754b718a039830b07b9624
  13. )
  14. # Fetch Boost
  15. FetchContent_MakeAvailable(Boost)
  16. # Ensure Boost paths are set before CGAL
  17. set(Boost_INCLUDE_DIR ${boost_SOURCE_DIR})
  18. set(Boost_LIBRARY_DIR ${boost_BINARY_DIR})
  19. # Add Boost libraries needed for your project
  20. set(BOOST_LIBRARIES
  21. container
  22. regex
  23. atomic
  24. exception
  25. chrono
  26. wave
  27. context
  28. coroutine
  29. date_time
  30. fiber
  31. filesystem
  32. graph
  33. iostreams
  34. locale
  35. log
  36. log_setup
  37. unit_test_framework
  38. math
  39. multiprecision
  40. program_options
  41. timer
  42. random
  43. serialization
  44. system
  45. thread
  46. type_erasure
  47. )
  48. foreach(lib IN LISTS BOOST_LIBRARIES)
  49. add_library(boost_${lib} INTERFACE)
  50. target_include_directories(boost_${lib} INTERFACE ${Boost_SOURCE_DIR})
  51. target_link_libraries(boost_${lib} INTERFACE Boost::${lib})
  52. endforeach()