xmake.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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.0", "b64eff580c721809d32be69c43070c37c9200ca02e5169d9ae7972fbd759977e")
  8. add_configs("sse", {description = "Use SSE/SSE2 optimizations if available", default = false, type = "boolean"})
  9. add_configs("openmp", {description = "Use OpenMP parallelization if available (experimental)", default = false, type = "boolean"})
  10. if is_plat("linux", "bsd") then
  11. add_syslinks("m")
  12. end
  13. add_deps("cmake")
  14. on_load(function (package)
  15. if package:config("openmp") then
  16. package:add("deps", "openmp")
  17. end
  18. if not package:config("shared") then
  19. package:add("defines", "PLFIT_STATIC")
  20. end
  21. end)
  22. on_install("!cross", function (package)
  23. io.replace("CMakeLists.txt", "add_subdirectory(test)", "", {plain = true})
  24. if package:is_plat("cross", "wasm") then
  25. io.replace("CMakeLists.txt", "FIND_LIBRARY(MATH_LIBRARY NAMES m)", "set(MATH_LIBRARY )", {plain = true})
  26. end
  27. local configs = {}
  28. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  29. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  30. table.insert(configs, "-DPLFIT_ENABLE_LTO=" .. (package:config("lto") and "ON" or "OFF"))
  31. table.insert(configs, "-DPLFIT_USE_SSE=" .. (package:config("sse") and "ON" or "OFF"))
  32. table.insert(configs, "-DPLFIT_USE_OPENMP=" .. (package:config("openmp") and "ON" or "OFF"))
  33. import("package.tools.cmake").install(package, configs)
  34. end)
  35. on_test(function (package)
  36. assert(package:has_cfuncs("plfit_continuous_options_init", {includes = "plfit/plfit.h"}))
  37. end)