Blob Blame Raw
From d86ff9a4e8ee4d7df53f26a686a0e4defcd749be Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Date: Wed, 14 May 2014 16:39:13 +0400
Subject: [PATCH 4/6] unbundle irrlicht

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
---
 CMakeLists.txt           |  8 ++---
 cmake/FindIrrlicht.cmake | 94 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 98 insertions(+), 4 deletions(-)
 create mode 100644 cmake/FindIrrlicht.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index bd525f8..861b76c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -49,8 +49,8 @@ find_package(ENet REQUIRED)
 include_directories(${ENet_INCLUDE_DIRS})
 
 # Build the irrlicht library
-add_subdirectory("${PROJECT_SOURCE_DIR}/lib/irrlicht")
-include_directories("${PROJECT_SOURCE_DIR}/lib/irrlicht/include")
+find_package(Irrlicht REQUIRED)
+include_directories(${IRRLICHT_INCLUDE_DIR})
 
 # Build the Wiiuse library
 # Note: wiiuse MUST be declared after irrlicht, since otherwise
@@ -228,10 +228,10 @@ endif()
 target_link_libraries(supertuxkart
     ${BULLET_LIBRARIES}
     ${ENet_LIBRARIES}
-    stkirrlicht
+    ${IRRLICHT_LIBRARIES}
+    IrrXML
     ${CURL_LIBRARIES}
     ${OGGVORBIS_LIBRARIES}
-    ${IRRLICHT_XF86VM_LIBRARY}
     ${OPENAL_LIBRARY}
     ${OPENGL_LIBRARIES})
 
diff --git a/cmake/FindIrrlicht.cmake b/cmake/FindIrrlicht.cmake
new file mode 100644
index 0000000..8c94ec2
--- /dev/null
+++ b/cmake/FindIrrlicht.cmake
@@ -0,0 +1,94 @@
+#FindIrrlicht.cmake
+
+set(IRRLICHT_SOURCE_DIR "" CACHE PATH "Path to irrlicht source directory (optional)")
+
+if( UNIX )
+	# Unix
+else( UNIX )
+	# Windows
+endif( UNIX )
+
+# Find include directory
+
+if(NOT IRRLICHT_SOURCE_DIR STREQUAL "")
+	set(IRRLICHT_SOURCE_DIR_INCLUDE
+		"${IRRLICHT_SOURCE_DIR}/include"
+	)
+
+	set(IRRLICHT_LIBRARY_NAMES libIrrlicht.a Irrlicht Irrlicht.lib)
+
+	if(WIN32)
+		if(MSVC)
+			set(IRRLICHT_SOURCE_DIR_LIBS "${IRRLICHT_SOURCE_DIR}/lib/Win32-visualstudio")
+			set(IRRLICHT_LIBRARY_NAMES Irrlicht.lib)
+		else()
+			set(IRRLICHT_SOURCE_DIR_LIBS "${IRRLICHT_SOURCE_DIR}/lib/Win32-gcc")
+			set(IRRLICHT_LIBRARY_NAMES libIrrlicht.a libIrrlicht.dll.a)
+		endif()
+	else()
+		set(IRRLICHT_SOURCE_DIR_LIBS "${IRRLICHT_SOURCE_DIR}/lib/Linux")
+		set(IRRLICHT_LIBRARY_NAMES libIrrlicht.a)
+	endif()
+
+	FIND_PATH(IRRLICHT_INCLUDE_DIR NAMES irrlicht.h
+		PATHS
+		${IRRLICHT_SOURCE_DIR_INCLUDE}
+		NO_DEFAULT_PATH
+	)
+
+	FIND_LIBRARY(IRRLICHT_LIBRARY NAMES ${IRRLICHT_LIBRARY_NAMES}
+		PATHS
+		${IRRLICHT_SOURCE_DIR_LIBS}
+		NO_DEFAULT_PATH
+	)
+
+else()
+
+	FIND_PATH(IRRLICHT_INCLUDE_DIR NAMES irrlicht.h
+		PATHS
+		/usr/local/include/irrlicht
+		/usr/include/irrlicht
+	)
+
+	FIND_LIBRARY(IRRLICHT_LIBRARY NAMES libIrrlicht.so Irrlicht
+		PATHS
+		/usr/local/lib
+		/usr/lib
+    /usr/lib64
+	)
+endif()
+
+MESSAGE(STATUS "IRRLICHT_SOURCE_DIR = ${IRRLICHT_SOURCE_DIR}")
+MESSAGE(STATUS "IRRLICHT_INCLUDE_DIR = ${IRRLICHT_INCLUDE_DIR}")
+MESSAGE(STATUS "IRRLICHT_LIBRARY = ${IRRLICHT_LIBRARY}")
+
+# On windows, find the dll for installation
+if(WIN32)
+	if(MSVC)
+		FIND_FILE(IRRLICHT_DLL NAMES Irrlicht.dll
+			PATHS
+			"${IRRLICHT_SOURCE_DIR}/bin/Win32-VisualStudio"
+			DOC "Path of the Irrlicht dll (for installation)"
+		)
+	else()
+		FIND_FILE(IRRLICHT_DLL NAMES Irrlicht.dll
+			PATHS
+			"${IRRLICHT_SOURCE_DIR}/bin/Win32-gcc"
+			DOC "Path of the Irrlicht dll (for installation)"
+		)
+	endif()
+	MESSAGE(STATUS "IRRLICHT_DLL = ${IRRLICHT_DLL}")
+endif(WIN32)
+
+# handle the QUIETLY and REQUIRED arguments and set IRRLICHT_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(IRRLICHT DEFAULT_MSG IRRLICHT_LIBRARY IRRLICHT_INCLUDE_DIR)
+
+IF(IRRLICHT_FOUND)
+  SET(IRRLICHT_LIBRARIES ${IRRLICHT_LIBRARY})
+ELSE(IRRLICHT_FOUND)
+  SET(IRRLICHT_LIBRARIES)
+ENDIF(IRRLICHT_FOUND)
+
+MARK_AS_ADVANCED(IRRLICHT_LIBRARY IRRLICHT_INCLUDE_DIR IRRLICHT_DLL)
-- 
1.9.3