Index: code/branches/buildsystem/cmake/FindLua.cmake
===================================================================
--- code/branches/buildsystem/cmake/FindLua.cmake	(revision 1883)
+++ 	(revision )
@@ -1,101 +1,0 @@
-#  Find Lua header and library files
-#
-#  When called, this script tries to define:
-#  Lua_INCLUDE_DIR    Header files directory
-#  Lua_LIBRARIES      library files (or file when using lua 5.1)
-#  Lua_FOUND          defined (true) if lua was found
-#  Lua_VERSION        either 5.1 or 5.0 or undefined
-#
-#  authors: Benjamin Knecht, Reto Grieder
-#
-# Several changes and additions by Fabian 'x3n' Landau
-#                 > www.orxonox.net <
-
-IF (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
-
-  # Already in cache, be silent
-  SET(Lua_FOUND TRUE)
-  SET(Lua_FIND_QUIETLY TRUE) 
-#  MESSAGE(STATUS "Lua was found.")
-
-ELSE (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
-
-  FIND_PATH(Lua_INCLUDE_DIR_51 lua.h
-    /usr/include/lua5.1
-    /usr/local/include/lua5.1
-    ../libs/lua-5.1.3/include)
-
-  FIND_PATH(Lua_INCLUDE_DIR_50 lua.h
-    /usr/include/lua50
-    /usr/local/include/lua50
-    /usr/pack/lua-5.0.3-sd/include)
-
-  FIND_LIBRARY(Lua_LIBRARY_51 NAMES lua5.1 lua PATHS
-    /usr/lib
-    /usr/local/lib
-    ../libs/lua-5.1.3/lib)
-
-  FIND_LIBRARY(Lua_LIBRARY_1_50 NAMES lua50 lua PATHS
-    /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib #tardis
-    /usr/lib
-    /usr/local/lib)
-
-  FIND_LIBRARY(Lua_LIBRARY_2_50 NAMES lualib50 lualib PATHS
-    /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib #tardis
-    /usr/lib
-    /usr/local/lib)
-
-
-  IF (Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
-
-    # Found newer lua 5.1 libs
-    SET(Lua_FOUND TRUE)
-    SET(Lua_VERSION "5.1" CACHE STRING "")
-    SET(Lua_INCLUDE_DIR ${Lua_INCLUDE_DIR_51} CACHE PATH "")
-    SET(Lua_LIBRARIES ${Lua_LIBRARY_51} CACHE FILEPATH "")
-    SET(Lua_LIBRARY_NAMES "lua5.1 lua")
-
-  ELSEIF(Lua_INCLUDE_DIR_50 AND Lua_LIBRARY_1_50 AND Lua_LIBRARY_2_50)
-
-    # Found older lua 5.0 libs
-    SET(Lua_FOUND TRUE)
-    SET(Lua_VERSION "5.0" CACHE STRING "")
-    SET(Lua_INCLUDE_DIR ${Lua_INCLUDE_DIR_50} CACHE PATH "")
-    SET(Lua_LIBRARIES ${Lua_LIBRARY_1_50} ${Lua_LIBRARY_2_50} CACHE FILEPATH "")
-    SET(Lua_LIBRARY_NAMES "lua50 lua, lualib50 lualib")
-
-  ENDIF (Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
-	
-
-  IF (Lua_FOUND)
-    MESSAGE(STATUS "Lua was found.")
-    IF (VERBOSE_FIND)
-      MESSAGE (STATUS "  include path: ${Lua_INCLUDE_DIR}")
-      MESSAGE (STATUS "  library path: ${Lua_LIBRARIES}")
-      MESSAGE (STATUS "  libraries:    ${Lua_LIBRARY_NAMES}")
-    ENDIF (VERBOSE_FIND)
-  ELSE (Lua_FOUND)
-    IF (Lua_INCLUDE_DIR_51 AND NOT Lua_LIBRARY_51)
-      MESSAGE(SEND_ERROR "Lua 5.1 library was not found")
-    ENDIF (Lua_INCLUDE_DIR_51 AND NOT Lua_LIBRARY_51)
-    IF (NOT Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
-      MESSAGE(SEND_ERROR "Lua 5.1 include path was not found")
-    ENDIF (NOT Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
-
-    IF (Lua_INCLUDE_DIR_50)
-      IF (NOT Lua_LIBRARY_1_50)
-       MESSAGE(SEND_ERROR "Lua 5.0 library "lua" was not found")
-      ENDIF (NOT Lua_LIBRARY_1_50)
-      IF (NOT Lua_LIBRARY_2_50)
-       MESSAGE(SEND_ERROR "Lua 5.0 library "lualib" was not found")
-      ENDIF (NOT Lua_LIBRARY_2_50)
-    ENDIF (Lua_INCLUDE_DIR_50)
-    IF (NOT Lua_INCLUDE_DIR_50 AND Lua_LIBRARY_1_50 AND Lua_LIBRARY_2_50)
-      MESSAGE(SEND_ERROR "Lua 5.0 include path was not found")
-    ENDIF (NOT Lua_INCLUDE_DIR_50 AND Lua_LIBRARY_1_50 AND Lua_LIBRARY_2_50)
-
-    MESSAGE(SEND_ERROR "Lua was not found.")
-  ENDIF (Lua_FOUND)
-
-ENDIF (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
-
Index: code/branches/buildsystem/cmake/FindLua50.cmake
===================================================================
--- code/branches/buildsystem/cmake/FindLua50.cmake	(revision 1975)
+++ code/branches/buildsystem/cmake/FindLua50.cmake	(revision 1975)
@@ -0,0 +1,101 @@
+# Locate Lua library
+# This module defines
+#  LUA_LIBRARIES, both lua and lualib
+#  LUA_FOUND, if false, do not try to link to Lua 
+#  LUA_INCLUDE_DIR, where to find lua.h and lualib.h (and probably lauxlib.h)
+#
+# Note that the expected include convention is
+#  #include "lua.h"
+# and not
+#  #include <lua/lua.h>
+# This is because, the lua location is not standardized and may exist
+# in locations other than lua/
+
+
+FIND_PATH(LUA_INCLUDE_DIR lua.h
+  PATHS
+  $ENV{LUA_DIR}
+  NO_DEFAULT_PATH
+  PATH_SUFFIXES include/lua50 include/lua5.0 include/lua5 include/lua include
+)
+
+FIND_PATH(LUA_INCLUDE_DIR lua.h
+  PATHS
+  ~/Library/Frameworks
+  /Library/Frameworks
+  /usr/local
+  /usr
+  /sw # Fink
+  /opt/local # DarwinPorts
+  /opt/csw # Blastwave
+  /opt
+  PATH_SUFFIXES include/lua50 include/lua5.0 include/lua5 include/lua include
+)
+
+FIND_LIBRARY(LUA_LIBRARY_lua 
+  NAMES lua50 lua5.0 lua5 lua
+  PATHS
+  $ENV{LUA_DIR}
+  NO_DEFAULT_PATH
+    PATH_SUFFIXES lib64 lib
+)
+
+FIND_LIBRARY(LUA_LIBRARY_lua
+  NAMES lua50 lua5.0 lua5 lua
+  PATHS
+  ~/Library/Frameworks
+  /Library/Frameworks
+  /usr/local
+  /usr
+  /sw
+  /opt/local
+  /opt/csw
+  /opt
+    PATH_SUFFIXES lib64 lib
+)
+
+# In an OS X framework, lualib is usually included as part of the framework
+# (like GLU in OpenGL.framework)
+IF(${LUA_LIBRARY_lua} MATCHES "framework")
+  SET( LUA_LIBRARIES "${LUA_LIBRARY_lua}" CACHE STRING "Lua framework")
+ELSE(${LUA_LIBRARY_lua} MATCHES "framework")
+  FIND_LIBRARY(LUA_LIBRARY_lualib 
+    NAMES lualib50 lualib5.0 lualib5 lualib
+    PATHS
+    $ENV{LUALIB_DIR}
+    $ENV{LUA_DIR}
+    NO_DEFAULT_PATH
+    PATH_SUFFIXES lib64 lib
+  )
+
+  FIND_LIBRARY(LUA_LIBRARY_lualib 
+    NAMES lualib50 lualib5.0 lualib5 lualib
+    PATHS
+    /usr/local
+    /usr
+    /sw
+    /opt/local
+    /opt/csw
+    /opt
+    PATH_SUFFIXES lib64 lib
+  )
+  IF(LUA_LIBRARY_lualib AND LUA_LIBRARY_lua)
+    # include the math library for Unix
+    IF(UNIX AND NOT APPLE)
+      FIND_LIBRARY(MATH_LIBRARY_FOR_LUA m)
+      SET( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua};${MATH_LIBRARY_FOR_LUA}" CACHE STRING "This is the concatentation of lua and lualib libraries")
+    # For Windows and Mac, don't need to explicitly include the math library
+    ELSE(UNIX AND NOT APPLE)
+      SET( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua}" CACHE STRING "This is the concatentation of lua and lualib libraries")
+    ENDIF(UNIX AND NOT APPLE)
+  ENDIF(LUA_LIBRARY_lualib AND LUA_LIBRARY_lua)
+ENDIF(${LUA_LIBRARY_lua} MATCHES "framework")
+
+
+INCLUDE(FindPackageHandleStandardArgs)
+# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if 
+# all listed variables are TRUE
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua50  DEFAULT_MSG  LUA_LIBRARIES LUA_INCLUDE_DIR)
+
+MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES)
+
Index: code/branches/buildsystem/cmake/FindLua51.cmake
===================================================================
--- code/branches/buildsystem/cmake/FindLua51.cmake	(revision 1975)
+++ code/branches/buildsystem/cmake/FindLua51.cmake	(revision 1975)
@@ -0,0 +1,74 @@
+# Locate Lua library
+# This module defines
+#  LUA_LIBRARIES
+#  LUA_FOUND, if false, do not try to link to Lua 
+#  LUA_INCLUDE_DIR, where to find lua.h 
+#
+# Note that the expected include convention is
+#  #include "lua.h"
+# and not
+#  #include <lua/lua.h>
+# This is because, the lua location is not standardized and may exist
+# in locations other than lua/
+
+
+FIND_PATH(LUA_INCLUDE_DIR lua.h
+  PATHS
+  $ENV{LUA_DIR}
+  NO_DEFAULT_PATH
+  PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include
+)
+
+FIND_PATH(LUA_INCLUDE_DIR lua.h
+  PATHS
+  ~/Library/Frameworks
+  /Library/Frameworks
+  /usr/local
+  /usr
+  /sw # Fink
+  /opt/local # DarwinPorts
+  /opt/csw # Blastwave
+  /opt
+  PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include
+)
+
+FIND_LIBRARY(LUA_LIBRARY 
+  NAMES lua51 lua5.1 lua
+  PATHS
+  $ENV{LUA_DIR}
+  NO_DEFAULT_PATH
+    PATH_SUFFIXES lib64 lib
+)
+
+FIND_LIBRARY(LUA_LIBRARY
+  NAMES lua51 lua5.1 lua
+  PATHS
+  ~/Library/Frameworks
+  /Library/Frameworks
+  /usr/local
+  /usr
+  /sw
+  /opt/local
+  /opt/csw
+  /opt
+    PATH_SUFFIXES lib64 lib
+)
+
+IF(LUA_LIBRARY)
+  # include the math library for Unix
+  IF(UNIX AND NOT APPLE)
+    FIND_LIBRARY(LUA_MATH_LIBRARY m)
+    SET( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
+  # For Windows and Mac, don't need to explicitly include the math library
+  ELSE(UNIX AND NOT APPLE)
+    SET( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
+  ENDIF(UNIX AND NOT APPLE)
+ENDIF(LUA_LIBRARY)
+
+INCLUDE(FindPackageHandleStandardArgs)
+# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if 
+# all listed variables are TRUE
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua50  DEFAULT_MSG  LUA_LIBRARIES LUA_INCLUDE_DIR)
+
+MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)
+
