diff --git a/BuildOptions.cmake b/BuildOptions.cmake index af9a9b293d..87eef62ee3 100644 --- a/BuildOptions.cmake +++ b/BuildOptions.cmake @@ -48,13 +48,7 @@ set(ENABLE_PERFTOOLS false #set(BIND_ROOT_DIR path/to/your/bind) # Uncomment to specify a custom prefix that contains the libpcap installation. -#set(PCAP_ROOT path/to/your/pcap) - -# Uncomment to specify a custom directory that contains libpcap headers. -#set(PCAP_INCLUDEDIR path/to/your/pcap/include) - -# Uncomment to specify a custom directory that contains the libpcap library. -#set(PCAP_LIBRARYDIR path/to/your/pcap/lib) +#set(PCAP_ROOT_DIR path/to/your/pcap) # TODO: more dependencies: # Flex diff --git a/cmake/FindPCAP.cmake b/cmake/FindPCAP.cmake index d309b1ead9..cb850f2e11 100644 --- a/cmake/FindPCAP.cmake +++ b/cmake/FindPCAP.cmake @@ -7,15 +7,9 @@ # Variables used by this module, they can change the default behaviour and need # to be set before calling find_package: # -# PCAP_ROOT Preferred installation prefix for searching for -# libpcap, set this if the module has problems -# finding the proper installation path. -# PCAP_INCLUDEDIR Set this to the include directory of libpcap if -# the module has problems finding the installation -# path. -# PCAP_LIBRARYDIR Set this to the library directory of libpcap if -# the module has problems finding the installation -# path. +# PCAP_ROOT_DIR Set this variable to the root installation of +# libpcap if the module has problems finding the +# proper installation path. # # Variables defined by this module: # @@ -23,51 +17,28 @@ # PCAP_INCLUDE_DIR The libpcap include directories. # PCAP_LIBRARY The libpcap library. -if (PCAP_ROOT) - message(STATUS "Searching for libpcap rooted in: ${PCAP_ROOT}") - set(PCAP_ADDITIONAL_INCLUDE_SEARCH_DIRS ${PCAP_ROOT}/include) - set(PCAP_ADDITIONAL_LIBRARY_SEARCH_DIRS ${PCAP_ROOT}/lib) -endif () - -if (PCAP_INCLUDEDIR) - message(STATUS "Searching for libpcap headers in: ${PCAP_INCLUDEDIR}") - set(PCAP_ADDITIONAL_INCLUDE_SEARCH_DIRS ${PCAP_INCLUDEDIR}) -endif () - -if (PCAP_LIBRARYDIR) - message(STATUS "Searching for libpcap libraries in: ${PCAP_LIBRARYDIR}") - set(PCAP_ADDITIONAL_LIBRARY_SEARCH_DIRS ${PCAP_LIBRARYDIR}) -endif () +find_path(PCAP_ROOT_DIR + NAMES include/pcap.h +) find_path(PCAP_INCLUDE_DIR - NAMES - pcap.h - PATHS - ${PCAP_ADDITIONAL_INCLUDE_SEARCH_DIRS} + NAMES pcap.h + HINTES ${PCAP_ROOT_DIR}/include ) find_library(PCAP_LIBRARY - NAMES - pcap - PATHS - ${PCAP_ADDITIONAL_LIBRARY_SEARCH_DIRS} + NAMES pcap + HINTS ${PCAP_ROOT_DIR}/lib ) -if (PCAP_INCLUDE_DIR AND PCAP_LIBRARY) - set(PCAP_FOUND true) -endif () - -if (PCAP_FOUND) - if (NOT PCAP_FIND_QUIETLY) - message(STATUS "Found libpcap") - endif () -else () - if (PCAP_FIND_REQUIRED) - message(FATAL_ERROR "Could not find required libpcap") - endif () -endif () +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PCAP DEFAULT_MSG + PCAP_LIBRARY + PCAP_INCLUDE_DIR +) mark_as_advanced( + PCAP_ROOT_DIR PCAP_INCLUDE_DIR PCAP_LIBRARY )