xmake.lua 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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.23.0", "9fc3f1f803a85170c2081cbbef2e301473a400683fc1dffefa2d6707598206a5")
  8. if is_plat("linux") then
  9. add_syslinks("m")
  10. elseif is_plat("bsd") then
  11. add_syslinks("m", "pthread")
  12. end
  13. add_deps("cmake")
  14. add_deps("boost", {configs = {regex = true, date_time = true, system = true}})
  15. add_deps("openssl")
  16. on_install("windows", "linux", "macosx", "bsd", "mingw", "cross", function (package)
  17. local configs = {
  18. "-DMAILIO_BUILD_EXAMPLES=OFF",
  19. "-DMAILIO_BUILD_TESTS=OFF",
  20. "-DMAILIO_DYN_LINK_TESTS=OFF",
  21. }
  22. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  23. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  24. if package:version():le("0.23.0") then
  25. table.insert(configs, "-DMAILIO_BUILD_SHARED_LIBRARY=" .. (package:config("shared") and "ON" or "OFF"))
  26. io.replace("CMakeLists.txt", " unit_test_framework", "", {plain = true})
  27. end
  28. if package:is_plat("windows") then
  29. table.insert(configs, "-DBoost_USE_STATIC_RUNTIME=" .. (package:dep("boost"):config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
  30. io.replace("CMakeLists.txt", "if (MSVC)",
  31. "if (MSVC)\n target_link_libraries(${PROJECT_NAME} crypt32)", {plain = true})
  32. elseif package:is_plat("mingw") then
  33. io.replace("CMakeLists.txt", "if(MINGW)",
  34. "if (MINGW)\n target_link_libraries(${PROJECT_NAME} crypt32)", {plain = true})
  35. end
  36. import("package.tools.cmake").install(package, configs)
  37. end)
  38. on_test(function (package)
  39. assert(package:check_cxxsnippets({test = [[
  40. #include <mailio/message.hpp>
  41. using namespace mailio;
  42. void test() {
  43. message msg;
  44. msg.header_codec(message::header_codec_t::QUOTED_PRINTABLE);
  45. }
  46. ]]}, {configs = {languages = "c++17"}}))
  47. end)