Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/buildsystem2/cmake/FindENet.cmake @ 2616

Last change on this file since 2616 was 2616, checked in by rgrieder, 15 years ago
  • Split FindOggVorbis.cmake in two. Having them in one file doesn't make sense, we can group it somewhere else.
  • Updated all find scripts
  • Removed all standard paths (like /usr /usr/local, etc.) because they're already searched by CMake anyway
  • Several workarounds for certain libraries when using the find script in the CMake module path.
  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1# - Try to find enet
2# Once done this will define
3#
4#  ENET_FOUND - system has enet
5#  ENet_INCLUDE_DIR - the enet include directory
6#  ENet_LIBRARIES - the libraries needed to use enet
7#
8# $ENETDIR is an environment variable used for finding enet.
9#
10#  Borrowed from The Mana World
11#  http://themanaworld.org/
12#
13# Several changes and additions by Fabian 'x3n' Landau
14# Lots of simplifications by Adrian Friedli
15#                 > www.orxonox.net <
16
17INCLUDE(FindPackageHandleAdvancedArgs)
18INCLUDE(HandleLibraryTypes)
19
20FIND_PATH(ENET_INCLUDE_DIR enet/enet.h
21  PATHS $ENV{ENETDIR}
22  PATH_SUFFIXES include
23)
24FIND_LIBRARY(ENET_LIBRARY_OPTIMIZED
25  NAMES enet
26  PATHS $ENV{ENETDIR}
27  PATH_SUFFIXES lib
28)
29FIND_LIBRARY(ENET_LIBRARY_DEBUG
30  NAMES enetd enet_d
31  PATHS $ENV{ENETDIR}
32  PATH_SUFFIXES lib
33)
34
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
38FILE(STRINGS ${ENET_INCLUDE_DIR}/enet/enet.h _enet_header REGEX "ENET_")
39IF(_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)
44  ELSE(_enet_header MATCHES "enet_socket_set_option")
45    SET(ENET_VERSION 1.0)
46  ENDIF(_enet_header MATCHES "enet_socket_set_option")
47ELSE(_enet_header MATCHES "ENET_VERSION[ \t]*=[ \t]*1")
48  SET(ENET_VERSION 0) # Script doesn't support versions below 1.0
49ENDIF(_enet_header MATCHES "ENET_VERSION[ \t]*=[ \t]*1")
50
51# Handle the REQUIRED argument and set ENET_FOUND
52# Also check the the version requirements
53FIND_PACKAGE_HANDLE_ADVANCED_ARGS(ENet DEFAULT_MSG ${ENET_VERSION}
54  ENET_INCLUDE_DIR
55  ENET_LIBRARY_OPTIMIZED
56)
57
58# Collect optimized and debug libraries
59IF(NOT LINK_ENET_DYNAMIC AND WIN32)
60  # ENet is linked statically, hence we need to add some windows dependencies
61  HANDLE_LIBRARY_TYPES(ENET ws2_32 winmm)
62ELSE(NOT LINK_ENET_DYNAMIC AND WIN32)
63  HANDLE_LIBRARY_TYPES(ENET)
64ENDIF(NOT LINK_ENET_DYNAMIC AND WIN32)
65
66MARK_AS_ADVANCED(
67  ENET_INCLUDE_DIR
68  ENET_LIBRARY_OPTIMIZED
69  ENET_LIBRARY_DEBUG
70)
Note: See TracBrowser for help on using the repository browser.