xmake.lua 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package("mailio")
  2. set_homepage("https://github.com/karastojko/mailio")
  3. set_description("mailio is a cross platform C++ library for MIME format and SMTP, POP3 and IMAP protocols. It is based on standard C++ 17 and Boost library.")
  4. set_license("BSD")
  5. add_urls("https://github.com/karastojko/mailio/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/karastojko/mailio.git")
  7. add_versions("0.24.1", "52d5ced35b6a87677d897010fb2e7c2d2ddbd834d59aab991c65c0c6627af40f")
  8. add_versions("0.23.0", "9fc3f1f803a85170c2081cbbef2e301473a400683fc1dffefa2d6707598206a5")
  9. if is_plat("linux", "bsd") then
  10. add_syslinks("m", "pthread")
  11. end
  12. add_deps("cmake")
  13. add_deps("boost", {configs = {regex = true, date_time = true, system = true, exception = true, container = true}})
  14. add_deps("openssl")
  15. on_load(function (package)
  16. if not package:config("shared") then
  17. package:add("defines", "MAILIO_STATIC_DEFINE")
  18. end
  19. end)
  20. on_install("!iphoneos and !wasm", function (package)
  21. local version = package:version()
  22. io.replace("CMakeLists.txt", "/WX", "", {plain = true})
  23. io.replace("CMakeLists.txt", "set(Boost_USE_STATIC_LIBS ON)", "", {plain = true})
  24. if package:gitref() or version:le("0.24.1") then
  25. io.replace("CMakeLists.txt", " unit_test_framework", "", {plain = true})
  26. if package:is_plat("windows") then
  27. io.replace("CMakeLists.txt", "if (MSVC)",
  28. "if (MSVC)\n target_link_libraries(${PROJECT_NAME} crypt32)", {plain = true})
  29. elseif package:is_plat("mingw") then
  30. io.replace("CMakeLists.txt", "if(MINGW)",
  31. "if (MINGW)\n target_link_libraries(${PROJECT_NAME} crypt32)", {plain = true})
  32. end
  33. end
  34. local configs = {
  35. "-DMAILIO_BUILD_EXAMPLES=OFF",
  36. "-DMAILIO_BUILD_TESTS=OFF",
  37. "-DMAILIO_DYN_LINK_TESTS=OFF",
  38. "-DMAILIO_BUILD_DOCUMENTATION=OFF"
  39. }
  40. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  41. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  42. if version and version:le("0.23.0") then
  43. table.insert(configs, "-DMAILIO_BUILD_SHARED_LIBRARY=" .. (package:config("shared") and "ON" or "OFF"))
  44. end
  45. import("package.tools.cmake").install(package, configs)
  46. end)
  47. on_test(function (package)
  48. assert(package:check_cxxsnippets({test = [[
  49. #include <mailio/message.hpp>
  50. using namespace mailio;
  51. void test() {
  52. message msg;
  53. msg.header_codec(message::header_codec_t::QUOTED_PRINTABLE);
  54. }
  55. ]]}, {configs = {languages = "c++17"}}))
  56. end)