xmake.lua 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package("microsoft-apsi")
  2. set_homepage("https://github.com/microsoft/APSI")
  3. set_description("APSI is a C++ library for Asymmetric (unlabeled or labeled) Private Set Intersection.")
  4. set_license("MIT")
  5. add_urls("https://github.com/microsoft/APSI.git")
  6. add_versions("v0.12.0", "b967a126b4e1c682b039afc2d76a98ea2c993230")
  7. add_configs("log4cplus", {description = "Use Log4cplus for logging", default = false, type = "boolean"})
  8. add_configs("cppzmq", {description = "Use ZeroMQ for networking", default = false, type = "boolean"})
  9. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  10. add_deps("cmake")
  11. add_deps("microsoft-seal", {configs = {ms_gsl = true, zstd = true, throw_tran = false}})
  12. add_deps("microsoft-kuku", "flatbuffers", "jsoncpp")
  13. on_check(function (package)
  14. if not package:is_arch64() then
  15. raise("package(microsoft-apsi) unsupported 32-bit")
  16. end
  17. end)
  18. on_load(function (package)
  19. if package:config("log4cplus") then
  20. package:add("deps", "log4cplus", {configs = {unicode = false}})
  21. end
  22. if package:config("cppzmq") then
  23. package:add("deps", "cppzmq")
  24. end
  25. if package:is_cross() then
  26. package:add("deps", "flatbuffers~binary", {host = true, private = true, kind = "binary"})
  27. end
  28. local version = package:version()
  29. if version then
  30. package:add("includedirs", format("include/APSI-%s.%s", version:major(), version:minor()))
  31. else
  32. package:add("includedirs", "include/APSI-0.12")
  33. end
  34. end)
  35. on_install("windows", "linux", "macosx", "bsd", "android", function (package)
  36. if package:is_cross() then
  37. io.replace("CMakeLists.txt", "get_target_property(FLATBUFFERS_FLATC_PATH flatbuffers::flatc IMPORTED_LOCATION_RELEASE)", "", {plain = true})
  38. io.replace("cmake/DetectArch.cmake", "if(MSVC)", "if(WIN32)", {plain = true})
  39. io.replace("cmake/DetectArch.cmake", "check_cxx_source_runs", "check_cxx_source_compiles", {plain = true})
  40. end
  41. local configs = {}
  42. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  43. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  44. if package:is_cross() then
  45. table.insert(configs, "-DFLATBUFFERS_FLATC_PATH=flatc")
  46. end
  47. table.insert(configs, "-DAPSI_USE_LOG4CPLUS=" .. (package:config("log4cplus") and "ON" or "OFF"))
  48. table.insert(configs, "-DAPSI_USE_ZMQ=" .. (package:config("cppzmq") and "ON" or "OFF"))
  49. local opt = {}
  50. if package:has_tool("cxx", "cl") then
  51. opt.cxflags = {"/utf-8", "/EHsc"}
  52. end
  53. import("package.tools.cmake").install(package, configs, opt)
  54. end)
  55. on_test(function (package)
  56. assert(package:check_cxxsnippets({test = [[
  57. using namespace apsi;
  58. void test() {
  59. ThreadPoolMgr::SetThreadCount(4);
  60. }
  61. ]]}, {configs = {languages = "c++17"}, includes = {"apsi/sender.h"}}))
  62. end)