xmake.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package("plfit")
  2. set_homepage("https://github.com/ntamas/plfit")
  3. set_description("Fitting power-law distributions to empirical data, according to the method of Clauset, Shalizi and Newman")
  4. set_license("GPL-2.0")
  5. add_urls("https://github.com/ntamas/plfit/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/ntamas/plfit.git")
  7. add_versions("1.0.1", "523868c283f334329084df457739baf29b0a21e679830e5326965b0d128db1d4")
  8. add_versions("1.0.0", "b64eff580c721809d32be69c43070c37c9200ca02e5169d9ae7972fbd759977e")
  9. add_configs("sse", {description = "Use SSE/SSE2 optimizations if available", default = false, type = "boolean"})
  10. add_configs("openmp", {description = "Use OpenMP parallelization if available (experimental)", default = false, type = "boolean"})
  11. if is_plat("linux", "bsd") then
  12. add_syslinks("m")
  13. end
  14. add_deps("cmake")
  15. on_load(function (package)
  16. if package:config("openmp") then
  17. package:add("deps", "openmp")
  18. end
  19. if not package:config("shared") then
  20. package:add("defines", "PLFIT_STATIC")
  21. end
  22. end)
  23. on_install("!cross", function (package)
  24. io.replace("CMakeLists.txt", "add_subdirectory(test)", "", {plain = true})
  25. if package:is_plat("cross", "wasm") then
  26. io.replace("CMakeLists.txt", "FIND_LIBRARY(MATH_LIBRARY NAMES m)", "set(MATH_LIBRARY )", {plain = true})
  27. end
  28. local configs = {}
  29. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  30. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  31. table.insert(configs, "-DPLFIT_ENABLE_LTO=" .. (package:config("lto") and "ON" or "OFF"))
  32. table.insert(configs, "-DPLFIT_USE_SSE=" .. (package:config("sse") and "ON" or "OFF"))
  33. table.insert(configs, "-DPLFIT_USE_OPENMP=" .. (package:config("openmp") and "ON" or "OFF"))
  34. import("package.tools.cmake").install(package, configs)
  35. end)
  36. on_test(function (package)
  37. assert(package:has_cfuncs("plfit_continuous_options_init", {includes = "plfit/plfit.h"}))
  38. end)