From 89bfaa42460696fb3c37c232f69c2afd5c6d909e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20=C5=A0tetiar?= Date: Tue, 5 Jun 2018 09:41:25 +0200 Subject: [PATCH] Fix possible linker errors by using CMake find_library macro MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- CMakeLists.txt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ceb472e..3bfc286 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() -- 2.25.1