xmake.lua 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package("lightgbm")
  2. set_homepage("https://github.com/microsoft/LightGBM")
  3. set_description("LightGBM is a gradient boosting framework that uses tree based learning algorithms.")
  4. set_license("MIT")
  5. add_urls("https://github.com/microsoft/LightGBM/releases/download/v$(version)/lightgbm-$(version).tar.gz")
  6. add_versions("4.6.0", "cb1c59720eb569389c0ba74d14f52351b573af489f230032a1c9f314f8bab7fe")
  7. add_versions("4.5.0", "e1cd7baf0318d4e308a26575a63a4635f08df866ad3622a9d8e3d71d9637a1ba")
  8. add_versions("4.4.0", "9e8a7640911481134e60987d5d1e1cd157f430c3b4b38de8d36fc55c302bc299")
  9. add_versions("4.3.0", "006f5784a9bcee43e5a7e943dc4f02de1ba2ee7a7af1ee5f190d383f3b6c9ebe")
  10. add_versions("4.2.0", "8a4d051df2ab2218998a16f7712e843ee9e96d8b09ffbfcc18533da127e0da02")
  11. add_versions("3.3.2", "5d25d16e77c844c297ece2044df57651139bc3c8ad8c4108916374267ac68b64")
  12. add_versions("3.2.1", "bd98e3b501b4c24dc127f4ad93e467f42923fe3eefa99e143b5b93158f024395")
  13. add_configs("gpu", {description = "Enable GPU-accelerated training.", default = false, type = "boolean"})
  14. add_deps("cmake")
  15. if on_check then
  16. on_check("linux", function (package)
  17. if package:version() and package:version():ge("4.5.0") then
  18. if package:has_tool("cxx", "clang") and package:config("shared") then
  19. raise("package(lightgbm) unsupported clang + shared build")
  20. end
  21. end
  22. end)
  23. end
  24. on_load("windows|x64", "linux", function (package)
  25. if package:config("gpu") then
  26. package:add("deps", "opencl")
  27. package:add("deps", "boost", {configs = {filesystem = true, system = true}})
  28. end
  29. if package:is_plat("linux") and package:has_tool("cc", "clang", "clangxx") then
  30. package:add("deps", "libomp")
  31. end
  32. end)
  33. on_install("windows|x64", "linux", function (package)
  34. if package:version() and package:version():lt("4.2.0") then
  35. os.cd("compile")
  36. end
  37. local configs = {"-DBoost_USE_STATIC_LIBS=ON", "-DBUILD_CLI=OFF"}
  38. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  39. table.insert(configs, "-DBUILD_STATIC_LIB=" .. (package:config("shared") and "OFF" or "ON"))
  40. if package:is_plat("windows") then
  41. table.insert(configs, "-DBoost_USE_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
  42. end
  43. if package:is_plat("linux") and package:has_tool("cc", "clang", "clangxx") then
  44. local libomp = package:dep("libomp"):fetch()
  45. if libomp then
  46. local includedirs = table.wrap(libomp.includedirs or libomp.sysincludedirs)
  47. local libfiles = table.wrap(libomp.libfiles)
  48. if #includedirs > 0 and #libfiles > 0 then
  49. table.insert(configs, "-DOpenMP_C_LIB_NAMES=libomp")
  50. table.insert(configs, "-DOpenMP_C_FLAGS=-I" .. includedirs[1])
  51. table.insert(configs, "-DOpenMP_CXX_LIB_NAMES=libomp")
  52. table.insert(configs, "-DOpenMP_CXX_FLAGS=-I" .. includedirs[1])
  53. table.insert(configs, "-DOpenMP_libomp_LIBRARY=" .. table.concat(libfiles, " "))
  54. end
  55. end
  56. end
  57. import("package.tools.cmake").install(package, configs)
  58. package:addenv("PATH", "bin")
  59. end)
  60. on_test(function (package)
  61. assert(package:has_cxxtypes("LightGBM::ChunkedArray<int>", {includes = "LightGBM/utils/chunked_array.hpp"}))
  62. end)