xmake.lua 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  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_deps("cmake", "nlohmann_json")
  8. if is_plat("mingw", "windows") then
  9. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  10. end
  11. on_install("linux", "bsd", "windows", "macosx", "iphoneos", "mingw", "cross", function (package)
  12. local configs = {}
  13. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  14. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  15. table.insert(configs, "-DJSON_VALIDATOR_BUILD_EXAMPLES=OFF")
  16. table.insert(configs, "-DJSON_VALIDATOR_BUILD_TESTS=OFF")
  17. import("package.tools.cmake").install(package, configs)
  18. end)
  19. on_test(function (package)
  20. assert(package:check_cxxsnippets({test = [[
  21. #include <nlohmann/json-schema.hpp>
  22. using nlohmann::json;
  23. using nlohmann::json_schema::json_validator;
  24. static json person_schema = R"({})"_json;
  25. static void test() {
  26. json_validator validator;
  27. validator.set_root_schema(person_schema);
  28. }
  29. ]]}, {configs = {languages = "c++17"}}))
  30. end)