build: find and use libnl header dirs
authorYousong Zhou <yszhou4tech@gmail.com>
Wed, 14 Oct 2020 08:04:01 +0000 (16:04 +0800)
committerYousong Zhou <yszhou4tech@gmail.com>
Thu, 22 Oct 2020 02:20:32 +0000 (10:20 +0800)
Name of the libnl .pc file is libnl-3.0.pc

This commit is mainly for testing netifd build on usual Linux systems.

netifd Makefile in current OpenWrt build system specifies custom cmake
flags to directly point to libnl-tiny

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
CMakeLists.txt

index d6203aac3a8f5e55451a7bf6b0663ea15da44ff3..9d19817484b00696d4385ce66812cf73a4190742 100644 (file)
@@ -27,8 +27,12 @@ SET(LIBS
        ubox ubus uci json-c blobmsg_json)
 
 IF (NOT DEFINED LIBNL_LIBS)
-  FIND_LIBRARY(libnl NAMES libnl-3 libnl nl-3 nl)
-  SET(LIBNL_LIBS ${libnl})
+       include(FindPkgConfig)
+       pkg_search_module(LIBNL libnl-3.0 libnl-3 libnl nl-3 nl)
+       IF (LIBNL_FOUND)
+               include_directories(${LIBNL_INCLUDE_DIRS})
+               SET(LIBNL_LIBS ${LIBNL_LIBRARIES})
+       ENDIF()
 ENDIF()
 
 IF("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" AND NOT DUMMY_MODE)