package An official xmake package repository https://xrepo.xmake.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.5 KiB

6 years ago
package("json-c")
set_homepage("https://github.com/json-c/json-c/wiki")
set_description("JSON parser for C")
set_license("MIT")
6 years ago
add_urls("https://github.com/json-c/json-c.git")
add_urls("https://github.com/json-c/json-c/archive/refs/tags/json-c-$(version).tar.gz", {
version = function (version)
local list = {
["0.17"] = "20230812",
}
return version .. "-" .. list[tostring(version)]
end})
6 years ago
add_versions("0.17", "024d302a3aadcbf9f78735320a6d5aedf8b77876c8ac8bbb95081ca55054c7eb")
6 years ago
add_deps("cmake")
on_install(function (package)
if package:config("shared") and package:is_plat("windows") then
package:add("defines", "JSON_EXPORT=__declspec(dllimport)")
end
local configs = {"-DBUILD_TESTING=OFF", "-DBUILD_APPS=OFF"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-DBUILD_STATIC_LIBS=" .. (package:config("shared") and "OFF" or "ON"))
if package:config("pic") ~= false then
table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
table.insert(configs, "-DDISABLE_STATIC_FPIC=OFF")
end
import("package.tools.cmake").install(package, configs)
6 years ago
end)
on_test(function (package)
assert(package:has_cfuncs("json_object_new_object", {includes = "json-c/json.h"}))
end)