2791c28
From f71003a718a75843a4936702ec3c2bd90e804e3f Mon Sep 17 00:00:00 2001
2791c28
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2791c28
Date: Wed, 14 May 2014 16:28:29 +0400
bd15c66
Subject: [PATCH 3/6] unbundle enet
2791c28
2791c28
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2791c28
---
2791c28
 CMakeLists.txt       |  6 +++---
2791c28
 cmake/FindENet.cmake | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
2791c28
 2 files changed, 52 insertions(+), 3 deletions(-)
2791c28
 create mode 100644 cmake/FindENet.cmake
2791c28
2791c28
diff --git a/cmake/FindENet.cmake b/cmake/FindENet.cmake
2791c28
new file mode 100644
2791c28
index 0000000..b6c146c
2791c28
--- /dev/null
2791c28
+++ b/cmake/FindENet.cmake
2791c28
@@ -0,0 +1,49 @@
2791c28
+# - Try to find enet
2791c28
+# Once done this will define
2791c28
+#
2791c28
+#  ENET_FOUND - system has enet
2791c28
+#  ENet_INCLUDE_DIRS - the enet include directory
2791c28
+#  ENet_LIBRARIES - the libraries needed to use enet
2791c28
+#
2791c28
+# $ENETDIR is an environment variable used for finding enet.
2791c28
+#
2791c28
+#  Borrowed from The Mana World
2791c28
+#  http://themanaworld.org/
2791c28
+#
2791c28
+# Several changes and additions by Fabian 'x3n' Landau
2791c28
+# Lots of simplifications by Adrian Friedli
2791c28
+#                 > www.orxonox.net <
2791c28
+
2791c28
+FIND_PATH(ENet_INCLUDE_DIRS enet/enet.h
2791c28
+    PATHS
2791c28
+    $ENV{ENETDIR}
2791c28
+    /usr/local
2791c28
+    /usr
2791c28
+    PATH_SUFFIXES include
2791c28
+    )
2791c28
+
2791c28
+FIND_LIBRARY(ENet_LIBRARY
2791c28
+    NAMES enet
2791c28
+    PATHS
2791c28
+    $ENV{ENETDIR}
2791c28
+    /usr/local
2791c28
+    /usr
2791c28
+    PATH_SUFFIXES lib
2791c28
+    )
2791c28
+
2791c28
+# handle the QUIETLY and REQUIRED arguments and set ENET_FOUND to TRUE if
2791c28
+# all listed variables are TRUE
2791c28
+INCLUDE(FindPackageHandleStandardArgs)
2791c28
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(ENet DEFAULT_MSG ENet_LIBRARY ENet_INCLUDE_DIRS)
2791c28
+
2791c28
+IF (ENET_FOUND)
2791c28
+    IF(WIN32)
2791c28
+        SET(WINDOWS_ENET_DEPENDENCIES "ws2_32;winmm")
2791c28
+        SET(ENet_LIBRARIES ${ENet_LIBRARY} ${WINDOWS_ENET_DEPENDENCIES})
2791c28
+    ELSE(WIN32)
2791c28
+        SET(ENet_LIBRARIES ${ENet_LIBRARY})
2791c28
+    ENDIF(WIN32)
2791c28
+ENDIF (ENET_FOUND)
2791c28
+
2791c28
+MARK_AS_ADVANCED(ENet_LIBRARY ENet_LIBRARIES ENet_INCLUDE_DIRS)
2791c28
+
2791c28
-- 
bd15c66
1.9.3
2791c28
cd00181
--- a/CMakeLists.txt~	2014-10-15 05:18:41.000000000 -0500
cd00181
+++ b/CMakeLists.txt	2014-10-15 05:23:37.792191084 -0500
cd00181
@@ -225,7 +226,7 @@
cd00181
     bulletdynamics
cd00181
     bulletcollision
cd00181
     bulletmath
cd00181
-    enet
cd00181
+    ${ENet_LIBRARIES}
cd00181
     stkirrlicht
cd00181
     ${CURL_LIBRARIES}
cd00181
     ${OGGVORBIS_LIBRARIES}
cd00181
--- a/CMakeLists.txt~	2014-10-15 05:40:11.000000000 -0500
cd00181
+++ b/CMakeLists.txt	2014-10-15 05:40:51.372219546 -0500
cd00181
@@ -41,8 +41,8 @@
cd00181
 include_directories("${PROJECT_SOURCE_DIR}/lib/bullet/src")
cd00181
 
cd00181
 # Build the ENet UDP network library
cd00181
-add_subdirectory("${PROJECT_SOURCE_DIR}/lib/enet")
cd00181
-include_directories("${PROJECT_SOURCE_DIR}/lib/enet/include")
cd00181
+find_package(ENet REQUIRED)
cd00181
+include_directories(${ENet_INCLUDE_DIRS})
cd00181
 
cd00181
 # Build the irrlicht library
cd00181
 add_subdirectory("${PROJECT_SOURCE_DIR}/lib/irrlicht")