Simplified FindPCAP CMake module.

This commit is contained in:
Jon Siwek 2010-10-19 15:37:12 -05:00
parent 570ee48cd9
commit 1542a49fff
2 changed files with 17 additions and 52 deletions

View file

@ -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

View file

@ -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
)