From: Petr Štetiar Date: Tue, 5 Jun 2018 07:41:25 +0000 (+0200) Subject: Fix possible linker errors by using CMake find_library macro X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=89bfaa42460696fb3c37c232f69c2afd5c6d909e;p=oweals%2Frpcd.git 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 --- 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()