Skip to content

Commit 2f8a8d9

Browse files
authored
libhv: debundle nlohmann_json (#7310)
1 parent 68debc9 commit 2f8a8d9

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

packages/l/libhv/xmake.lua

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package("libhv")
44
set_license("BSD-3-Clause")
55

66
add_urls("https://github.com/ithewei/libhv.git")
7-
add_urls("https://github.com/ithewei/libhv/archive/archive/refs/$(version).zip", {excludes = {"*/html/*"}})
7+
add_urls("https://github.com/ithewei/libhv/archive/refs/$(version).zip", {excludes = {"*/html/*"}})
88

99
add_versions("v1.0.0", "39adb77cc7addaba82b69fa9a433041c8288f3d9c773fa360162e3391dcf6a7b")
1010
add_versions("v1.1.0", "a753c268976d9c4f85dcc10be2377bebc36d4cb822ac30345cf13f2a7285dbe3")
@@ -46,6 +46,7 @@ package("libhv")
4646
end
4747

4848
add_deps("cmake")
49+
add_deps("nlohmann_json", {configs = {cmake = true}})
4950

5051
on_load(function (package)
5152
if package:config("openssl") then
@@ -69,6 +70,20 @@ package("libhv")
6970
table.insert(configs, "-DBUILD_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
7071
table.insert(configs, "-DBUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
7172

73+
os.rm("cpputil/json.hpp")
74+
io.replace("cmake/vars.cmake", "cpputil/json.hpp", "", {plain = true})
75+
io.replace("CMakeLists.txt", [[target_link_libraries(hv ${LIBS})]],
76+
[[find_package(nlohmann_json CONFIG REQUIRED)
77+
target_link_libraries(hv ${LIBS} nlohmann_json::nlohmann_json)]], {plain = true})
78+
io.replace("CMakeLists.txt", [[target_link_libraries(hv_static ${LIBS})]],
79+
[[find_package(nlohmann_json CONFIG REQUIRED)
80+
target_link_libraries(hv_static ${LIBS} nlohmann_json::nlohmann_json)]], {plain = true})
81+
for _, suffix in ipairs({"**.h", "**.cpp"}) do
82+
for _, file in ipairs(os.files(suffix)) do
83+
io.replace(file, [[#include "json.hpp"]], [[#include <nlohmann/json.hpp>]], {plain = true})
84+
end
85+
end
86+
7287
for _, name in ipairs({"with_protocol",
7388
"with_http",
7489
"with_http_server",

0 commit comments

Comments
 (0)