xmake.lua 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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.4.0", "9e8a7640911481134e60987d5d1e1cd157f430c3b4b38de8d36fc55c302bc299")
  7. add_versions("4.3.0", "006f5784a9bcee43e5a7e943dc4f02de1ba2ee7a7af1ee5f190d383f3b6c9ebe")
  8. add_versions("4.2.0", "8a4d051df2ab2218998a16f7712e843ee9e96d8b09ffbfcc18533da127e0da02")
  9. add_versions("3.3.2", "5d25d16e77c844c297ece2044df57651139bc3c8ad8c4108916374267ac68b64")
  10. add_versions("3.2.1", "bd98e3b501b4c24dc127f4ad93e467f42923fe3eefa99e143b5b93158f024395")
  11. add_configs("gpu", {description = "Enable GPU-accelerated training.", default = false, type = "boolean"})
  12. add_deps("cmake")
  13. on_load("windows|x64", "linux", function (package)
  14. if package:config("gpu") then
  15. package:add("deps", "opencl")
  16. package:add("deps", "boost", {configs = {filesystem = true, system = true}})
  17. end
  18. if package:is_plat("linux") and package:has_tool("cc", "clang", "clangxx") then
  19. package:add("deps", "libomp")
  20. end
  21. end)
  22. on_install("windows|x64", "linux", function (package)
  23. if package:version():lt("4.2.0") then
  24. os.cd("compile")
  25. end
  26. local configs = {"-DBoost_USE_STATIC_LIBS=ON", "-DBUILD_CLI=OFF"}
  27. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  28. table.insert(configs, "-DBUILD_STATIC_LIB=" .. (package:config("shared") and "OFF" or "ON"))
  29. if package:is_plat("windows") then
  30. table.insert(configs, "-DBoost_USE_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
  31. end
  32. if package:is_plat("linux") and package:has_tool("cc", "clang", "clangxx") then
  33. local libomp = package:dep("libomp"):fetch()
  34. if libomp then
  35. local includedirs = table.wrap(libomp.includedirs or libomp.sysincludedirs)
  36. local libfiles = table.wrap(libomp.libfiles)
  37. if #includedirs > 0 and #libfiles > 0 then
  38. table.insert(configs, "-DOpenMP_C_LIB_NAMES=libomp")
  39. table.insert(configs, "-DOpenMP_C_FLAGS=-I" .. includedirs[1])
  40. table.insert(configs, "-DOpenMP_CXX_LIB_NAMES=libomp")
  41. table.insert(configs, "-DOpenMP_CXX_FLAGS=-I" .. includedirs[1])
  42. table.insert(configs, "-DOpenMP_libomp_LIBRARY=" .. table.concat(libfiles, " "))
  43. end
  44. end
  45. end
  46. import("package.tools.cmake").install(package, configs)
  47. package:addenv("PATH", "bin")
  48. end)
  49. on_test(function (package)
  50. assert(package:has_cxxtypes("LightGBM::ChunkedArray<int>", {includes = "LightGBM/utils/chunked_array.hpp"}))
  51. end)