Debian Codegraph @

monero/cmake/FindMiniupnpc.cmake

raw
1 # --------------------------------- FindMiniupnpc Start ---------------------------------
2 # Locate miniupnp library
3 # This module defines
4 # MINIUPNP_FOUND, if false, do not try to link to miniupnp
5 # MINIUPNP_LIBRARY, the miniupnp variant
6 # MINIUPNP_INCLUDE_DIR, where to find miniupnpc.h and family)
7 # MINIUPNPC_VERSION_1_7_OR_HIGHER, set if we detect the version of miniupnpc is 1.7 or higher
8 #
9 # Note that the expected include convention is
10 # #include "miniupnpc.h"
11 # and not
12 # #include <miniupnpc/miniupnpc.h>
13 # This is because, the miniupnpc location is not standardized and may exist
14 # in locations other than miniupnpc/
15
16 if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY)
17 # Already in cache, be silent
18 set(MINIUPNP_FIND_QUIETLY TRUE)
19 endif ()
20
21 find_path(MINIUPNP_INCLUDE_DIR miniupnpc.h
22 HINTS $ENV{MINIUPNP_INCLUDE_DIR}
23 PATH_SUFFIXES miniupnpc
24 )
25
26 find_library(MINIUPNP_LIBRARY miniupnpc
27 HINTS $ENV{MINIUPNP_LIBRARY}
28 )
29
30 find_library(MINIUPNP_STATIC_LIBRARY libminiupnpc.a
31 HINTS $ENV{MINIUPNP_STATIC_LIBRARY}
32 )
33
34 set(MINIUPNP_INCLUDE_DIRS ${MINIUPNP_INCLUDE_DIR})
35 set(MINIUPNP_LIBRARIES ${MINIUPNP_LIBRARY})
36 set(MINIUPNP_STATIC_LIBRARIES ${MINIUPNP_STATIC_LIBRARY})
37
38 include(FindPackageHandleStandardArgs)
39 find_package_handle_standard_args(
40 MiniUPnPc DEFAULT_MSG
41 MINIUPNP_INCLUDE_DIR
42 MINIUPNP_LIBRARY
43 )
44
45 IF(MINIUPNPC_FOUND)
46 file(STRINGS "${MINIUPNP_INCLUDE_DIR}/miniupnpc.h" MINIUPNPC_API_VERSION_STR REGEX "^#define[\t ]+MINIUPNPC_API_VERSION[\t ]+[0-9]+")
47 if(MINIUPNPC_API_VERSION_STR MATCHES "^#define[\t ]+MINIUPNPC_API_VERSION[\t ]+([0-9]+)")
48 set(MINIUPNPC_API_VERSION "${CMAKE_MATCH_1}")
49 if (${MINIUPNPC_API_VERSION} GREATER "10" OR ${MINIUPNPC_API_VERSION} EQUAL "10")
50 message(STATUS "Found miniupnpc API version " ${MINIUPNPC_API_VERSION})
51 set(MINIUPNP_FOUND true)
52 set(MINIUPNPC_VERSION_1_7_OR_HIGHER true)
53 endif()
54 endif()
55
56 ENDIF()
57
58 mark_as_advanced(MINIUPNP_INCLUDE_DIR MINIUPNP_LIBRARY MINIUPNP_STATIC_LIBRARY)
59 # --------------------------------- FindMiniupnpc End ---------------------------------