xmake.lua 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package("cpp-jwt")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://github.com/arun11299/cpp-jwt")
  4. set_description("JSON Web Token library for C++")
  5. set_license("MIT")
  6. add_urls("https://github.com/arun11299/cpp-jwt/archive/refs/tags/$(version).tar.gz",
  7. "https://github.com/arun11299/cpp-jwt.git")
  8. add_versions("v1.5.1", "7e5ec6891254c8f00128952ed6b9a73d827539136c3b804563521a0042abe72c")
  9. add_versions("v1.5", "44a59d619b0a82cae6334bb7d430d27b7fc7595e872c9f20d46aa96d2301edb2")
  10. add_versions("v1.4", "1cb8039ee15bf9bf735c26082d7ff50c23d2886d65015dd6b0668c65e17dd20f")
  11. add_deps("cmake")
  12. add_deps("openssl3")
  13. add_deps("nlohmann_json", {configs = {cmake = true}})
  14. on_install(function (package)
  15. local configs = {"-DCPP_JWT_BUILD_EXAMPLES=OFF", "-DCPP_JWT_BUILD_TESTS=OFF", "-DCPP_JWT_USE_VENDORED_NLOHMANN_JSON=OFF"}
  16. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  17. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  18. import("package.tools.cmake").install(package, configs)
  19. end)
  20. on_test(function (package)
  21. assert(package:check_cxxsnippets({test = [[
  22. #include <cassert>
  23. #include <jwt/jwt.hpp>
  24. void test() {
  25. using namespace jwt::params;
  26. jwt::jwt_object obj{algorithm("HS256"), secret("secret")};
  27. obj.add_claim("test", "12345");
  28. assert(obj.has_claim("test"));
  29. }
  30. ]]}, {configs = {languages = "cxx17"}}))
  31. end)