Index: code/branches/buildsystem2/cmake/FindALUT.cmake
===================================================================
--- code/branches/buildsystem2/cmake/FindALUT.cmake	(revision 2615)
+++ code/branches/buildsystem2/cmake/FindALUT.cmake	(revision 2616)
@@ -24,17 +24,7 @@
 INCLUDE(HandleLibraryTypes)
 
-SET(ALUT_PATHS
-  $ENV{ALUTDIR}
-  /usr/local
-  /usr
-  /sw        # Fink
-  /opt/local # DarwinPorts
-  /opt/csw   # Blastwave
-  /opt
-)
-
 FIND_PATH(ALUT_INCLUDE_DIR AL/alut.h
   PATHS
-  ${ALUT_PATHS}
+  $ENV{ALUTDIR}
   ~/Library/Frameworks/OpenAL.framework
   /Library/Frameworks/OpenAL.framework
@@ -69,28 +59,26 @@
   FIND_LIBRARY(ALUT_LIBRARY_OPTIMIZED
     NAMES alut
-    PATHS ${ALUT_PATHS}
+    PATHS $ENV{ALUTDIR}
     PATH_SUFFIXES lib libs
   )
   FIND_LIBRARY(ALUT_LIBRARY_DEBUG
-    NAMES alut${LIBRARY_DEBUG_POSTFIX}
-    PATHS ${ALUT_PATHS}
+    NAMES alutd alut_d
+    PATHS $ENV{ALUTDIR}
     PATH_SUFFIXES lib libs
   )
 ENDIF(${ALUT_INCLUDE_DIR} MATCHES ".framework")
 
-# handle the QUIETLY and REQUIRED arguments and set ALUT_FOUND to TRUE if
-# all listed variables are TRUE
+# Handle the REQUIRED argument and set ALUT_FOUND
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(ALUT DEFAULT_MSG
+    ALUT_INCLUDE_DIR
     ALUT_LIBRARY_OPTIMIZED
-    ALUT_INCLUDE_DIR
 )
 
-# Set optimized and debug libraries
+# Collect optimized and debug libraries
 HANDLE_LIBRARY_TYPES(ALUT)
 
 MARK_AS_ADVANCED(
-    ALUT_LIBRARY
+    ALUT_INCLUDE_DIR
     ALUT_LIBRARY_OPTIMIZED
     ALUT_LIBRARY_DEBUG
-    ALUT_INCLUDE_DIR
 )
Index: code/branches/buildsystem2/cmake/FindCEGUI.cmake
===================================================================
--- code/branches/buildsystem2/cmake/FindCEGUI.cmake	(revision 2615)
+++ code/branches/buildsystem2/cmake/FindCEGUI.cmake	(revision 2616)
@@ -19,73 +19,73 @@
 #                 > www.orxonox.net <
 
-INCLUDE(FindPackageHandleStandardArgs)
+INCLUDE(DetermineVersion)
+INCLUDE(FindPackageHandleAdvancedArgs)
 INCLUDE(HandleLibraryTypes)
 
 FIND_PATH(CEGUI_INCLUDE_DIR CEGUI.h
-    PATHS
-    $ENV{CEGUIDIR}
-    /usr/local
-    /usr
-    PATH_SUFFIXES include include/CEGUI
+  PATHS $ENV{CEGUIDIR}
+  PATH_SUFFIXES include include/CEGUI
 )
 FIND_LIBRARY(CEGUI_LIBRARY_OPTIMIZED
-    NAMES CEGUIBase
-    PATHS
-    $ENV{CEGUIDIR}
-    /usr/local
-    /usr
-    PATH_SUFFIXES lib bin
+  NAMES CEGUIBase
+  PATHS $ENV{CEGUIDIR}
+  PATH_SUFFIXES lib bin
 )
 FIND_LIBRARY(CEGUI_LIBRARY_DEBUG
-    NAMES CEGUIBase${LIBRARY_DEBUG_POSTFIX}
-    PATHS
-    $ENV{CEGUIDIR}
-    /usr/local
-    /usr
-    PATH_SUFFIXES lib bin
+  NAMES CEGUIBased CEGUIBase_d
+  PATHS $ENV{CEGUIDIR}
+  PATH_SUFFIXES lib bin
 )
 
-# Look in CEGUIVersion.h for the version number
-INCLUDE(DetermineVersion)
+# Inspect CEGUIVersion.h for the version number
 DETERMINE_VERSION(CEGUI ${CEGUI_INCLUDE_DIR}/CEGUIVersion.h)
-# STRLESS can be dangerous since it only compares strings.
-# Unfortunately VERSION_LESS is only provided since CMake v2.6.2
-IF(${CEGUI_VERSION} STRLESS "0.5.0")
-   MESSAGE(FATAL_ERROR "Minimum CEGUI version required is 0.5.0")
-ENDIF(${CEGUI_VERSION} STRLESS "0.5.0")
 
-
-#    IF (NOT CEGUI_SCRIPT_LIBDIR)
-#        # Search Lua script module
-#        SET(CEGUI_SCRIPT_LIBRARIES "CEGUILuaScriptModule")
-#        FIND_LIBRARY(CEGUI_SCRIPT_LIBDIR NAMES ${CEGUI_SCRIPT_LIBRARIES} PATHS
-#            ../libs/cegui-0.6.1/bin
-#        )
-#    IF (NOT CEGUI_SCRIPT_LIBDIR)
-#            SET(CEGUI_SCRIPT_LIBRARIES "CEGUILua")
-#            FIND_LIBRARY(CEGUI_SCRIPT_LIBDIR NAMES ${CEGUI_SCRIPT_LIBRARIES} PATHS
-#                ../libs/cegui-0.6.1/bin
-#            )
-#            IF (NOT CEGUI_SCRIPT_LIBDIR)
-#                SET(CEGUI_SCRIPT_LIBRARIES)
-#            ENDIF (NOT CEGUI_SCRIPT_LIBDIR)
-#        ENDIF (NOT CEGUI_SCRIPT_LIBDIR)
-#    ENDIF (NOT CEGUI_SCRIPT_LIBDIR)
-
-
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(CEGUI DEFAULT_MSG
-    CEGUI_LIBRARY_OPTIMIZED
-    CEGUI_INCLUDE_DIR
-    #CEGUI_SCRIPT_LIBRARIES
+# Handle the REQUIRED argument and set CEGUI_FOUND
+# Also checks the version requirements if given
+FIND_PACKAGE_HANDLE_ADVANCED_ARGS(CEGUI DEFAULT_MSG "${CEGUI_VERSION}"
+  CEGUI_INCLUDE_DIR
+  CEGUI_LIBRARY_OPTIMIZED
 )
 
-# Set optimized and debug libraries
+# Collect optimized and debug libraries
 HANDLE_LIBRARY_TYPES(CEGUI)
 
 MARK_AS_ADVANCED(
-    CEGUI_LIBRARY
-    CEGUI_LIBRARY_OPTIMIZED
-    CEGUI_LIBRARY_DEBUG
-    CEGUI_INCLUDE_DIR
-    #CEGUI_SCRIPT_LIBRARIES
+  CEGUI_INCLUDE_DIR
+  CEGUI_LIBRARY_OPTIMIZED
+  CEGUI_LIBRARY_DEBUG
 )
+
+LIST(FIND CEGUILUA_INTERNAL_SUPPORT "${CEGUI_VERSION}" _find_result)
+IF(CEGUILUA_USE_EXTERNAL_LIBRARY OR _find_result EQUAL -1)
+  # Also try to find the CEGUILua libraries.
+  # There would already be libraries in src/ for versions 0.5 and 0.6
+  FIND_LIBRARY(CEGUILUA_LIBRARY_OPTIMIZED
+    NAMES CEGUILua
+    PATHS $ENV{CEGUIDIR}
+    PATH_SUFFIXES lib bin
+  )
+  FIND_LIBRARY(CEGUILUA_LIBRARY_DEBUG
+    NAMES CEGUILuad CEGUILua_d
+    PATHS $ENV{CEGUIDIR}
+    PATH_SUFFIXES lib bin
+  )
+
+  SET(CEGUILua_FIND_REQUIRED ${CEGUI_FIND_REQUIRED})
+  # Handle the REQUIRED argument and set CEGUILUA_FOUND
+  FIND_PACKAGE_HANDLE_STANDARD_ARGS(CEGUILua DEFAULT_MSG
+    CEGUILUA_LIBRARY_OPTIMIZED
+  )
+
+  # Collect optimized and debug libraries
+  HANDLE_LIBRARY_TYPES(CEGUILUA)
+
+  MARK_AS_ADVANCED(
+    CEGUILUA_LIBRARY_OPTIMIZED
+    CEGUILUA_LIBRARY_DEBUG
+  )
+
+ELSE(CEGUILUA_USE_EXTERNAL_LIBRARY OR _find_result EQUAL -1)
+  SET(CEGUILUA_USE_INTERNAL_LIBRARY TRUE)
+ENDIF(CEGUILUA_USE_EXTERNAL_LIBRARY OR _find_result EQUAL -1)
+
Index: code/branches/buildsystem2/cmake/FindDirectX.cmake
===================================================================
--- code/branches/buildsystem2/cmake/FindDirectX.cmake	(revision 2615)
+++ code/branches/buildsystem2/cmake/FindDirectX.cmake	(revision 2616)
@@ -1,47 +1,42 @@
+# Find script for DirectX on Windows
+# Once loaded this will define
+#   DirectX_FOUND        - system has DirectX
+#   DirectX_INCLUDE_DIR  - include directory for DirectX
+#   DirectX_LIBRARY      - library for DirectX
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
 INCLUDE(FindPackageHandleStandardArgs)
 INCLUDE(HandleLibraryTypes)
 
-IF(WIN32)
-  # Find script for DirectX on Windows
-  # Once loaded this will define
-  #   DirectX_FOUND        - system has DirectX
-  #   DirectX_INCLUDE_DIR  - include directory for DirectX
-  #   DirectX_LIBRARY      - library for DirectX
-  #
-  # Several changes and additions by Fabian 'x3n' Landau
-  #                 > www.orxonox.net <
+FIND_PATH(DIRECTX_INCLUDE_DIR dinput.h
+  PATHS
+  $ENV{DXSDK_DIR}
+  PATH_SUFFIXES include
+)
+FIND_LIBRARY(DIRECTX_LIBRARY_input dinput8
+  PATHS
+  $ENV{DXSDK_DIR}
+  PATH_SUFFIXES lib Lib lib/x86 Lib/x86
+)
+FIND_LIBRARY(DIRECTX_LIBRARY_guid dxguid
+  PATHS
+  $ENV{DXSDK_DIR}
+  PATH_SUFFIXES lib Lib lib/x86 Lib/x86
+)
 
-  FIND_PATH(DirectX_INCLUDE_DIR dinput.h
-    PATHS
-    $ENV{DXSDK_DIR}
-    PATH_SUFFIXES include
-  )
+# Handle the REQUIRED argument and set DIRECTX_FOUND
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(DirectX DEFAULT_MSG
+  DIRECTX_INCLUDE_DIR
+  DIRECTX_LIBRARY_input
+  DIRECTX_LIBRARY_guid
+)
 
-  FIND_LIBRARY(DirectX_LIBRARY_1 dinput8
-    PATHS
-    $ENV{DXSDK_DIR}
-    PATH_SUFFIXES lib Lib lib/x86 Lib/x86
-  )
-  FIND_LIBRARY(DirectX_LIBRARY_2 dxguid
-    PATHS
-    $ENV{DXSDK_DIR}
-    PATH_SUFFIXES lib Lib lib/x86 Lib/x86
-  )
-
-  FIND_PACKAGE_HANDLE_STANDARD_ARGS(DirectX DEFAULT_MSG
-    DirectX_LIBRARY_1
-    DirectX_LIBRARY_2
-    DirectX_INCLUDE_DIR
-  )
-
-  IF(DIRECTX_FOUND)
-    SET(DirectX_LIBRARIES ${DirectX_LIBRARY_1} ${DirectX_LIBRARY_2} CACHE STRING "DirectX library files" FORCE)
-  ENDIF(DIRECTX_FOUND)
-ENDIF(WIN32)
+SET(DIRECTX_LIBRARIES ${DIRECTX_LIBRARY_input} ${DIRECTX_LIBRARY_guid})
 
 MARK_AS_ADVANCED(
-  DirectX_INCLUDE_DIR
-  DirectX_LIBRARY_1
-  DirectX_LIBRARY_2
-  DirectX_LIBRARIES
+  DIRECTX_INCLUDE_DIR
+  DIRECTX_LIBRARY_input
+  DIRECTX_LIBRARY_guid
 )
Index: code/branches/buildsystem2/cmake/FindENet.cmake
===================================================================
--- code/branches/buildsystem2/cmake/FindENet.cmake	(revision 2615)
+++ code/branches/buildsystem2/cmake/FindENet.cmake	(revision 2616)
@@ -15,50 +15,56 @@
 #                 > www.orxonox.net <
 
-INCLUDE(FindPackageHandleStandardArgs)
+INCLUDE(FindPackageHandleAdvancedArgs)
 INCLUDE(HandleLibraryTypes)
 
 FIND_PATH(ENET_INCLUDE_DIR enet/enet.h
-    PATHS
-    $ENV{ENETDIR}
-    /usr/local
-    /usr
-    PATH_SUFFIXES include
+  PATHS $ENV{ENETDIR}
+  PATH_SUFFIXES include
 )
 FIND_LIBRARY(ENET_LIBRARY_OPTIMIZED
-    NAMES enet
-    PATHS
-    $ENV{ENETDIR}
-    /usr/local
-    /usr
-    PATH_SUFFIXES lib
+  NAMES enet
+  PATHS $ENV{ENETDIR}
+  PATH_SUFFIXES lib
 )
 FIND_LIBRARY(ENET_LIBRARY_DEBUG
-    NAMES enet${LIBRARY_DEBUG_POSTFIX}
-    PATHS
-    $ENV{ENETDIR}
-    /usr/local
-    /usr
-    PATH_SUFFIXES lib
+  NAMES enetd enet_d
+  PATHS $ENV{ENETDIR}
+  PATH_SUFFIXES lib
 )
 
-# handle the QUIETLY and REQUIRED arguments and set ENET_FOUND to TRUE if
-# all listed variables are TRUE
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(ENET DEFAULT_MSG
-    ENET_LIBRARY_OPTIMIZED
-    ENET_INCLUDE_DIR
+# Try to determine the version. Note that enet only stores the major
+# version in the header file. So we check for existing functions.
+# Hence the this script only distinguishes between 1.0, 1.1 and 1.2
+FILE(STRINGS ${ENET_INCLUDE_DIR}/enet/enet.h _enet_header REGEX "ENET_")
+IF(_enet_header MATCHES "ENET_VERSION[ \t]*=[ \t]*1")
+  IF(_enet_header MATCHES "enet_socket_set_option")
+    SET(ENET_VERSION 1.2)
+  ELSEIF(_enet_header MATCHES "enet_peer_disconnect_later")
+    SET(ENET_VERSION 1.1)
+  ELSE(_enet_header MATCHES "enet_socket_set_option")
+    SET(ENET_VERSION 1.0)
+  ENDIF(_enet_header MATCHES "enet_socket_set_option")
+ELSE(_enet_header MATCHES "ENET_VERSION[ \t]*=[ \t]*1")
+  SET(ENET_VERSION 0) # Script doesn't support versions below 1.0
+ENDIF(_enet_header MATCHES "ENET_VERSION[ \t]*=[ \t]*1")
+
+# Handle the REQUIRED argument and set ENET_FOUND
+# Also check the the version requirements
+FIND_PACKAGE_HANDLE_ADVANCED_ARGS(ENet DEFAULT_MSG ${ENET_VERSION}
+  ENET_INCLUDE_DIR
+  ENET_LIBRARY_OPTIMIZED
 )
 
-# Set optimized and debug libraries
-IF(MINGW)
+# Collect optimized and debug libraries
+IF(NOT LINK_ENET_DYNAMIC AND WIN32)
   # ENet is linked statically, hence we need to add some windows dependencies
   HANDLE_LIBRARY_TYPES(ENET ws2_32 winmm)
-ELSE(MINGW)
+ELSE(NOT LINK_ENET_DYNAMIC AND WIN32)
   HANDLE_LIBRARY_TYPES(ENET)
-ENDIF(MINGW)
+ENDIF(NOT LINK_ENET_DYNAMIC AND WIN32)
 
 MARK_AS_ADVANCED(
-    ENET_LIBRARY
-    ENET_LIBRARY_OPTIMIZED
-    ENET_LIBRARY_DEBUG
-    ENET_INCLUDE_DIR
+  ENET_INCLUDE_DIR
+  ENET_LIBRARY_OPTIMIZED
+  ENET_LIBRARY_DEBUG
 )
Index: code/branches/buildsystem2/cmake/FindOGRE.cmake
===================================================================
--- code/branches/buildsystem2/cmake/FindOGRE.cmake	(revision 2615)
+++ code/branches/buildsystem2/cmake/FindOGRE.cmake	(revision 2616)
@@ -13,37 +13,41 @@
 # Several changes and additions by Fabian 'x3n' Landau
 # Lots of simplifications by Adrian Friedli
-# Plugin checking by Reto Grieder
 #                 > www.orxonox.net <
 
-INCLUDE(FindPackageHandleStandardArgs)
+INCLUDE(DetermineVersion)
+INCLUDE(FindPackageHandleAdvancedArgs)
 INCLUDE(HandleLibraryTypes)
 
 FIND_PATH(OGRE_INCLUDE_DIR Ogre.h
-    PATHS $ENV{OGRE_HOME} /usr/local /usr
-    PATH_SUFFIXES include include/OGRE
+  PATHS $ENV{OGRE_HOME}
+  PATH_SUFFIXES include include/OGRE
 )
 FIND_LIBRARY(OGRE_LIBRARY_OPTIMIZED
-    NAMES OgreMain
-    PATHS $ENV{OGRE_HOME} /usr/local /usr
-    PATH_SUFFIXES lib bin/Release bin/release Release release
+  NAMES OgreMain
+  PATHS $ENV{OGRE_HOME}
+  PATH_SUFFIXES lib bin/Release bin/release Release release
 )
 FIND_LIBRARY(OGRE_LIBRARY_DEBUG
-    NAMES OgreMain${LIBRARY_DEBUG_POSTFIX}
-    PATHS $ENV{OGRE_HOME} /usr/local /usr
-    PATH_SUFFIXES lib bin/Debug bin/debug Debug debug
+  NAMES OgreMaind OgreMain_d
+  PATHS $ENV{OGRE_HOME}
+  PATH_SUFFIXES lib bin/Debug bin/debug Debug debug
 )
 
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(OGRE DEFAULT_MSG
-    OGRE_LIBRARY_OPTIMIZED
-    OGRE_INCLUDE_DIR
+# Inspect OgrePrerquisites.h for the version number
+DETERMINE_VERSION(OGRE ${OGRE_INCLUDE_DIR}/OgrePrerequisites.h)
+
+# Handle the REQUIRED argument and set OGRE_FOUND
+# Also check the version requirements
+FIND_PACKAGE_HANDLE_ADVANCED_ARGS(OGRE DEFAULT_MSG ${OGRE_VERSION}
+  OGRE_INCLUDE_DIR
+  OGRE_LIBRARY_OPTIMIZED
 )
 
-# Set optimized and debug libraries
+# Collect optimized and debug libraries
 HANDLE_LIBRARY_TYPES(OGRE)
 
 MARK_AS_ADVANCED(
-    OGRE_LIBRARY
-    OGRE_LIBRARY_OPTIMIZED
-    OGRE_LIBRARY_DEBUG
-    OGRE_INCLUDE_DIR
+  OGRE_INCLUDE_DIR
+  OGRE_LIBRARY_OPTIMIZED
+  OGRE_LIBRARY_DEBUG
 )
Index: code/branches/buildsystem2/cmake/FindOgg.cmake
===================================================================
--- code/branches/buildsystem2/cmake/FindOgg.cmake	(revision 2616)
+++ code/branches/buildsystem2/cmake/FindOgg.cmake	(revision 2616)
@@ -0,0 +1,50 @@
+# - Try to find ogg/vorbis
+# Once done this will define
+#
+#  OGG_FOUND - system has ogg
+#  OGG_INCLUDE_DIR
+#  OGG_LIBRARY
+#
+# $OGGDIR is an environment variable used
+# for finding ogg.
+#
+# Several changes and additions by Fabian 'x3n' Landau
+# Most of all rewritten by Adrian Friedli
+#                 > www.orxonox.net <
+
+INCLUDE(FindPackageHandleStandardArgs)
+INCLUDE(HandleLibraryTypes)
+
+FIND_PATH(OGG_INCLUDE_DIR ogg/ogg.h
+  PATHS $ENV{OGGDIR}
+  PATH_SUFFIXES include
+)
+FIND_PATH(VORBIS_INCLUDE_DIR vorbis/codec.h
+  PATHS $ENV{OGGDIR}
+  PATH_SUFFIXES include
+)
+FIND_LIBRARY(OGG_LIBRARY_OPTIMIZED
+  NAMES ogg
+  PATHS $ENV{OGGDIR}
+  PATH_SUFFIXES lib
+)
+FIND_LIBRARY(OGG_LIBRARY_DEBUG
+  NAMES oggd ogg_d
+  PATHS $ENV{VORBISDIR}
+  PATH_SUFFIXES lib
+)
+
+# Handle the REQUIRED argument and set OGG_FOUND
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ogg DEFAULT_MSG
+  OGG_INCLUDE_DIR
+  OGG_LIBRARY_OPTIMIZED
+)
+
+# Collect optimized and debug libraries
+HANDLE_LIBRARY_TYPES(OGG)
+
+MARK_AS_ADVANCED(
+  OGG_INCLUDE_DIR
+  OGG_LIBRARY_OPTIMIZED
+  OGG_LIBRARY_DEBUG
+)
Index: code/branches/buildsystem2/cmake/FindOggVorbis.cmake
===================================================================
--- code/branches/buildsystem2/cmake/FindOggVorbis.cmake	(revision 2615)
+++ 	(revision )
@@ -1,101 +1,0 @@
-# - Try to find ogg/vorbis
-# Once done this will define
-#
-#  OGG_FOUND - system has ogg
-#  OGG_INCLUDE_DIR
-#  OGG_LIBRARY
-#  VORBIS_FOUND - system has vorbis
-#  VORBIS_INCLUDE_DIR
-#  VORBIS_LIBRARY
-#  VORBISENC_LIBRARY
-#  VORBISFILE_LIBRARY
-#
-# $OGGDIR and $VORBISDIR are environment variables used
-# for finding ogg/vorbis.
-#
-# Several changes and additions by Fabian 'x3n' Landau
-# Most of all rewritten by Adrian Friedli
-#                 > www.orxonox.net <
-
-INCLUDE(FindPackageHandleStandardArgs)
-INCLUDE(HandleLibraryTypes)
-
-SET(OGG_SEARCH_PATHS
-  $ENV{OGGDIR}
-  $ENV{VORBISDIR}
-  /usr/local
-  /usr
-  /sw
-  /opt/local
-  /opt/csw
-  /opt
-)
-
-FIND_PATH(OGG_INCLUDE_DIR ogg/ogg.h
-  PATHS ${OGG_SEARCH_PATHS}
-  PATH_SUFFIXES include
-)
-FIND_PATH(VORBIS_INCLUDE_DIR vorbis/codec.h
-  PATHS ${OGG_SEARCH_PATHS}
-  PATH_SUFFIXES include
-)
-FIND_LIBRARY(OGG_LIBRARY_OPTIMIZED NAMES ogg
-  PATHS ${OGG_SEARCH_PATHS}
-  PATH_SUFFIXES lib
-)
-FIND_LIBRARY(OGG_LIBRARY_DEBUG NAMES ogg${LIBRARY_DEBUG_POSTFIX}
-  PATHS ${OGG_SEARCH_PATHS}
-  PATH_SUFFIXES lib
-)
-FIND_LIBRARY(VORBIS_LIBRARY_OPTIMIZED NAMES vorbis
-  PATHS ${OGG_SEARCH_PATHS}
-  PATH_SUFFIXES lib
-)
-FIND_LIBRARY(VORBIS_LIBRARY_DEBUG NAMES vorbis${LIBRARY_DEBUG_POSTFIX}
-  PATHS ${OGG_SEARCH_PATHS}
-  PATH_SUFFIXES lib
-)
-FIND_LIBRARY(VORBISFILE_LIBRARY_OPTIMIZED NAMES vorbisfile
-  PATHS ${OGG_SEARCH_PATHS}
-  PATH_SUFFIXES lib
-)
-FIND_LIBRARY(VORBISFILE_LIBRARY_DEBUG NAMES vorbisfile${LIBRARY_DEBUG_POSTFIX}
-  PATHS ${OGG_SEARCH_PATHS}
-  PATH_SUFFIXES lib
-)
-
-# handle the QUIETLY and REQUIRED arguments and set *_FOUND to TRUE if
-# all listed variables are TRUE
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(OGG DEFAULT_MSG
-  OGG_LIBRARY_OPTIMIZED
-  OGG_INCLUDE_DIR
-)
-SET(VORBIS_FIND_REQUIRED ON)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(VORBIS DEFAULT_MSG
-  VORBIS_LIBRARY_OPTIMIZED
-  VORBIS_INCLUDE_DIR
-)
-SET(VORBISFILE_FIND_REQUIRED ON)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(VORBISFILE DEFAULT_MSG
-  VORBISFILE_LIBRARY_OPTIMIZED
-  VORBIS_INCLUDE_DIR
-)
-
-# Set optimized and debug libraries
-HANDLE_LIBRARY_TYPES(OGG)
-HANDLE_LIBRARY_TYPES(VORBIS)
-HANDLE_LIBRARY_TYPES(VORBISFILE)
-
-MARK_AS_ADVANCED(
-  OGG_LIBRARY
-  OGG_LIBRARY_OPTIMIZED
-  OGG_LIBRARY_DEBUG
-  OGG_INCLUDE_DIR
-  VORBIS_LIBRARY
-  VORBIS_LIBRARY_OPTIMIZED
-  VORBIS_LIBRARY_DEBUG
-  VORBISFILE_LIBRARY
-  VORBISFILE_LIBRARY_OPTIMIZED
-  VORBISFILE_LIBRARY_DEBUG
-  VORBIS_INCLUDE_DIR
-)
Index: code/branches/buildsystem2/cmake/FindVorbis.cmake
===================================================================
--- code/branches/buildsystem2/cmake/FindVorbis.cmake	(revision 2616)
+++ code/branches/buildsystem2/cmake/FindVorbis.cmake	(revision 2616)
@@ -0,0 +1,63 @@
+# - Try to find ogg/vorbis
+# Once done this will define
+#
+#  VORBIS_FOUND - system has vorbis
+#  VORBIS_INCLUDE_DIR
+#  VORBIS_LIBRARY
+#  VORBISENC_LIBRARY
+#  VORBISFILE_LIBRARY
+#
+# $VORBISDIR is an environment variable used
+# for finding vorbis.
+#
+# Several changes and additions by Fabian 'x3n' Landau
+# Most of all rewritten by Adrian Friedli
+#                 > www.orxonox.net <
+
+INCLUDE(FindPackageHandleStandardArgs)
+INCLUDE(HandleLibraryTypes)
+
+FIND_PATH(VORBIS_INCLUDE_DIR vorbis/codec.h
+  PATHS $ENV{VORBISDIR}
+  PATH_SUFFIXES include
+)
+FIND_LIBRARY(VORBIS_LIBRARY_OPTIMIZED
+  NAMES vorbis
+  PATHS $ENV{VORBISDIR}
+  PATH_SUFFIXES lib
+)
+FIND_LIBRARY(VORBIS_LIBRARY_DEBUG
+  NAMES vorbisd vorbis_d
+  PATHS $ENV{VORBISDIR}
+  PATH_SUFFIXES lib
+)
+FIND_LIBRARY(VORBISFILE_LIBRARY_OPTIMIZED
+  NAMES vorbisfile
+  PATHS $ENV{VORBISDIR}
+  PATH_SUFFIXES lib
+)
+FIND_LIBRARY(VORBISFILE_LIBRARY_DEBUG
+  NAMES vorbisfiled vorbisfile_d
+  PATHS $ENV{VORBISDIR}
+  PATH_SUFFIXES lib
+)
+
+# Handle the REQUIRED argument and set VORBIS_FOUND
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Vorbis DEFAULT_MSG
+  VORBIS_LIBRARY_OPTIMIZED
+  VORBISFILE_LIBRARY_OPTIMIZED
+  VORBIS_INCLUDE_DIR
+)
+
+# Collect optimized and debug libraries
+HANDLE_LIBRARY_TYPES(VORBIS)
+HANDLE_LIBRARY_TYPES(VORBISFILE)
+SET(VORBIS_LIBRARIES ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY})
+
+MARK_AS_ADVANCED(
+  VORBIS_INCLUDE_DIR
+  VORBIS_LIBRARY_OPTIMIZED
+  VORBIS_LIBRARY_DEBUG
+  VORBISFILE_LIBRARY_OPTIMIZED
+  VORBISFILE_LIBRARY_DEBUG
+)
Index: code/branches/buildsystem2/cmake/LibraryConfig.cmake
===================================================================
--- code/branches/buildsystem2/cmake/LibraryConfig.cmake	(revision 2615)
+++ code/branches/buildsystem2/cmake/LibraryConfig.cmake	(revision 2616)
@@ -3,23 +3,33 @@
 INCLUDE(LibraryConfigTardis)
 
-# Performs the search and sets the variables
+############### Library finding #################
+# Performs the search and sets the variables    #
 
-# Expand the next statement if newer boost versions than 1.36.1 are released
-SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0 CACHE STRING "")
-FIND_PACKAGE(Boost 1.34 REQUIRED thread filesystem)
-# With MSVC, automatic linking is performed for boost. So wee need to tell
-# the linker where to find them. Also note that when running FindBoost for the
-# first time, it will set ${Boost_LIBRARIES} to "" but afterwards to the libs.
-IF (MSVC)
-  LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
-ENDIF (MSVC)
-FIND_PACKAGE(OGRE REQUIRED)
-FIND_PACKAGE(CEGUI REQUIRED)
-FIND_PACKAGE(ENet REQUIRED)
-FIND_PACKAGE(OpenAL REQUIRED)
-FIND_PACKAGE(ALUT REQUIRED)
-FIND_PACKAGE(OggVorbis REQUIRED)
-FIND_PACKAGE(ZLIB REQUIRED)
-FIND_PACKAGE(DirectX REQUIRED)
+FIND_PACKAGE(OGRE  1.4 EXACT REQUIRED)
+FIND_PACKAGE(ENet  1.1       REQUIRED)
+FIND_PACKAGE(Ogg             REQUIRED)
+FIND_PACKAGE(Vorbis          REQUIRED)
+FIND_PACKAGE(ALUT            REQUIRED)
+FIND_PACKAGE(ZLIB            REQUIRED)
+IF(WIN32)
+  FIND_PACKAGE(DirectX       REQUIRED)
+ENDIF(WIN32)
+
+##### CEGUI #####
+# We make use of the CEGUI script module called CEGUILua.
+# However there is a small issue with that: We use Tolua, a C++ binding
+# generator ourselves. And we also have to use our bindings in the same
+# lua state is CEGUILua's. Unfortunately this implies that both lua runtime
+# version are equal or else you get segmentation faults.
+# In order to match the Lua versions we decided to ship CEGUILua in our
+# repository, mainly because there is no way to determine which version of
+# Lua CEGUILua was linked against (you'd have to specify yourself) and secondly
+# because we can then choose the Lua version. Future plans might involve only
+# accepting Lua 5.1.
+
+# Insert all internally supported CEGUILua versions here
+SET(CEGUILUA_INTERNAL_SUPPORT 0.5.0 0.6.0 0.6.1 0.6.2)
+OPTION(CEGUILUA_USE_EXTERNAL_LIBRARY "Force the use of external CEGUILua library" OFF)
+FIND_PACKAGE(CEGUI 0.5 REQUIRED)
 
 ##### Lua #####
@@ -36,15 +46,48 @@
 FIND_PACKAGE(Lua ${LUA_VERSION_REQUEST} EXACT REQUIRED)
 
-# QUIET: Don't require the whole tcl rat tail
-FIND_PACKAGE(TCL QUIET)
-IF(NOT TCL_FOUND)
-  MESSAGE(FATAL_ERROR "Tcl was not found.")
-ENDIF(NOT TCL_FOUND)
-
-# Hide variables created by CMake FindXX scripts
+##### OpenAL #####
+FIND_PACKAGE(OpenAL REQUIRED)
+# ALUT's headers include openal headers, but like <AL/al.h>, not <al.h>
+# Unfortunately this is not the case on all systems, so FindOpenAL.cmake
+# specifies the directory/AL, which now causes problems with ALUT.
+IF(DEFINED OPENAL_FOUND_FIRST_TIME)
+  SET(OPENAL_FOUND_FIRST_TIME FALSE CACHE INTERNAL "")
+ELSE(DEFINED OPENAL_FOUND_FIRST_TIME)
+  SET(OPENAL_FOUND_FIRST_TIME TRUE CACHE INTERNAL "")
+  STRING(REGEX REPLACE "^(.*)/AL$" "\\1" _openal_dir_2 ${OPENAL_INCLUDE_DIR})
+  IF(_openal_dir_2)
+    SET(OPENAL_INCLUDE_DIR ${OPENAL_INCLUDE_DIR} ${_openal_dir_2} CACHE STRING "" FORCE)
+  ENDIF(_openal_dir_2)
+ENDIF(DEFINED OPENAL_FOUND_FIRST_TIME)
+# Hide variables created by the script
 MARK_AS_ADVANCED(
-  LUA_LIBRARY_lua
-  LUA_LIBRARY_lualib
   OPENAL_INCLUDE_DIR
   OPENAL_LIBRARY
 )
+
+##### TCL #####
+# We only require TCL, so avoid confusing user about other TCL stuff by
+# applying a little workaround
+SET(Tclsh_FIND_QUIETLY TRUE)
+FIND_PACKAGE(TCL 8.4 REQUIRED QUIET)
+# Display messages separately
+SET(TCL_FIND_QUIETLY FALSE)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH)
+# Workaround a CMake bug that doesn't set the variables to the cache
+# Occurs at least on CMake 2.6.2 and 2.6.0 under Windows
+SET(TCL_LIBRARY ${TCL_LIBRARY} CACHE FILEPATH "")
+SET(TCL_INCLUDE_PATH ${TCL_INCLUDE_PATH} CACHE PATH "")
+
+##### Boost #####
+# Expand the next statement if newer boost versions than 1.36.1 are released
+SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0)
+FIND_PACKAGE(Boost 1.34 REQUIRED thread filesystem)
+# With MSVC, automatic linking is performed for boost. So wee need to tell
+# the linker where to find them. Also note that when running FindBoost for the
+# first time, it will set ${Boost_LIBRARIES} to "" but afterwards to the libs.
+IF (MSVC)
+  # Little bit hacky, but Boost_LIBRARY_DIRS doesn't get set right when having
+  # debug and optimized libraries.
+  GET_FILENAME_COMPONENT(BOOST_LINK_DIR "${Boost_THREAD_LIBRARY_RELEASE}" PATH)
+  LINK_DIRECTORIES(${BOOST_LINK_DIR})
+ENDIF (MSVC)
