Blob Blame Raw
From f71003a718a75843a4936702ec3c2bd90e804e3f Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Date: Wed, 14 May 2014 16:28:29 +0400
Subject: [PATCH 3/6] unbundle enet

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
---
 CMakeLists.txt       |  6 +++---
 cmake/FindENet.cmake | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 3 deletions(-)
 create mode 100644 cmake/FindENet.cmake

diff --git a/cmake/FindENet.cmake b/cmake/FindENet.cmake
new file mode 100644
index 0000000..b6c146c
--- /dev/null
+++ b/cmake/FindENet.cmake
@@ -0,0 +1,49 @@
+# - Try to find enet
+# Once done this will define
+#
+#  ENET_FOUND - system has enet
+#  ENet_INCLUDE_DIRS - the enet include directory
+#  ENet_LIBRARIES - the libraries needed to use enet
+#
+# $ENETDIR is an environment variable used for finding enet.
+#
+#  Borrowed from The Mana World
+#  http://themanaworld.org/
+#
+# Several changes and additions by Fabian 'x3n' Landau
+# Lots of simplifications by Adrian Friedli
+#                 > www.orxonox.net <
+
+FIND_PATH(ENet_INCLUDE_DIRS enet/enet.h
+    PATHS
+    $ENV{ENETDIR}
+    /usr/local
+    /usr
+    PATH_SUFFIXES include
+    )
+
+FIND_LIBRARY(ENet_LIBRARY
+    NAMES enet
+    PATHS
+    $ENV{ENETDIR}
+    /usr/local
+    /usr
+    PATH_SUFFIXES lib
+    )
+
+# handle the QUIETLY and REQUIRED arguments and set ENET_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(ENet DEFAULT_MSG ENet_LIBRARY ENet_INCLUDE_DIRS)
+
+IF (ENET_FOUND)
+    IF(WIN32)
+        SET(WINDOWS_ENET_DEPENDENCIES "ws2_32;winmm")
+        SET(ENet_LIBRARIES ${ENet_LIBRARY} ${WINDOWS_ENET_DEPENDENCIES})
+    ELSE(WIN32)
+        SET(ENet_LIBRARIES ${ENet_LIBRARY})
+    ENDIF(WIN32)
+ENDIF (ENET_FOUND)
+
+MARK_AS_ADVANCED(ENet_LIBRARY ENet_LIBRARIES ENet_INCLUDE_DIRS)
+
-- 
1.9.3

--- a/CMakeLists.txt~	2014-10-15 05:18:41.000000000 -0500
+++ b/CMakeLists.txt	2014-10-15 05:23:37.792191084 -0500
@@ -225,7 +226,7 @@
     bulletdynamics
     bulletcollision
     bulletmath
-    enet
+    ${ENet_LIBRARIES}
     stkirrlicht
     ${CURL_LIBRARIES}
     ${OGGVORBIS_LIBRARIES}
--- a/CMakeLists.txt~	2014-10-15 05:40:11.000000000 -0500
+++ b/CMakeLists.txt	2014-10-15 05:40:51.372219546 -0500
@@ -41,8 +41,8 @@
 include_directories("${PROJECT_SOURCE_DIR}/lib/bullet/src")
 
 # Build the ENet UDP network library
-add_subdirectory("${PROJECT_SOURCE_DIR}/lib/enet")
-include_directories("${PROJECT_SOURCE_DIR}/lib/enet/include")
+find_package(ENet REQUIRED)
+include_directories(${ENet_INCLUDE_DIRS})
 
 # Build the irrlicht library
 add_subdirectory("${PROJECT_SOURCE_DIR}/lib/irrlicht")