1###################################################################
2# - Find the Dumb (not so!) Library: dnet
3# Find the DUMBNET includes and library
4# http://code.google.com/p/libdnet/
5#
6# The environment variable DUMBNETDIR allows to specficy where to find
7# libdnet in non standard location.
8#
9#  DNET_INCLUDE_DIR - where to find dnet.h, etc.
10#  DNET_LIBRARIES   - List of libraries when using dnet.
11#  DNET_FOUND       - True if dnet found.
12#  HAVE_DUMBNET_H   - True if found dumnet rather than dnet
13
14set(ERROR_MESSAGE
15    "
16    ERROR!  dnet header not found, go get it from
17    http://code.google.com/p/libdnet/ or use the --with-dnet-*
18    options, if you have it installed in an unusual place.
19    "
20)
21
22# Check for libdumbnet first, then libdnet
23
24find_path(DUMBNET_INCLUDE_DIR dumbnet.h
25    HINTS ${DNET_INCLUDE_DIR_HINT})
26
27# If we found libdumbnet header, define HAVE_DUMBNET_H for config.h generation
28# and search for libdumbnet.
29if (DUMBNET_INCLUDE_DIR)
30    set(HAVE_DUMBNET_H "1")
31    set(DNET_INCLUDE_DIR ${DUMBNET_INCLUDE_DIR})
32    find_library(DNET_LIBRARIES NAMES dumbnet
33        HINTS ${DNET_LIBRARIES_DIR_HINT})
34else ()
35    find_path(DNET_INCLUDE_DIR dnet.h
36        HINTS ${DNET_INCLUDE_DIR_HINT})
37    find_library(DNET_LIBRARIES NAMES dnet
38        HINTS ${DNET_LIBRARIES_DIR_HINT})
39endif()
40
41include(FindPackageHandleStandardArgs)
42find_package_handle_standard_args(DNET
43    REQUIRED_VARS DNET_INCLUDE_DIR DNET_LIBRARIES
44    FAIL_MESSAGE "${ERROR_MESSAGE}"
45)
46
47mark_as_advanced(
48    DNET_INCLUDE_DIR
49    DNET_LIBRARIES
50)
51