xmake.lua 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package("yalantinglibs")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://github.com/alibaba/yalantinglibs")
  4. set_description("A collection of modern C++ libraries")
  5. set_license("Apache-2.0")
  6. set_urls("https://github.com/alibaba/yalantinglibs/archive/refs/tags/$(version).tar.gz",
  7. "https://github.com/alibaba/yalantinglibs.git")
  8. add_versions("0.3.4", "dd5edd3f43f23cd4b0614896e6587b61bb38c981dc21c85a54bcc54800d0dfe8")
  9. add_configs("ssl", {description = "Enable ssl support", default = false, type = "boolean"})
  10. add_configs("pmr", {description = "Enable pmr support", default = false, type = "boolean"})
  11. add_configs("io_uring", {description = "Enable io_uring", default = false, type = "boolean"})
  12. add_configs("file_io_uring", {description = "Enable file io_uring", default = false, type = "boolean"})
  13. add_configs("struct_pack_unportable_type", {description = "enable struct_pack unportable type(like wchar_t)", default = false, type = "boolean"})
  14. add_configs("struct_pack_unportable_optimize", {description = "enable struct_pack optimize(but cost more compile time)", default = false, type = "boolean"})
  15. add_deps("cinatra", "iguana")
  16. on_load(function (package)
  17. if package:config("ssl") then
  18. package:add("deps", "openssl")
  19. package:add("defines", "YLT_ENABLE_SSL")
  20. end
  21. if package:config("pmr") then
  22. package:add("defines", "YLT_ENABLE_PMR")
  23. end
  24. if package:config("io_uring") then
  25. package:add("deps", "liburing")
  26. package:add("defines", "ASIO_HAS_IO_URING", "ASIO_DISABLE_EPOLL", "ASIO_HAS_FILE", "YLT_ENABLE_FILE_IO_URING")
  27. end
  28. if package:config("file_io_uring") then
  29. package:add("deps", "liburing")
  30. package:add("defines", "ASIO_HAS_IO_URING", "ASIO_HAS_FILE", "YLT_ENABLE_FILE_IO_URING")
  31. end
  32. if package:config("struct_pack_unportable_type") then
  33. package:add("defines", "STRUCT_PACK_ENABLE_UNPORTABLE_TYPE")
  34. end
  35. if package:config("struct_pack_unportable_optimize") then
  36. package:add("defines", "YLT_ENABLE_STRUCT_PACK_OPTIMIZE")
  37. end
  38. end)
  39. on_install("windows", "linux", "macosx", function (package)
  40. local configs = {
  41. "-DINSTALL_THIRDPARTY=OFF",
  42. "-DINSTALL_STANDALONE=OFF",
  43. "-DINSTALL_INDEPENDENT_THIRDPARTY=OFF",
  44. "-DINSTALL_INDEPENDENT_STANDALONE=OFF",
  45. "-DCMAKE_PROJECT_NAME=xmake",
  46. }
  47. for name, enabled in table.orderpairs(package:configs()) do
  48. if not package:extraconf("configs", name, "builtin") then
  49. table.insert(configs, "-DYLT_ENABLE_" .. name:upper() .. "=" .. (enabled and "ON" or "OFF"))
  50. end
  51. end
  52. import("package.tools.cmake").install(package, configs)
  53. end)
  54. on_test(function (package)
  55. assert(package:check_cxxsnippets({test = [[
  56. #include "ylt/struct_pack.hpp"
  57. struct person {
  58. int64_t id;
  59. std::string name;
  60. int age;
  61. double salary;
  62. };
  63. void test() {
  64. person person1{.id = 1, .name = "hello struct pack", .age = 20, .salary = 1024.42};
  65. std::vector<char> buffer = struct_pack::serialize(person1);
  66. }
  67. ]]}, {configs = {languages = "c++20"}}))
  68. end)