Annotation of previous_trunk/cmake/FindPCAP.cmake, revision 1.1

1.1     ! root        1: # - Try to find libpcap include dirs and libraries
        !             2: #
        !             3: # Usage of this module as follows:
        !             4: #
        !             5: #     find_package(PCAP)
        !             6: #
        !             7: # Variables used by this module, they can change the default behaviour and need
        !             8: # to be set before calling find_package:
        !             9: #
        !            10: #  PCAP_ROOT_DIR             Set this variable to the root installation of
        !            11: #                            libpcap if the module has problems finding the
        !            12: #                            proper installation path.
        !            13: #
        !            14: # Variables defined by this module:
        !            15: #
        !            16: #  PCAP_FOUND                System has libpcap, include and library dirs found
        !            17: #  PCAP_INCLUDE_DIR          The libpcap include directories.
        !            18: #  PCAP_LIBRARY              The libpcap library (possibly includes a thread
        !            19: #                            library e.g. required by pf_ring's libpcap)
        !            20: #  HAVE_PF_RING              If a found version of libpcap supports PF_RING
        !            21: 
        !            22: find_path(PCAP_ROOT_DIR
        !            23:     NAMES include/pcap.h
        !            24:     HINTS /c/MinGW/WpdPack
        !            25: )
        !            26: 
        !            27: find_path(PCAP_INCLUDE_DIR
        !            28:     NAMES pcap.h
        !            29:     HINTS ${PCAP_ROOT_DIR}/include
        !            30: )
        !            31: 
        !            32: find_library(PCAP_LIBRARY
        !            33:     NAMES pcap wpcap
        !            34:     HINTS ${PCAP_ROOT_DIR}/lib ${PCAP_ROOT_DIR}/Lib
        !            35: )
        !            36: 
        !            37: include(FindPackageHandleStandardArgs)
        !            38: find_package_handle_standard_args(PCAP DEFAULT_MSG
        !            39:     PCAP_LIBRARY
        !            40:     PCAP_INCLUDE_DIR
        !            41: )
        !            42: 
        !            43: include(CheckCSourceCompiles)
        !            44: set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY})
        !            45: check_c_source_compiles("int main() { return 0; }" PCAP_LINKS_SOLO)
        !            46: set(CMAKE_REQUIRED_LIBRARIES)
        !            47: 
        !            48: # check if linking against libpcap also needs to link against a thread library
        !            49: if (NOT PCAP_LINKS_SOLO)
        !            50:     find_package(Threads)
        !            51:     if (THREADS_FOUND)
        !            52:         set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
        !            53:         check_c_source_compiles("int main() { return 0; }" PCAP_NEEDS_THREADS)
        !            54:         set(CMAKE_REQUIRED_LIBRARIES)
        !            55:     endif ()
        !            56:     if (THREADS_FOUND AND PCAP_NEEDS_THREADS)
        !            57:         set(_tmp ${PCAP_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
        !            58:         list(REMOVE_DUPLICATES _tmp)
        !            59:         set(PCAP_LIBRARY ${_tmp}
        !            60:             CACHE STRING "Libraries needed to link against libpcap" FORCE)
        !            61:     else ()
        !            62:         message(FATAL_ERROR "Couldn't determine how to link against libpcap")
        !            63:     endif ()
        !            64: endif ()
        !            65: 
        !            66: include(CheckFunctionExists)
        !            67: set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY})
        !            68: check_function_exists(pcap_get_pfring_id HAVE_PF_RING)
        !            69: set(CMAKE_REQUIRED_LIBRARIES)
        !            70: 
        !            71: mark_as_advanced(
        !            72:     PCAP_ROOT_DIR
        !            73:     PCAP_INCLUDE_DIR
        !            74:     PCAP_LIBRARY
        !            75: )

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.