Complete cmake support for netlink detection
authorJörg Mayer <jmayer@loplof.de>
Wed, 20 Jun 2012 20:59:43 +0000 (20:59 -0000)
committerJörg Mayer <jmayer@loplof.de>
Wed, 20 Jun 2012 20:59:43 +0000 (20:59 -0000)
svn path=/trunk/; revision=43421

CMakeLists.txt
CMakeOptions.txt
Makefile.am
cmake/modules/FindNL.cmake [new file with mode: 0644]
cmakeconfig.h.in

index e074abbb4075e5fe0dc1a783b38e8a5f7ac653e4..eae1a8d5c5da1f9d3e47d48bd721e79a0d3a4f75 100644 (file)
@@ -312,6 +312,10 @@ if(ENABLE_GEOIP)
        set(PACKAGELIST ${PACKAGELIST} GEOIP)
 endif()
 
+if(ENABLE_NETLINK)
+       set(PACKAGELIST ${PACKAGELIST} NL)
+endif()
+
 # Capabilities
 if(ENABLE_CAP)
        set(PACKAGELIST ${PACKAGELIST} CAP)
@@ -380,6 +384,9 @@ endif()
 if(ENABLE_AIRPCAP)
        set(HAVE_AIRPCAP 1)
 endif()
+if(HAVE_LIBNL AND ENABLE_AIRPCAP)
+       message(ERROR "Airpcap and Libnl support are mutually exclusive")
+endif()
 # No matter which version of GTK is present
 if(GTK2_FOUND OR GTK3_FOUND)
        set(GTK_FOUND ON)
@@ -904,6 +911,7 @@ if(BUILD_dumpcap AND PCAP_FOUND)
                ${GTHREAD2_LIBRARIES}
                ${ZLIB_LIBRARIES}
                ${APPLE_COCOA_LIBRARY}
+               ${LIBNL_LIBRARIES}
        )
        set(dumpcap_FILES
                svnversion.h
index 21af1f2d936096e7880b97bcd6ab7c90b975d7d2..cb983b96f4983983028d989f3e28eacf499472b9 100644 (file)
@@ -44,5 +44,6 @@ option(ENABLE_GCRYPT     "Build with GNU crypto support" ON)
 option(ENABLE_GEOIP      "Build with GeoIP support" ON)
 option(ENABLE_CAP        "Build with posix capabilities support" ON)
 option(ENABLE_CARES      "Build with c_ares support" ON)
+option(ENABLE_LIBNL      "Build with libnl support" ON)
 # todo Mostly hardcoded
 option(ENABLE_KERBEROS   "Build with Kerberos support" ON)
index d692e071b1a079b80ab0792ad6d6f72eb28160cd..4b0ab05676075c253bd792ad86cac73ebce88042 100644 (file)
@@ -832,6 +832,7 @@ EXTRA_DIST = \
        cmake/modules/FindGTK3.cmake            \
        cmake/modules/FindHtmlViewer.cmake      \
        cmake/modules/FindKERBEROS.cmake        \
+       cmake/modules/FindLIBNL.cmake           \
        cmake/modules/FindLEX.cmake             \
        cmake/modules/FindLUA.cmake             \
        cmake/modules/FindLYNX.cmake            \
diff --git a/cmake/modules/FindNL.cmake b/cmake/modules/FindNL.cmake
new file mode 100644 (file)
index 0000000..d7c4c29
--- /dev/null
@@ -0,0 +1,50 @@
+#
+# $Id$
+#
+# - Find libnl
+# Find the native LIBNL includes and library
+#
+#  LIBNL_INCLUDE_DIRS - where to find libnl.h, etc.
+#  LIBNL_LIBRARIES    - List of libraries when using libnl3.
+#  LIBNL_FOUND        - True if libnl found.
+
+FIND_PATH(
+    LIBNL_INCLUDE_DIR
+  NAMES
+    netlink/netlink.h
+  PATHS
+    /opt/local/include
+    /sw/include
+    /usr/include
+    /usr/local/include
+  PATH_SUFFIXES
+    libnl3
+)
+
+SET(LIBNL_NAMES nl-3)
+FIND_LIBRARY(LIBNL_LIBRARY NAMES ${LIBNL_NAMES} )
+FIND_LIBRARY(LIBNLGENL_LIBRARY NAMES nl-genl-3 )
+FIND_LIBRARY(LIBNLROUTE_LIBRARY NAMES nl-route-3 )
+
+IF(NOT LIBNL_FOUND)
+  FIND_PATH(LIBNL_INCLUDE_DIR netlink/netlink.h /usr/include/)
+  SET(LIBNL_NAMES nl)
+  FIND_LIBRARY(LIBNL_LIBRARY NAMES ${LIBNL_NAMES} )
+  FIND_LIBRARY(LIBNLGENL_LIBRARY NAMES nl-genl )
+  FIND_LIBRARY(LIBNLROUTE_LIBRARY NAMES nl-route )
+ENDIF()
+
+# handle the QUIETLY and REQUIRED arguments and set LIBNL_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBNL DEFAULT_MSG LIBNL_LIBRARY LIBNL_INCLUDE_DIRS)
+
+IF(LIBNL_FOUND)
+  SET( LIBNL_LIBRARIES ${LIBNL_LIBRARY} ${LIBNLGENL_LIBRARY} ${LIBNLROUTE_LIBRARY})
+  SET( LIBNL_INCLUDE_DIRS ${LIBNL_INCLUDE_DIR})
+ELSE()
+  SET( LIBNL_LIBRARIES )
+  SET( LIBNL_INCLUDE_DIRS )
+ENDIF()
+
+MARK_AS_ADVANCED( LIBNL_LIBRARIES LIBNL_INCLUDE_DIRS )
index 8578ef05be8f641e83b9eb59e0850f4b1587665f..f0ed5fffd00c7d1e9360feeb82defe0ad90e6499 100644 (file)
@@ -60,6 +60,9 @@
 /* Define to use the airpcap library */
 #cmakedefine HAVE_AIRPCAP 1
 
+/* Define to use the libnl library */
+#cmakedefine HAVE_LIBNL 1
+
 /* Define to use C ares library */
 #cmakedefine HAVE_C_ARES 1