xmake.lua 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package("taocpp-json")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://github.com/taocpp/json")
  4. set_description("C++ header-only JSON library")
  5. set_license("MIT")
  6. add_urls("https://github.com/taocpp/json.git", {submodules = false})
  7. add_versions("2025.03.11", "11a31e12eda35c1322f9cf6ebb4cca0653d579dc")
  8. add_deps("cmake")
  9. add_deps("pkgconf")
  10. add_deps("pegtl 54a2e32bf4593ed86782b4882702286cc8d621f9")
  11. on_install(function (package)
  12. io.replace("CMakeLists.txt",
  13. [[find_package(pegtl ${TAOCPP_JSON_PEGTL_MIN_VERSION} QUIET CONFIG)]], [[include(FindPkgConfig)
  14. pkg_check_modules(pegtl REQUIRED pegtl)]], {plain = true})
  15. io.replace("CMakeLists.txt",
  16. [[target_link_libraries(taocpp-json INTERFACE taocpp::pegtl)]],
  17. [[target_include_directories(taocpp-json INTERFACE ${pegtl_INCLUDE_DIRS})]], {plain = true})
  18. local configs = {
  19. "-DTAOCPP_JSON_BUILD_TESTS=OFF",
  20. "-DTAOCPP_JSON_BUILD_EXAMPLES=OFF",
  21. "-DTAOCPP_JSON_BUILD_PERFORMANCE=OFF",
  22. "-DTAOCPP_JSON_INSTALL=ON"
  23. }
  24. import("package.tools.cmake").install(package, configs)
  25. end)
  26. on_test(function (package)
  27. assert(package:check_cxxsnippets({test = [[
  28. #include <tao/json.hpp>
  29. void test() {
  30. const tao::json::value v = tao::json::from_file( "filename.json" );
  31. }
  32. ]]}, {configs = {languages = "c++17"}}))
  33. end)