Fix possible linker errors by using CMake find_library macro

Fixes following errors while compiling natively on x86:

 cc -fPIC -shared  -o rpcsys.so sys.c.o -lubox -lubus
 ld: cannot find -lubox
 ld: cannot find -lubus

Signed-off-by: Petr Štetiar <ynezz@true.cz>
This commit is contained in:
Petr Štetiar 2018-06-05 09:41:25 +02:00
parent 569284a119
commit 89bfaa4246

View file

@ -22,6 +22,10 @@ IF(HAVE_SHADOW)
ADD_DEFINITIONS(-DHAVE_SHADOW)
ENDIF()
FIND_LIBRARY(uci NAMES uci)
FIND_LIBRARY(ubus NAMES ubus)
FIND_LIBRARY(ubox NAMES ubox)
FIND_LIBRARY(blobmsg_json NAMES blobmsg_json)
FIND_LIBRARY(json NAMES json-c json)
FIND_LIBRARY(crypt NAMES crypt)
IF(crypt STREQUAL "crypt-NOTFOUND")
@ -35,28 +39,29 @@ FIND_PATH(ubox_include_dir libubox/blobmsg_json.h)
INCLUDE_DIRECTORIES(${ubox_include_dir})
ADD_EXECUTABLE(rpcd main.c exec.c session.c uci.c plugin.c)
TARGET_LINK_LIBRARIES(rpcd ubox ubus uci dl blobmsg_json ${json} ${crypt})
TARGET_LINK_LIBRARIES(rpcd ${ubox} ${ubus} ${uci} ${blobmsg_json} ${json} ${crypt} dl)
SET(PLUGINS "")
IF(FILE_SUPPORT)
SET(PLUGINS ${PLUGINS} file_plugin)
ADD_LIBRARY(file_plugin MODULE file.c)
TARGET_LINK_LIBRARIES(file_plugin ubox ubus)
TARGET_LINK_LIBRARIES(file_plugin ${ubox} ${ubus})
SET_TARGET_PROPERTIES(file_plugin PROPERTIES OUTPUT_NAME file PREFIX "")
ENDIF()
IF(RPCSYS_SUPPORT)
SET(PLUGINS ${PLUGINS} rpcsys_plugin)
ADD_LIBRARY(rpcsys_plugin MODULE sys.c)
TARGET_LINK_LIBRARIES(rpcsys_plugin ubox ubus)
TARGET_LINK_LIBRARIES(rpcsys_plugin ${ubox} ${ubus})
SET_TARGET_PROPERTIES(rpcsys_plugin PROPERTIES OUTPUT_NAME rpcsys PREFIX "")
ENDIF()
IF (IWINFO_SUPPORT)
FIND_LIBRARY(iwinfo NAMES iwinfo)
SET(PLUGINS ${PLUGINS} iwinfo_plugin)
ADD_LIBRARY(iwinfo_plugin MODULE iwinfo.c)
TARGET_LINK_LIBRARIES(iwinfo_plugin ubox ubus iwinfo)
TARGET_LINK_LIBRARIES(iwinfo_plugin ${ubox} ${ubus} ${iwinfo})
SET_TARGET_PROPERTIES(iwinfo_plugin PROPERTIES OUTPUT_NAME iwinfo PREFIX "")
ENDIF()