[OpenWrt-Devel] [PATCH ubus] cmake: Fix find_library for ubusd and examples/server
Florian Fainelli
f.fainelli at gmail.com
Fri Jul 1 17:56:38 EDT 2016
Both ubusd and cli TARGET_LINK_LIBRARIES reference ${json} which is
obtained via find_library(), but since the find_library() is searched
after the TARGET_LINK_LIBRARIES for ubusd, ubusd always gets an empty
${json} variable.
examples/server also links against libjson-c, but we were not setting
TARGET_LINK_LIBRARIES accordingly, so do that too with ${json} appended.
This was causing linking errors for ubusd and then examples/server using
an external toolchain (stbgcc-4.8-1.x).
Fixes: 9f52d1769b762 ("cli: use the new json-c library name")
Signed-off-by: Florian Fainelli <f.fainelli at gmail.com>
---
CMakeLists.txt | 3 ++-
examples/CMakeLists.txt | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 70a0de6536d9..7123096a0f93 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,10 +32,11 @@ INCLUDE_DIRECTORIES(${ubox_include_dir})
ADD_LIBRARY(ubus SHARED libubus.c libubus-io.c libubus-obj.c libubus-sub.c libubus-req.c libubus-acl.c)
TARGET_LINK_LIBRARIES(ubus ${ubox_library})
+find_library(json NAMES json-c json)
+
ADD_EXECUTABLE(ubusd ubusd.c ubusd_id.c ubusd_obj.c ubusd_proto.c ubusd_event.c ubusd_acl.c ubusd_monitor.c)
TARGET_LINK_LIBRARIES(ubusd ${ubox_library} ${blob_library} ${json})
-find_library(json NAMES json-c json)
ADD_EXECUTABLE(cli cli.c)
SET_TARGET_PROPERTIES(cli PROPERTIES OUTPUT_NAME ubus)
TARGET_LINK_LIBRARIES(cli ubus ${ubox_library} ${blob_library} ${json})
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 006dac42a27c..81f999752950 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -5,7 +5,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..)
IF (BUILD_EXAMPLES)
ADD_EXECUTABLE(server server.c count.c)
- TARGET_LINK_LIBRARIES(server ubus ${ubox_library} ${blob_library})
+ TARGET_LINK_LIBRARIES(server ubus ${ubox_library} ${blob_library} ${json})
ADD_EXECUTABLE(client client.c count.c)
TARGET_LINK_LIBRARIES(client ubus ${ubox_library})
--
2.7.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list