1*4882a593SmuzhiyunFrom 89ad9c143825b13d028c2f1713d55e83135d5c0f Mon Sep 17 00:00:00 2001
2*4882a593SmuzhiyunFrom: Fabrice Fontaine <fontaine.fabrice@gmail.com>
3*4882a593SmuzhiyunDate: Sat, 5 Sep 2020 15:38:33 +0200
4*4882a593SmuzhiyunSubject: [PATCH] CMakesLists.txt: fix static build with pcap
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunUse pkg-config to find the dependencies of pcap such as libnl otherwise
7*4882a593Smuzhiyuna static-only build will fail on:
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun[100%] Linking C executable ef
10*4882a593Smuzhiyun/srv/storage/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabi/8.3.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: /srv/storage/autobuild/run/instance-0/output-1/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libpcap.a(pcap-linux.o): in function `nl80211_init':
11*4882a593Smuzhiyunpcap-linux.c:(.text+0x460): undefined reference to `nl_socket_alloc'
12*4882a593Smuzhiyun/srv/storage/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabi/8.3.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: pcap-linux.c:(.text+0x498): undefined reference to `genl_connect'
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunFixes:
15*4882a593Smuzhiyun - http://autobuild.buildroot.org/results/99062bfc8c21c32bc835acae675aede7c9cf0c90
16*4882a593Smuzhiyun
17*4882a593SmuzhiyunSigned-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
18*4882a593Smuzhiyun[Upstream status: https://github.com/microchip-ung/easyframes/pull/2]
19*4882a593Smuzhiyun---
20*4882a593Smuzhiyun CMakeLists.txt | 20 ++++++++++++++------
21*4882a593Smuzhiyun 1 file changed, 14 insertions(+), 6 deletions(-)
22*4882a593Smuzhiyun
23*4882a593Smuzhiyundiff --git a/CMakeLists.txt b/CMakeLists.txt
24*4882a593Smuzhiyunindex a62a950..5be128c 100644
25*4882a593Smuzhiyun--- a/CMakeLists.txt
26*4882a593Smuzhiyun+++ b/CMakeLists.txt
27*4882a593Smuzhiyun@@ -7,13 +7,21 @@ include_directories(src)
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun set(_LIBPCAP "")
31*4882a593Smuzhiyun-FIND_PATH(PCAP_INCLUDE_DIR NAMES pcap/pcap.h)
32*4882a593Smuzhiyun-FIND_LIBRARY(PCAP_LIBRARY NAMES pcap)
33*4882a593Smuzhiyun-
34*4882a593Smuzhiyun-if (PCAP_LIBRARY)
35*4882a593Smuzhiyun+find_package(PkgConfig)
36*4882a593Smuzhiyun+pkg_check_modules(PCAP libpcap)
37*4882a593Smuzhiyun+if (PCAP_FOUND)
38*4882a593Smuzhiyun     add_definitions(-DHAS_LIBPCAP)
39*4882a593Smuzhiyun-    include_directories(${PCAP_INCLUDE_DIR})
40*4882a593Smuzhiyun-    set(_LIBPCAP ${PCAP_LIBRARY})
41*4882a593Smuzhiyun+    include_directories(${PCAP_INCLUDE_DIRS})
42*4882a593Smuzhiyun+    set(_LIBPCAP ${PCAP_LIBRARIES})
43*4882a593Smuzhiyun+else()
44*4882a593Smuzhiyun+    FIND_PATH(PCAP_INCLUDE_DIR NAMES pcap/pcap.h)
45*4882a593Smuzhiyun+    FIND_LIBRARY(PCAP_LIBRARY NAMES pcap)
46*4882a593Smuzhiyun+
47*4882a593Smuzhiyun+    if (PCAP_LIBRARY)
48*4882a593Smuzhiyun+        add_definitions(-DHAS_LIBPCAP)
49*4882a593Smuzhiyun+        include_directories(${PCAP_INCLUDE_DIR})
50*4882a593Smuzhiyun+        set(_LIBPCAP ${PCAP_LIBRARY})
51*4882a593Smuzhiyun+    endif()
52*4882a593Smuzhiyun endif()
53*4882a593Smuzhiyun
54*4882a593Smuzhiyun add_library(libef STATIC
55*4882a593Smuzhiyun--
56*4882a593Smuzhiyun2.28.0
57*4882a593Smuzhiyun
58