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) #set(BIND_ROOT_DIR path/to/your/bind)
# Uncomment to specify a custom prefix that contains the libpcap installation. # Uncomment to specify a custom prefix that contains the libpcap installation.
#set(PCAP_ROOT path/to/your/pcap) #set(PCAP_ROOT_DIR 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)
# TODO: more dependencies: # TODO: more dependencies:
# Flex # Flex

View file

@ -7,15 +7,9 @@
# Variables used by this module, they can change the default behaviour and need # Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package: # to be set before calling find_package:
# #
# PCAP_ROOT Preferred installation prefix for searching for # PCAP_ROOT_DIR Set this variable to the root installation of
# libpcap, set this if the module has problems # libpcap if the module has problems finding the
# finding the proper installation path. # 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.
# #
# Variables defined by this module: # Variables defined by this module:
# #
@ -23,51 +17,28 @@
# PCAP_INCLUDE_DIR The libpcap include directories. # PCAP_INCLUDE_DIR The libpcap include directories.
# PCAP_LIBRARY The libpcap library. # PCAP_LIBRARY The libpcap library.
if (PCAP_ROOT) find_path(PCAP_ROOT_DIR
message(STATUS "Searching for libpcap rooted in: ${PCAP_ROOT}") NAMES include/pcap.h
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_INCLUDE_DIR find_path(PCAP_INCLUDE_DIR
NAMES NAMES pcap.h
pcap.h HINTES ${PCAP_ROOT_DIR}/include
PATHS
${PCAP_ADDITIONAL_INCLUDE_SEARCH_DIRS}
) )
find_library(PCAP_LIBRARY find_library(PCAP_LIBRARY
NAMES NAMES pcap
pcap HINTS ${PCAP_ROOT_DIR}/lib
PATHS
${PCAP_ADDITIONAL_LIBRARY_SEARCH_DIRS}
) )
if (PCAP_INCLUDE_DIR AND PCAP_LIBRARY) include(FindPackageHandleStandardArgs)
set(PCAP_FOUND true) find_package_handle_standard_args(PCAP DEFAULT_MSG
endif () PCAP_LIBRARY
PCAP_INCLUDE_DIR
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 ()
mark_as_advanced( mark_as_advanced(
PCAP_ROOT_DIR
PCAP_INCLUDE_DIR PCAP_INCLUDE_DIR
PCAP_LIBRARY PCAP_LIBRARY
) )