xmake.lua 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package("boost")
  2. set_homepage("https://www.boost.org/")
  3. set_description("Collection of portable C++ source libraries.")
  4. set_license("BSL-1.0")
  5. -- xrepo does not support `package:config("cmake")` in on_source to set the download url, so if you want to build with cmake, we need to `add_urls` cmake archive url at first line.
  6. -- Users can also download the cmake archive and put it in `xmake g --pkg_searchdirs=` to avoid xrepo using a non-cmake archive url.
  7. add_urls("https://github.com/boostorg/boost/releases/download/boost-$(version)/boost-$(version)-cmake.tar.gz", {alias = "cmake"})
  8. add_urls("https://github.com/boostorg/boost/releases/download/boost-$(version)/boost-$(version)-b2-nodocs.tar.gz")
  9. add_urls("https://github.com/boostorg/boost/releases/download/boost-$(version)/boost-$(version).tar.gz")
  10. add_urls("https://github.com/xmake-mirror/boost/releases/download/boost-$(version).tar.bz2", {alias = "mirror", version = function (version)
  11. return version .. "/boost_" .. (version:gsub("%.", "_"))
  12. end})
  13. add_versions("cmake:1.86.0", "c62ce6e64d34414864fef946363db91cea89c1b90360eabed0515f0eda74c75c")
  14. add_versions("1.86.0", "2128a4c96862b5c0970c1e34d76b1d57e4a1016b80df85ad39667f30b1deba26")
  15. add_versions("1.85.0", "f4a7d3f81b8a0f65067b769ea84135fd7b72896f4f59c7f405086c8c0dc61434")
  16. add_versions("1.84.0", "4d27e9efed0f6f152dc28db6430b9d3dfb40c0345da7342eaa5a987dde57bd95")
  17. add_versions("1.83.0", "0c6049764e80aa32754acd7d4f179fd5551d8172a83b71532ae093e7384e98da")
  18. add_versions("1.82.0", "b62bd839ea6c28265af9a1f68393eda37fab3611425d3b28882d8e424535ec9d")
  19. add_versions("1.81.0", "121da556b718fd7bd700b5f2e734f8004f1cfa78b7d30145471c526ba75a151c")
  20. add_versions("mirror:1.80.0", "1e19565d82e43bc59209a168f5ac899d3ba471d55c7610c677d4ccf2c9c500c0")
  21. add_versions("mirror:1.79.0", "475d589d51a7f8b3ba2ba4eda022b170e562ca3b760ee922c146b6c65856ef39")
  22. add_versions("mirror:1.78.0", "8681f175d4bdb26c52222665793eef08490d7758529330f98d3b29dd0735bccc")
  23. add_versions("mirror:1.77.0", "fc9f85fc030e233142908241af7a846e60630aa7388de9a5fafb1f3a26840854")
  24. add_versions("mirror:1.76.0", "f0397ba6e982c4450f27bf32a2a83292aba035b827a5623a14636ea583318c41")
  25. add_versions("mirror:1.75.0", "953db31e016db7bb207f11432bef7df100516eeb746843fa0486a222e3fd49cb")
  26. add_versions("mirror:1.74.0", "83bfc1507731a0906e387fc28b7ef5417d591429e51e788417fe9ff025e116b1")
  27. add_versions("mirror:1.73.0", "4eb3b8d442b426dc35346235c8733b5ae35ba431690e38c6a8263dce9fcbb402")
  28. add_versions("mirror:1.72.0", "59c9b274bc451cf91a9ba1dd2c7fdcaf5d60b1b3aa83f2c9fa143417cc660722")
  29. add_versions("mirror:1.70.0", "430ae8354789de4fd19ee52f3b1f739e1fba576f0aded0897c3c2bc00fb38778")
  30. add_patches("1.75.0", "patches/1.75.0/warning.patch", "43ff97d338c78b5c3596877eed1adc39d59a000cf651d0bcc678cf6cd6d4ae2e")
  31. includes(path.join(os.scriptdir(), "libs.lua"))
  32. for _, libname in ipairs(get_libs()) do
  33. add_configs(libname, {description = "Enable " .. libname .. " library.", default = (libname == "filesystem"), type = "boolean"})
  34. end
  35. add_configs("zlib", {description = "Enable zlib for iostreams", default = false, type = "boolean"})
  36. add_configs("bzip2", {description = "Enable bzip2 for iostreams", default = false, type = "boolean"})
  37. add_configs("lzma", {description = "Enable lzma for iostreams", default = false, type = "boolean"})
  38. add_configs("zstd", {description = "Enable zstd for iostreams", default = false, type = "boolean"})
  39. add_configs("openssl", {description = "Enable openssl for mysql/redis", default = false, type = "boolean"})
  40. add_configs("icu", {description = "Enable icu for regex/locale", default = false, type = "boolean"})
  41. add_configs("cmake", {description = "Use cmake build system (>= 1.86)", default = true, type = "boolean"})
  42. add_configs("all", {description = "Enable all library modules support.", default = false, type = "boolean"})
  43. add_configs("header_only", {description = "Enable header only modules", default = false, type = "boolean"})
  44. add_configs("pyver", {description = "python version x.y, etc. 3.10 (only for b2)", default = "3.10"})
  45. add_configs("multi", {description = "Enable multi-thread support (only for b2)", default = true, type = "boolean"})
  46. if is_plat("mingw") and is_subhost("msys") then
  47. add_extsources("pacman::boost")
  48. elseif is_plat("linux") then
  49. add_extsources("pacman::boost", "apt::libboost-all-dev")
  50. elseif is_plat("macosx") then
  51. add_extsources("brew::boost")
  52. end
  53. if is_plat("linux", "bsd") then
  54. add_syslinks("pthread", "dl")
  55. end
  56. on_fetch("fetch")
  57. if on_check then
  58. on_check(function (package)
  59. if not package:is_plat("macosx", "linux", "windows", "bsd", "mingw", "cross") then
  60. if not package:config("cmake") then
  61. raise("package(boost/b2) unsupported current platform.")
  62. end
  63. end
  64. end)
  65. end
  66. on_load(function (package)
  67. local version = package:version()
  68. if package:config("cmake") and version:lt("1.86") then
  69. -- Don't break old version
  70. package:config_set("cmake", false)
  71. end
  72. if package:config("cmake") then
  73. wprint("If cmake build failure, set package config cmake = false fallback to b2 for the build")
  74. package:add("deps", "cmake")
  75. import("cmake.load")(package)
  76. else
  77. if package:is_plat("linux") then
  78. package:add("deps", "bzip2", "zlib")
  79. end
  80. import("b2.load")(package)
  81. end
  82. end)
  83. on_install(function (package)
  84. if package:config("cmake") then
  85. assert(os.isfile("CMakeLists.txt"), "Currently the source archive only has the b2 build system, you need to download the cmake archive and put it in `xmake g --pkg_searchdirs=` to avoid xrepo using a non-cmake archive url.")
  86. import("cmake.install")(package)
  87. else
  88. import("b2.install")(package)
  89. end
  90. end)
  91. on_test(function (package)
  92. import("test")(package)
  93. end)