Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 2624 was 2624, checked in by rgrieder, 15 years ago

Replaced most of the ELSE(…) and ENDIF(…) with ELSE() and ENDIF(). Kept the shorter and the spreaded ones for better clarity since that's what it originally was thought for. But I can really pollute the code when having long conditions and lots of IFs.

  • Property svn:eol-style set to native
File size: 1.9 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()
45    SET(ENET_VERSION 1.0)
46  ENDIF()
47ELSE()
48  SET(ENET_VERSION 0) # Script doesn't support versions below 1.0
49ENDIF()
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()
63  HANDLE_LIBRARY_TYPES(ENET)
64ENDIF()
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.