xmake.lua 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. set_license("MIT")
  5. add_urls("https://github.com/pboettch/json-schema-validator/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/pboettch/json-schema-validator.git")
  7. add_versions("2.4.0", "24cbb114609cc9b43d4018b8d03e082ff5d2f26f5dce8bd36538097267b63af9")
  8. add_versions("2.3.0", "2c00b50023c7d557cdaa71c0777f5bcff996c4efd7a539e58beaa4219fa2a5e1")
  9. add_versions("2.1.0", "83f61d8112f485e0d3f1e72d51610ba3924b179926a8376aef3c038770faf202")
  10. if is_host("windows") then
  11. set_policy("platform.longpaths", true)
  12. end
  13. add_deps("cmake")
  14. add_deps("nlohmann_json", {configs = {cmake = true}})
  15. on_install(function (package)
  16. if package:is_plat("windows") and package:config("shared") then
  17. package:add("defines", "JSON_SCHEMA_VALIDATOR_IMPORTS")
  18. end
  19. local configs = {
  20. "-DJSON_VALIDATOR_BUILD_EXAMPLES=OFF",
  21. "-DJSON_VALIDATOR_BUILD_TESTS=OFF",
  22. "-DBUILD_TESTS=OFF", -- 2.1.0 option
  23. "-DBUILD_EXAMPLES=OFF",
  24. }
  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. table.insert(configs, "-DJSON_VALIDATOR_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  28. import("package.tools.cmake").install(package, configs)
  29. end)
  30. on_test(function (package)
  31. assert(package:check_cxxsnippets({test = [[
  32. #include <nlohmann/json-schema.hpp>
  33. using nlohmann::json;
  34. using nlohmann::json_schema::json_validator;
  35. static json person_schema = R"({})"_json;
  36. static void test() {
  37. json_validator validator;
  38. validator.set_root_schema(person_schema);
  39. }
  40. ]]}, {configs = {languages = "c++17"}}))
  41. end)