blob: 812978c335096616a8c256744baecafc7d0e7b35 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
From 59c389a91cfe91eebed9c36887fa2a3eca4cbd6f Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Mon, 24 Nov 2025 18:53:28 +0100
Subject: [PATCH] [rest] Permit to externally provide cJSON library
Permit to externally provide cJSON library if found with PKGConfig.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
src/rest/CMakeLists.txt | 12 +++++++++++-
third_party/CMakeLists.txt | 5 ++++-
2 files changed, 15 insertions(+), 2 deletions(-)
--- a/src/rest/CMakeLists.txt
+++ b/src/rest/CMakeLists.txt
@@ -36,11 +36,22 @@ add_library(otbr-rest
response.cpp
)
+if (CJSON_FOUND)
+ set(CJSON_LIB_TARGETS ${CJSON_LINK_LIBRARIES})
+else()
+ set(CJSON_LIB_TARGETS cjson)
+endif()
+
+target_include_directories(otbr-rest
+ PRIVATE
+ ${CJSON_INCLUDE_DIRS}
+)
+
target_link_libraries(otbr-rest
PUBLIC
http_parser
PRIVATE
- cjson
+ ${CJSON_LIB_TARGETS}
otbr-config
otbr-utils
openthread-ftd
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -28,6 +28,13 @@
add_subdirectory(openthread)
if(OTBR_REST)
- add_subdirectory(cJSON)
+ pkg_check_modules(CJSON libcjson)
+ if (CJSON_FOUND)
+ set(CJSON_FOUND ${CJSON_FOUND} PARENT_SCOPE)
+ set(CJSON_INCLUDE_DIRS ${CJSON_INCLUDE_DIRS} PARENT_SCOPE)
+ set(CJSON_LINK_LIBRARIES ${CJSON_LINK_LIBRARIES} PARENT_SCOPE)
+ else()
+ add_subdirectory(cJSON)
+ endif()
add_subdirectory(http-parser)
endif()
|