xmake.lua 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package("hexl")
  2. set_homepage("https://intel.github.io/hexl")
  3. set_description("Intel:registered: Homomorphic Encryption Acceleration Library accelerates modular arithmetic operations used in homomorphic encryption")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/intel/hexl/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/intel/hexl.git")
  7. add_versions("v1.2.5", "3692e6e6183dbc49253e51e86c3e52e7affcac925f57db0949dbb4d34b558a9a")
  8. add_configs("experimental", {description = "Enable experimental features", default = false, type = "boolean"})
  9. if is_plat("linux", "bsd") then
  10. add_syslinks("pthread", "m")
  11. end
  12. add_deps("cmake")
  13. add_deps("cpu-features")
  14. if on_check then
  15. on_check(function (package)
  16. if not package:is_arch("x86_64", "x64") then
  17. raise("package(hexl) only support x86_64 arch")
  18. end
  19. end)
  20. end
  21. on_load(function (package)
  22. if package:is_debug() then
  23. package:add("deps", "easyloggingpp")
  24. package:add("deps", (is_subhost("windows") and "pkgconf") or "pkg-config")
  25. package:add("patches", "1.2.5", "patches/1.2.5/cmake-find-easyloggingpp.patch", "7b239bebc13cd9548334b4dfcc84f1a11895c37e08b414d87e5ce81c944fb239")
  26. end
  27. end)
  28. on_install("!wasm", function (package)
  29. os.rmdir("cmake/third-party")
  30. io.replace("CMakeLists.txt", "set(CMAKE_POSITION_INDEPENDENT_CODE ON)", "", {plain = true})
  31. io.replace("hexl/CMakeLists.txt", "set_target_properties(hexl PROPERTIES POSITION_INDEPENDENT_CODE ON)", "", {plain = true})
  32. if package:is_cross() then
  33. io.replace("hexl/CMakeLists.txt", "-march=native", "", {plain = true})
  34. end
  35. io.replace("cmake/hexl/hexl-util.cmake", "if(HEXL_DEBUG AND UNIX)", "if(0)", {plain = true})
  36. io.replace("cmake/hexl/hexl-util.cmake", "if (CAN_COMPILE AND CAN_RUN STREQUAL 0)", "if(CAN_COMPILE)", {plain = true})
  37. io.replace("cmake/hexl/hexl-util.cmake", "try_run(CAN_RUN CAN_COMPILE", "try_compile(CAN_COMPILE", {plain = true})
  38. local configs = {"-DHEXL_BENCHMARK=OFF", "-DHEXL_TESTING=OFF"}
  39. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  40. table.insert(configs, "-DHEXL_SHARED_LIB=" .. (package:config("shared") and "ON" or "OFF"))
  41. if package:is_plat("windows") then
  42. table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''")
  43. if package:config("shared") then
  44. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  45. end
  46. end
  47. table.insert(configs, "-DHEXL_EXPERIMENTAL=" .. (package:config("experimental") and "ON" or "OFF"))
  48. import("package.tools.cmake").install(package, configs)
  49. if package:is_plat("windows") and package:is_debug() then
  50. local dir = package:installdir(package:config("shared") and "bin" or "lib")
  51. os.vcp(path.join(package:buildir(), "**.pdb"), dir)
  52. end
  53. end)
  54. on_test(function (package)
  55. assert(package:check_cxxsnippets({test = [[
  56. void test() {
  57. uint64_t modulus = 10;
  58. uint64_t op1[]{1, 2, 3, 4, 5, 6, 7, 8};
  59. uint64_t op2[]{1, 3, 5, 7, 2, 4, 6, 8};
  60. uint64_t exp_out[]{2, 5, 8, 1, 7, 0, 3, 6};
  61. intel::hexl::EltwiseAddMod(op1, op1, op2, std::size(op1), modulus);
  62. }
  63. ]]}, {configs = {languages = "c++17"}, includes = {"hexl/hexl.hpp"}}))
  64. end)