xmake.lua 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package("clipper2")
  2. set_homepage("https://github.com/AngusJohnson/Clipper2")
  3. set_description("Polygon Clipping and Offsetting - C++, C# and Delphi")
  4. set_license("BSL-1.0")
  5. add_urls("https://github.com/AngusJohnson/Clipper2/archive/refs/tags/Clipper2_$(version).tar.gz")
  6. add_urls("https://github.com/AngusJohnson/Clipper2.git", {alias = "git", includes = "CPP"})
  7. add_versions("1.5.4", "9d8a35a29d04cd1b7b45f542c0ba48015feece1210036ea9e4efaad3140af4b0")
  8. add_versions("1.4.0", "b83f71bb6a338f4f82116089c5ae867dbc43a2d651b5441380970dd966edd959")
  9. add_versions("1.3.0", "8e537ec320e140afaa8fba1f23120416693cc1d71b0f76ad801d24b88b5e0b3c")
  10. add_versions("1.2.4", "a013d391c25c5f665cdb5cbd75cdd842dcc28f6e1bd098454beb359f6f212f33")
  11. add_versions("1.2.3", "d65bd45f50331e9dd2de3c68137c6be069fe25732095bef0128d547c997b1fda")
  12. add_versions("1.2.2", "e893e3560383744a13b896225a1ae97cf910fa30125cad66264b18446b9f931e")
  13. add_versions("git:1.5.4", "Clipper2_1.5.4")
  14. add_configs("use_z", {description = "Build Clipper2Z", default = "OFF", type = "string", values = {"ON", "OFF", "ONLY"}})
  15. add_configs("hi_precision", {description = "Enable high precision (caution: will compromise performance)", default = false, type = "boolean"})
  16. add_configs("max_decimal_precision", {description = "Maximum decimal precision range", default = "8", type = "string"})
  17. if is_plat("linux") then
  18. add_syslinks("m")
  19. end
  20. add_deps("cmake")
  21. on_load(function (package)
  22. if package:config("use_z") ~= "OFF" then
  23. package:add("defines", "USINGZ")
  24. end
  25. package:add("defines", "CLIPPER2_MAX_DECIMAL_PRECISION=" .. package:config("max_decimal_precision"))
  26. if package:config("hi_precision") then
  27. package:add("defines", "CLIPPER2_HI_PRECISION")
  28. end
  29. end)
  30. on_install(function (package)
  31. os.cd("CPP")
  32. io.replace("CMakeLists.txt", "-WX", "", {plain = true})
  33. io.replace("CMakeLists.txt", "-Werror", "", {plain = true})
  34. local configs = {"-DCLIPPER2_UTILS=OFF", "-DCLIPPER2_EXAMPLES=OFF", "-DCLIPPER2_TESTS=OFF"}
  35. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  36. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  37. if package:config("shared") and package:is_plat("windows") then
  38. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  39. end
  40. table.insert(configs, "-DCLIPPER2_USINGZ=" .. package:config("use_z"))
  41. table.insert(configs, "-DCLIPPER2_HI_PRECISION=" .. (package:config("hi_precision") and "ON" or "OFF"))
  42. table.insert(configs, "-DCLIPPER2_MAX_DECIMAL_PRECISION=" .. package:config("max_decimal_precision"))
  43. import("package.tools.cmake").install(package, configs)
  44. end)
  45. on_test(function (package)
  46. assert(package:check_cxxsnippets({test = [[
  47. #include <clipper2/clipper.h>
  48. using namespace Clipper2Lib;
  49. void test() {
  50. Paths64 subject, clip, solution;
  51. subject.push_back(MakePath({100, 50, 10, 79, 65, 2, 65, 98, 10, 21}));
  52. }
  53. ]]}, {configs = {languages = "c++17"}}))
  54. end)