xmake.lua 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  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", "44a59d619b0a82cae6334bb7d430d27b7fc7595e872c9f20d46aa96d2301edb2")
  9. add_versions("v1.4", "1cb8039ee15bf9bf735c26082d7ff50c23d2886d65015dd6b0668c65e17dd20f")
  10. add_deps("cmake")
  11. add_deps("openssl3")
  12. add_deps("nlohmann_json", {configs = {cmake = true}})
  13. on_install(function (package)
  14. local configs = {"-DCPP_JWT_BUILD_EXAMPLES=OFF", "-DCPP_JWT_BUILD_TESTS=OFF", "-DCPP_JWT_USE_VENDORED_NLOHMANN_JSON=OFF"}
  15. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  16. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  17. import("package.tools.cmake").install(package, configs)
  18. end)
  19. on_test(function (package)
  20. assert(package:check_cxxsnippets({test = [[
  21. #include <cassert>
  22. #include <jwt/jwt.hpp>
  23. void test() {
  24. using namespace jwt::params;
  25. jwt::jwt_object obj{algorithm("HS256"), secret("secret")};
  26. obj.add_claim("test", "12345");
  27. assert(obj.has_claim("test"));
  28. }
  29. ]]}, {configs = {languages = "cxx17"}}))
  30. end)