Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/toonshader/cmake/FindENet.cmake @ 6733

Last change on this file since 6733 was 2710, checked in by rgrieder, 16 years ago

Merged buildsystem3 containing buildsystem2 containing Adi's buildsystem branch back to the trunk.
Please update the media directory if you were not using buildsystem3 before.

  • Property svn:eol-style set to native
File size: 2.0 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_LIBRARY - the library needed to link against 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 and Reto Grieder
15# Version checking by Reto Grieder
16#                 > www.orxonox.net <
17
18INCLUDE(FindPackageHandleAdvancedArgs)
19INCLUDE(HandleLibraryTypes)
20
21FIND_PATH(ENET_INCLUDE_DIR enet/enet.h
22  PATHS $ENV{ENETDIR}
23  PATH_SUFFIXES include
24)
25FIND_LIBRARY(ENET_LIBRARY_OPTIMIZED
26  NAMES enet
27  PATHS $ENV{ENETDIR}
28  PATH_SUFFIXES lib
29)
30FIND_LIBRARY(ENET_LIBRARY_DEBUG
31  NAMES enetd enet_d enet_D
32  PATHS $ENV{ENETDIR}
33  PATH_SUFFIXES lib
34)
35
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
39FILE(STRINGS ${ENET_INCLUDE_DIR}/enet/enet.h _enet_header REGEX "ENET_")
40IF(_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()
48ELSE()
49  SET(ENET_VERSION 0) # Script doesn't support versions below 1.0
50ENDIF()
51
52# Handle the REQUIRED argument and set ENET_FOUND
53# Also check the the version requirements
54FIND_PACKAGE_HANDLE_ADVANCED_ARGS(ENet DEFAULT_MSG ${ENET_VERSION}
55  ENET_LIBRARY_OPTIMIZED
56  ENET_INCLUDE_DIR
57)
58
59# Collect optimized and debug libraries
60IF(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)
63ELSE()
64  HANDLE_LIBRARY_TYPES(ENET)
65ENDIF()
66
67MARK_AS_ADVANCED(
68  ENET_INCLUDE_DIR
69  ENET_LIBRARY_OPTIMIZED
70  ENET_LIBRARY_DEBUG
71)
Note: See TracBrowser for help on using the repository browser.