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