boost.cmake 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. include(ExternalProject)
  2. include(GNUInstallDirs)
  3. set(BOOST_CXXFLAGS "")
  4. if (WIN32)
  5. set(BOOST_BOOTSTRAP_COMMAND bootstrap.bat)
  6. set(BOOST_BUILD_TOOL b2.exe)
  7. set(BOOST_LIBRARY_SUFFIX -vc140-mt-1_63.lib)
  8. else()
  9. set(BOOST_BOOTSTRAP_COMMAND ./bootstrap.sh)
  10. set(BOOST_BUILD_TOOL ./b2)
  11. set(BOOST_LIBRARY_SUFFIX .a)
  12. if (${BUILD_SHARED_LIBS})
  13. set(BOOST_CXXFLAGS "cxxflags=-fPIC")
  14. endif()
  15. endif()
  16. ExternalProject_Add(boost-project
  17. PREFIX deps/boost
  18. URL https://sourceforge.net/projects/boost/files/boost/1.63.0/boost_1_63_0.tar.gz/download
  19. URL_HASH SHA256=fe34a4e119798e10b8cc9e565b3b0284e9fd3977ec8a1b19586ad1dec397088b
  20. DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR}/downloads
  21. SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/boost
  22. STAMP_DIR ${CMAKE_CURRENT_LIST_DIR}/tmp/boost
  23. TMP_DIR ${CMAKE_CURRENT_LIST_DIR}/tmp/boost
  24. BUILD_IN_SOURCE 1
  25. CONFIGURE_COMMAND ${BOOST_BOOTSTRAP_COMMAND}
  26. BUILD_COMMAND ${BOOST_BUILD_TOOL} stage
  27. ${BOOST_CXXFLAGS}
  28. threading=multi
  29. link=static
  30. variant=release
  31. address-model=64
  32. -d0
  33. --with-chrono
  34. --with-date_time
  35. --with-filesystem
  36. --with-random
  37. --with-regex
  38. --with-test
  39. --with-thread
  40. INSTALL_COMMAND ""
  41. )
  42. set(BOOST_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/boost)
  43. set(BOOST_LIB_DIR ${CMAKE_CURRENT_LIST_DIR}/boost/stage/lib)
  44. add_library(boost::chrono STATIC IMPORTED)
  45. set_property(TARGET boost::chrono PROPERTY IMPORTED_LOCATION ${BOOST_LIB_DIR}/libboost_chrono${BOOST_LIBRARY_SUFFIX})
  46. add_dependencies(boost::chrono boost-project)
  47. add_library(boost::date_time STATIC IMPORTED)
  48. set_property(TARGET boost::date_time PROPERTY IMPORTED_LOCATION ${BOOST_LIB_DIR}/libboost_date_time${BOOST_LIBRARY_SUFFIX})
  49. add_dependencies(boost::date_time boost-project)
  50. add_library(boost::regex STATIC IMPORTED)
  51. set_property(TARGET boost::regex PROPERTY IMPORTED_LOCATION ${BOOST_LIB_DIR}/libboost_regex${BOOST_LIBRARY_SUFFIX})
  52. add_dependencies(boost::regex boost-project)
  53. add_library(boost::system STATIC IMPORTED)
  54. set_property(TARGET boost::system PROPERTY IMPORTED_LOCATION ${BOOST_LIB_DIR}/libboost_system${BOOST_LIBRARY_SUFFIX})
  55. add_dependencies(boost::system boost-project)
  56. add_library(boost::filesystem STATIC IMPORTED)
  57. set_property(TARGET boost::filesystem PROPERTY IMPORTED_LOCATION ${BOOST_LIB_DIR}/libboost_filesystem${BOOST_LIBRARY_SUFFIX})
  58. set_property(TARGET boost::filesystem PROPERTY INTERFACE_LINK_LIBRARIES boost::system)
  59. add_dependencies(boost::filesystem boost-project)
  60. add_library(boost::random STATIC IMPORTED)
  61. set_property(TARGET boost::random PROPERTY IMPORTED_LOCATION ${BOOST_LIB_DIR}/libboost_random${BOOST_LIBRARY_SUFFIX})
  62. add_dependencies(boost::random boost-project)
  63. add_library(boost::unit_test_framework STATIC IMPORTED)
  64. set_property(TARGET boost::unit_test_framework PROPERTY IMPORTED_LOCATION ${BOOST_LIB_DIR}/libboost_unit_test_framework${BOOST_LIBRARY_SUFFIX})
  65. add_dependencies(boost::unit_test_framework boost-project)
  66. add_library(boost::thread STATIC IMPORTED)
  67. set_property(TARGET boost::thread PROPERTY IMPORTED_LOCATION ${BOOST_LIB_DIR}/libboost_thread${BOOST_LIBRARY_SUFFIX})
  68. set_property(TARGET boost::thread PROPERTY INTERFACE_LINK_LIBRARIES boost::chrono boost::date_time boost::regex)
  69. add_dependencies(boost::thread boost-project)