xmake.lua 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package("oatpp")
  2. set_homepage("https://oatpp.io/")
  3. set_description("Modern Web Framework for C++. High performance, simple API, cross platform, zero dependency.")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/oatpp/oatpp/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/oatpp/oatpp.git")
  7. add_versions("1.0.0", "9ba7c75e3ada8ec894ec10beae712e775774a835fd3de89d8c34e17740202619")
  8. add_versions("1.2.5", "36276e8b23e68ece1e6093c3f06fc80e3d42a5f4e47cdeef5e7e63f36eeddaad")
  9. add_versions("1.3.0", "e1f80fa8fd7a74da6737e7fee1a4db68b4d7085a3f40e7d550752d6ff5714583")
  10. add_versions("1.4.0-preview", "bbf9715eb8bc3ef58686c5b1fb844de4b73ba6d0")
  11. if is_plat("windows") then
  12. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  13. end
  14. if is_plat("windows") then
  15. add_syslinks("ws2_32")
  16. end
  17. add_deps("cmake")
  18. on_load(function (package)
  19. local version = package:version_str():gsub("-preview", "")
  20. package:add("includedirs", path.join("include", "oatpp-" .. version, "oatpp"))
  21. package:add("linkdirs", path.join("lib", "oatpp-" .. version))
  22. end)
  23. on_install("linux", "macosx", "windows|x64", function (package)
  24. local configs = {"-DOATPP_BUILD_TESTS=OFF"}
  25. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  26. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  27. if package:is_plat("windows") then
  28. table.insert(configs, "-DOATPP_MSVC_LINK_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
  29. end
  30. import("package.tools.cmake").install(package, configs)
  31. end)
  32. on_test(function (package)
  33. assert(package:check_cxxsnippets({test = [[
  34. #include "oatpp/encoding/Base64.hpp"
  35. #include "oatpp/base/Log.hpp"
  36. void test() {
  37. oatpp::String message = "oat++ web framework";
  38. oatpp::String messageEncoded = "b2F0Kysgd2ViIGZyYW1ld29yaw==";
  39. {
  40. oatpp::String encoded = oatpp::encoding::Base64::encode(message);
  41. OATPP_ASSERT(encoded == messageEncoded);
  42. oatpp::String decoded = oatpp::encoding::Base64::decode(encoded);
  43. OATPP_ASSERT(message == decoded);
  44. }
  45. }
  46. ]]}, {configs = {languages = "cxx11"}}))
  47. end)