| [1505] | 1 | # - Try to find enet | 
|---|
|  | 2 | # Once done this will define | 
|---|
|  | 3 | # | 
|---|
|  | 4 | #  ENET_FOUND - system has enet | 
|---|
| [2710] | 5 | #  ENet_INCLUDE_DIR - the enet include directory | 
|---|
|  | 6 | #  ENet_LIBRARY - the library needed to link against enet | 
|---|
| [1505] | 7 | # | 
|---|
| [2710] | 8 | # $ENETDIR is an environment variable used for finding enet. | 
|---|
|  | 9 | # | 
|---|
| [1505] | 10 | #  Borrowed from The Mana World | 
|---|
|  | 11 | #  http://themanaworld.org/ | 
|---|
|  | 12 | # | 
|---|
| [1776] | 13 | # Several changes and additions by Fabian 'x3n' Landau | 
|---|
| [2710] | 14 | # Lots of simplifications by Adrian Friedli and Reto Grieder | 
|---|
|  | 15 | # Version checking by Reto Grieder | 
|---|
| [1776] | 16 | #                 > www.orxonox.net < | 
|---|
| [1505] | 17 |  | 
|---|
| [2710] | 18 | INCLUDE(FindPackageHandleAdvancedArgs) | 
|---|
|  | 19 | INCLUDE(HandleLibraryTypes) | 
|---|
| [1505] | 20 |  | 
|---|
| [2710] | 21 | FIND_PATH(ENET_INCLUDE_DIR enet/enet.h | 
|---|
|  | 22 | PATHS $ENV{ENETDIR} | 
|---|
|  | 23 | PATH_SUFFIXES include | 
|---|
|  | 24 | ) | 
|---|
|  | 25 | FIND_LIBRARY(ENET_LIBRARY_OPTIMIZED | 
|---|
|  | 26 | NAMES enet | 
|---|
|  | 27 | PATHS $ENV{ENETDIR} | 
|---|
|  | 28 | PATH_SUFFIXES lib | 
|---|
|  | 29 | ) | 
|---|
|  | 30 | FIND_LIBRARY(ENET_LIBRARY_DEBUG | 
|---|
|  | 31 | NAMES enetd enet_d enet_D | 
|---|
|  | 32 | PATHS $ENV{ENETDIR} | 
|---|
|  | 33 | PATH_SUFFIXES lib | 
|---|
|  | 34 | ) | 
|---|
| [1505] | 35 |  | 
|---|
| [2710] | 36 | # Try to determine the version. Note that enet only stores the major | 
|---|
|  | 37 | # version in the header file. So we check for existing functions. | 
|---|
|  | 38 | # Hence the this script only distinguishes between 1.0, 1.1 and 1.2 | 
|---|
|  | 39 | FILE(STRINGS ${ENET_INCLUDE_DIR}/enet/enet.h _enet_header REGEX "ENET_") | 
|---|
|  | 40 | IF(_enet_header MATCHES "ENET_VERSION[ \t]*=[ \t]*1") | 
|---|
|  | 41 | IF(_enet_header MATCHES "enet_socket_set_option") | 
|---|
|  | 42 | SET(ENET_VERSION 1.2) | 
|---|
|  | 43 | ELSEIF(_enet_header MATCHES "enet_peer_disconnect_later") | 
|---|
|  | 44 | SET(ENET_VERSION 1.1) | 
|---|
|  | 45 | ELSE() | 
|---|
|  | 46 | SET(ENET_VERSION 1.0) | 
|---|
|  | 47 | ENDIF() | 
|---|
|  | 48 | ELSE() | 
|---|
|  | 49 | SET(ENET_VERSION 0) # Script doesn't support versions below 1.0 | 
|---|
|  | 50 | ENDIF() | 
|---|
| [1505] | 51 |  | 
|---|
| [2710] | 52 | # Handle the REQUIRED argument and set ENET_FOUND | 
|---|
|  | 53 | # Also check the the version requirements | 
|---|
|  | 54 | FIND_PACKAGE_HANDLE_ADVANCED_ARGS(ENet DEFAULT_MSG ${ENET_VERSION} | 
|---|
|  | 55 | ENET_LIBRARY_OPTIMIZED | 
|---|
|  | 56 | ENET_INCLUDE_DIR | 
|---|
|  | 57 | ) | 
|---|
| [1776] | 58 |  | 
|---|
| [2710] | 59 | # Collect optimized and debug libraries | 
|---|
|  | 60 | IF(NOT LINK_ENET_DYNAMIC AND WIN32) | 
|---|
|  | 61 | # ENet is linked statically, hence we need to add some windows dependencies | 
|---|
|  | 62 | HANDLE_LIBRARY_TYPES(ENET ws2_32 winmm) | 
|---|
|  | 63 | ELSE() | 
|---|
|  | 64 | HANDLE_LIBRARY_TYPES(ENET) | 
|---|
|  | 65 | ENDIF() | 
|---|
| [1776] | 66 |  | 
|---|
| [2710] | 67 | MARK_AS_ADVANCED( | 
|---|
|  | 68 | ENET_INCLUDE_DIR | 
|---|
|  | 69 | ENET_LIBRARY_OPTIMIZED | 
|---|
|  | 70 | ENET_LIBRARY_DEBUG | 
|---|
|  | 71 | ) | 
|---|