Changeset 2664 for code/branches/buildsystem3/cmake/FindENet.cmake
- Timestamp:
- Feb 14, 2009, 10:53:45 PM (16 years ago)
- Location:
- code/branches/buildsystem3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/buildsystem3
- Property svn:ignore deleted
- Property svn:mergeinfo changed
-
code/branches/buildsystem3/cmake/FindENet.cmake
r1872 r2664 3 3 # 4 4 # ENET_FOUND - system has enet 5 # ENET_INCLUDE_DIR - the enet include directory 6 # ENET_LIBRARIES - the libraries needed to use enet 7 # ENET_DEFINITIONS - Compiler switches required for using 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. 8 9 # 9 10 # Borrowed from The Mana World … … 11 12 # 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 13 16 # > www.orxonox.net < 14 17 15 IF (ENet_INCLUDE_DIR AND ENet_LIBRARY) 16 SET(ENet_FIND_QUIETLY TRUE) 17 ENDIF (ENet_INCLUDE_DIR AND ENet_LIBRARY) 18 INCLUDE(FindPackageHandleAdvancedArgs) 19 INCLUDE(HandleLibraryTypes) 18 20 19 FIND_PATH(ENet_INCLUDE_DIR enet/enet.h 20 /usr/include 21 /usr/local/include 22 /usr/pack/enet-2007-sd/include 23 ../libs/enet-1.1/include 24 ${DEPENDENCY_DIR}/enet-1.2/include 25 ) 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 ) 26 35 27 FIND_LIBRARY(ENet_LIBRARY 28 NAMES enet 29 PATHS /usr/lib /usr/local/lib /usr/pack/enet-2007-sd/i686-debian-linux3.1/lib/ 30 ../libs/enet-1.1 31 ${DEPENDENCY_DIR}/enet-1.2/lib 32 ) 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() 33 51 34 SET(ENET_FOUND FALSE) 35 IF (ENet_INCLUDE_DIR AND ENet_LIBRARY) 36 SET(ENET_FOUND TRUE) 37 SET(ENET_INCLUDE_DIR ${ENet_INCLUDE_DIR}) 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 ) 38 58 39 IF(WIN32) 40 SET(WINDOWS_ENET_DEPENDENCIES "ws2_32;winmm") 41 SET(ENet_LIBRARY ${ENet_LIBRARY} ${WINDOWS_ENET_DEPENDENCIES}) 42 ENDIF(WIN32) 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() 43 66 44 SET(ENET_LIBRARIES ${ENet_LIBRARY}) 45 ENDIF (ENet_INCLUDE_DIR AND ENet_LIBRARY) 46 47 IF (ENET_FOUND) 48 IF (NOT ENet_FIND_QUIETLY) 49 MESSAGE(STATUS "ENet was found.") 50 IF (VERBOSE_FIND) 51 MESSAGE (STATUS " include path: ${ENet_INCLUDE_DIR}") 52 MESSAGE (STATUS " library path: ${ENet_LIBRARY}") 53 MESSAGE (STATUS " libraries: enet") 54 ENDIF (VERBOSE_FIND) 55 ENDIF (NOT ENet_FIND_QUIETLY) 56 ELSE (ENET_FOUND) 57 IF (NOT ENet_INCLUDE_DIR) 58 MESSAGE(SEND_ERROR "ENet include path was not found.") 59 ENDIF (NOT ENet_INCLUDE_DIR) 60 IF (NOT ENet_LIBRARY) 61 MESSAGE(SEND_ERROR "ENet library was not found.") 62 ENDIF (NOT ENet_LIBRARY) 63 ENDIF (ENET_FOUND) 64 65 MARK_AS_ADVANCED(ENet_INCLUDE_DIR ENet_LIBRARY) 67 MARK_AS_ADVANCED( 68 ENET_INCLUDE_DIR 69 ENET_LIBRARY_OPTIMIZED 70 ENET_LIBRARY_DEBUG 71 )
Note: See TracChangeset
for help on using the changeset viewer.