2
0

xmake.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package("cjson")
  2. set_homepage("https://github.com/DaveGamble/cJSON")
  3. set_description("Ultralightweight JSON parser in ANSI C.")
  4. set_license("MIT")
  5. set_urls("https://github.com/DaveGamble/cJSON/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/DaveGamble/cJSON.git")
  7. add_versions("v1.7.18", "3aa806844a03442c00769b83e99970be70fbef03735ff898f4811dd03b9f5ee5")
  8. add_versions("v1.7.15", "5308fd4bd90cef7aa060558514de6a1a4a0819974a26e6ed13973c5f624c24b2")
  9. add_deps("cmake")
  10. on_install(function (package)
  11. if package:is_plat("windows") then
  12. if package:config("shared") then
  13. package:add("defines", "CJSON_IMPORT_SYMBOLS")
  14. else
  15. package:add("defines", "CJSON_HIDE_SYMBOLS")
  16. end
  17. end
  18. io.replace("CMakeLists.txt", "-Werror", "", {plain = true})
  19. local configs = {"-DENABLE_CJSON_TEST=OFF", "-DCMAKE_POLICY_DEFAULT_CMP0057=NEW"}
  20. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  21. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  22. import("package.tools.cmake").install(package, configs)
  23. if package:is_plat("windows") and package:is_debug() then
  24. local dir = package:installdir(package:config("shared") and "bin" or "lib")
  25. os.trycp(path.join(package:buildir(), "cjson.pdb"), dir)
  26. end
  27. end)
  28. on_test(function (package)
  29. assert(package:has_cfuncs("cJSON_malloc", {includes = "cjson/cJSON.h"}))
  30. end)