2
0

xmake.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package("json-schema-validator")
  2. set_homepage("https://github.com/pboettch/json-schema-validator")
  3. set_description("JSON schema validator for JSON for Modern C++")
  4. add_urls("https://github.com/pboettch/json-schema-validator/archive/refs/tags/$(version).tar.gz",
  5. "https://github.com/pboettch/json-schema-validator.git")
  6. add_versions("2.1.0", "83f61d8112f485e0d3f1e72d51610ba3924b179926a8376aef3c038770faf202")
  7. add_versions("2.3.0", "2c00b50023c7d557cdaa71c0777f5bcff996c4efd7a539e58beaa4219fa2a5e1")
  8. add_deps("cmake", "nlohmann_json")
  9. if is_plat("mingw", "windows") then
  10. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  11. end
  12. if is_host("windows") then
  13. set_policy("platform.longpaths", true)
  14. end
  15. on_install("linux", "bsd", "windows", "macosx", "iphoneos", "mingw", "cross", function (package)
  16. local configs = {}
  17. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  18. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  19. table.insert(configs, "-DJSON_VALIDATOR_BUILD_EXAMPLES=OFF")
  20. table.insert(configs, "-DJSON_VALIDATOR_BUILD_TESTS=OFF")
  21. import("package.tools.cmake").install(package, configs)
  22. end)
  23. on_test(function (package)
  24. assert(package:check_cxxsnippets({test = [[
  25. #include <nlohmann/json-schema.hpp>
  26. using nlohmann::json;
  27. using nlohmann::json_schema::json_validator;
  28. static json person_schema = R"({})"_json;
  29. static void test() {
  30. json_validator validator;
  31. validator.set_root_schema(person_schema);
  32. }
  33. ]]}, {configs = {languages = "c++17"}}))
  34. end)