Index: code/branches/buildsystem3/cmake/AddSourceFiles.cmake
===================================================================
--- code/branches/buildsystem3/cmake/AddSourceFiles.cmake	(revision 2663)
+++ 	(revision )
@@ -1,39 +1,0 @@
-#    AddSourceFiles.cmake - CMake Module to include source files in subdirectories.
-#    Author: Reto '1337' Grieder (2008)
-#
-#    This program is free software; you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation; either version 2 of the License, or
-#    (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License
-#    along with this program; if not, write to the Free Software
-#    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
-
-MACRO(ADD_SOURCE_DIRECTORY _target_list _directory)
-
-  # Subfolder puts source files into CMake Cache variable _CACHED_SOURCE_FILES
-  ADD_SUBDIRECTORY(${_directory})
-
-  # Put the directory name in front of each source file from the subfolder
-  # and add it to the source list in the current directory
-  FOREACH(_source_file ${_CACHED_SOURCE_FILES})
-    LIST(APPEND ${_target_list} "${_directory}/${_source_file}")
-  ENDFOREACH(_source_file)
-
-ENDMACRO(ADD_SOURCE_DIRECTORY)
-
-
-MACRO(ADD_SOURCE_FILES _source_list)
-  
-  # Put the source file into a variable that still exists in this_folder/../
-  # Use FORCE to always overwrite the cache variable
-  SET(_CACHED_SOURCE_FILES ${${_source_list}} CACHE STRING "" FORCE)
-  MARK_AS_ADVANCED(_CACHED_SOURCE_FILES FORCE)
-
-ENDMACRO(ADD_SOURCE_FILES)
Index: code/branches/buildsystem3/cmake/BuildConfig.cmake
===================================================================
--- code/branches/buildsystem3/cmake/BuildConfig.cmake	(revision 2664)
+++ code/branches/buildsystem3/cmake/BuildConfig.cmake	(revision 2664)
@@ -0,0 +1,167 @@
+ #
+ #             ORXONOX - the hottest 3D action shooter ever to exist
+ #                             > www.orxonox.net <
+ #
+ #        This program is free software; you can redistribute it and/or
+ #         modify it under the terms of the GNU General Public License
+ #        as published by the Free Software Foundation; either version 2
+ #            of the License, or (at your option) any later version.
+ #
+ #       This program is distributed in the hope that it will be useful,
+ #        but WITHOUT ANY WARRANTY; without even the implied warranty of
+ #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ #                 GNU General Public License for more details.
+ #
+ #   You should have received a copy of the GNU General Public License along
+ #      with this program; if not, write to the Free Software Foundation,
+ #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ #
+ #
+ #  Author:
+ #    Reto Grieder
+ #  Description:
+ #    Configures the compilers and sets build options.
+ #    This also includes handling the OGRE plugins and the media directory.
+ #
+
+################ Misc Options ###################
+
+# Set binary output directories
+SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
+SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+
+# Sets where to find the external libraries like OgreMain.dll at runtime
+# On Unix you should not have to change this at all.
+IF(NOT ORXONOX_RUNTIME_LIBRARY_DIRECTORY)
+  SET(ORXONOX_RUNTIME_LIBRARY_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
+ENDIF()
+
+# Set Debug build to default when not having multi-config generator like msvc
+IF(NOT CMAKE_CONFIGURATION_TYPES)
+  IF(NOT CMAKE_BUILD_TYPE)
+    SET(CMAKE_BUILD_TYPE Debug CACHE STRING
+        "Build types are: Debug, Release, MinSizeRel, RelWithDebInfo" FORCE)
+  ENDIF()
+  MARK_AS_ADVANCED(CLEAR CMAKE_BUILD_TYPE)
+
+  MESSAGE(STATUS "*** Build type is ${CMAKE_BUILD_TYPE} ***")
+ELSE()
+  IF(CMAKE_BUILD_TYPE)
+    SET(CMAKE_BUILD_TYPE CACHE STRING FORCE)
+  ENDIF()
+  MARK_AS_ADVANCED(CMAKE_BUILD_TYPE)
+ENDIF()
+
+OPTION(EXTRA_WARNINGS "Enable some extra warnings (heavily pollutes the output)")
+
+# More plugins: Plugin_BSPSceneManager, Plugin_OctreeSceneManager
+# Render systems may be optional, but at least one has to be found in FindOgre
+SET(OGRE_PLUGINS_INT RenderSystem_GL RenderSystem_Direct3D9 Plugin_ParticleFX)
+IF(WIN32)
+  # CG program manager is probably DirectX related (not available under unix)
+  LIST(APPEND OGRE_PLUGINS_INT Plugin_CgProgramManager)
+ENDIF(WIN32)
+SET(OGRE_PLUGINS ${OGRE_PLUGINS_INT} CACHE STRING
+   "Specify which OGRE plugins to load. Existance check is performed.")
+
+# Check the plugins and determine the plugin folder
+# You can give a hint by setting the environment variable ENV{OGRE_PLUGIN_DIR}
+INCLUDE(CheckOGREPlugins)
+CHECK_OGRE_PLUGINS(${OGRE_PLUGINS})
+
+
+############## Compiler Config ##################
+
+INCLUDE(FlagUtilities)
+
+# Configure the compiler specific build options
+IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUC)
+  INCLUDE(BuildConfigGCC)
+ELSEIF(MSVC)
+  INCLUDE(BuildConfigMSVC)
+ELSE()
+  MESSAGE(STATUS "Warning: Your compiler is not officially supported.")
+ENDIF()
+
+SET(BUILD_CONFIG_USER_SCRIPT "" CACHE FILEPATH
+    "Specify a CMake script if you wish to write your own build config.
+     See BuildConfigGCC.cmake or BuildConfigMSVC.cmake for examples.")
+IF(BUILD_CONFIG_USER_SCRIPT)
+  IF(EXISTS ${CMAKE_MODULE_PATH}/${BUILD_CONFIG_USER_SCRIPT}.cmake)
+    INCLUDE(${BUILD_CONFIG_USER_SCRIPT})
+  ELSEIF(EXISTS ${BUILD_CONFIG_USER_SCRIPT})
+    INCLUDE(${BUILD_CONFIG_USER_SCRIPT})
+  ELSEIF(EXISTS ${CMAKE_MODULE_PATH}/${BUILD_CONFIG_USER_SCRIPT})
+    INCLUDE(${CMAKE_MODULE_PATH}/${BUILD_CONFIG_USER_SCRIPT})
+  ENDIF()
+ENDIF(BUILD_CONFIG_USER_SCRIPT)
+
+
+################ Test options ###################
+
+OPTION(ENABLE_TESTS "Enable build tests.")
+IF(ENABLE_TESTS)
+  ENABLE_TESTING()
+ENDIF(ENABLE_TESTS)
+
+OPTION(NETWORK_TESTING_ENABLED "Build network testing tools: i.e. chatclient chatserver and alike.")
+OPTION(NETWORKTRAFFIC_TESTING_ENABLED "Build dummyserver4 and dummyclient4.")
+
+
+############ Installation Settings ##############
+
+IF(UNIX)
+  SET(ORXONOX_RUNTIME_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/bin/orxonox)
+  SET(ORXONOX_LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/orxonox)
+  SET(ORXONOX_ARCHIVE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/orxonox/static)
+  SET(ORXONOX_MEDIA_INSTALL_PATH   ${CMAKE_INSTALL_PREFIX}/share/orxonox)
+  SET(ORXONOX_DOC_INSTALL_PATH     ${CMAKE_INSTALL_PREFIX}/share/doc/orxonox)
+  # Not yet used
+  SET(ORXONOX_LOG_INSTALL_PATH     ~/.orxonox/log)
+  SET(ORXONOX_CONFIG_INSTALL_PATH  ~/.orxonox/config)
+ELSEIF(WIN32)
+  SET(ORXONOX_RUNTIME_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/bin)
+  SET(ORXONOX_LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib)
+  SET(ORXONOX_ARCHIVE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/static)
+  SET(ORXONOX_MEDIA_INSTALL_PATH   ${CMAKE_INSTALL_PREFIX}/media)
+  SET(ORXONOX_DOC_INSTALL_PATH     ${CMAKE_INSTALL_PREFIX}/doc)
+  # Not yet used
+  SET(ORXONOX_LOG_INSTALL_PATH     ${CMAKE_INSTALL_PREFIX}/log)
+  SET(ORXONOX_CONFIG_INSTALL_PATH  ${CMAKE_INSTALL_PREFIX}/config)
+ENDIF()
+
+
+################# Unix rpath ####################
+
+# use, i.e. don't skip the full RPATH for the build tree
+SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
+
+# when building, don't use the install RPATH already
+# (but later on when installing)
+SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) 
+
+# the RPATH to be used when installing
+SET(CMAKE_INSTALL_RPATH ${ORXONOX_LIBRARY_INSTALL_PATH})
+
+# add the automatically determined parts of the RPATH
+# which point to directories outside the build tree to the install RPATH
+SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+
+
+####### Static/Dynamic linking defines ##########
+
+# Disable Boost auto linking completely
+ADD_COMPILER_FLAGS("-DBOOST_ALL_NO_LIB")
+
+# If no defines are specified, these libs get linked statically
+ADD_COMPILER_FLAGS("-DBOOST_ALL_DYN_LINK" WIN32 LINK_BOOST_DYNAMIC)
+ADD_COMPILER_FLAGS("-DENET_DLL"           WIN32 LINK_ENET_DYNAMIC)
+ADD_COMPILER_FLAGS("-DLUA_BUILD_AS_DLL"   WIN32 LINK_LUA_DYNAMIC)
+ADD_COMPILER_FLAGS("-DZLIB_DLL"           WIN32 LINK_ZLIB_DYNAMIC)
+
+# If no defines are specified, these libs get linked dynamically
+# You can change that optionally in the Cache.
+ADD_COMPILER_FLAGS("-DCEGUI_STATIC"       WIN32 NOT LINK_CEGUI_DYNAMIC)
+ADD_COMPILER_FLAGS("-DOGRE_STATIC_LIB"    WIN32 NOT LINK_OGRE_DYNAMIC)
+ADD_COMPILER_FLAGS("-DSTATIC_BUILD"       WIN32 NOT LINK_TCL_DYNAMIC)
Index: code/branches/buildsystem3/cmake/BuildConfigGCC.cmake
===================================================================
--- code/branches/buildsystem3/cmake/BuildConfigGCC.cmake	(revision 2664)
+++ code/branches/buildsystem3/cmake/BuildConfigGCC.cmake	(revision 2664)
@@ -0,0 +1,68 @@
+ #
+ #             ORXONOX - the hottest 3D action shooter ever to exist
+ #                             > www.orxonox.net <
+ #
+ #        This program is free software; you can redistribute it and/or
+ #         modify it under the terms of the GNU General Public License
+ #        as published by the Free Software Foundation; either version 2
+ #            of the License, or (at your option) any later version.
+ #
+ #       This program is distributed in the hope that it will be useful,
+ #        but WITHOUT ANY WARRANTY; without even the implied warranty of
+ #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ #                 GNU General Public License for more details.
+ #
+ #   You should have received a copy of the GNU General Public License along
+ #      with this program; if not, write to the Free Software Foundation,
+ #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ #
+ #
+ #  Author:
+ #    Reto Grieder, Adrian Friedli
+ #  Description:
+ #    Sets the right compiler and linker flags for GCC.
+ #
+
+# Determine compiler version
+EXEC_PROGRAM(
+  ${CMAKE_CXX_COMPILER}
+  ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
+  OUTPUT_VARIABLE GCC_VERSION
+)
+
+# GCC may not support #pragma GCC system_header correctly when using
+# templates. According to Bugzilla, it was fixed March 07 but tests
+# have confirmed that GCC 4.0.0 does not pose a problem for our cases.
+INCLUDE(CompareVersionStrings)
+COMPARE_VERSION_STRINGS("${GCC_VERSION}" "4.0.0" _compare_result)
+IF(_compare_result LESS 0)
+  SET(GCC_NO_SYSTEM_HEADER_SUPPORT TRUE)
+ENDIF()
+
+# Also include environment flags. Could cause conflicts though
+SET_COMPILER_FLAGS("$ENV{CXXFLAGS}" CXX CACHE)
+SET_COMPILER_FLAGS("$ENV{CFLAGS}"   C   CACHE)
+
+# These flags get added to the flags above
+SET_COMPILER_FLAGS("    -g -ggdb -D_DEBUG" Debug          CACHE)
+SET_COMPILER_FLAGS("             -DNDEBUG" ReleaseAll     CACHE)
+ADD_COMPILER_FLAGS("-O3"                   Release        CACHE)
+ADD_COMPILER_FLAGS("-O2 -g -ggdb"          RelWithDebInfo CACHE)
+ADD_COMPILER_FLAGS("-Os"                   MinSizeRel     CACHE)
+
+# CMake doesn't seem to set the PIC flags right on certain 64 bit systems
+IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
+  ADD_COMPILER_FLAGS("-fPIC" CACHE)
+ENDIF()
+
+# Increase warning level if requested
+IF(EXTRA_WARNINGS)
+  REMOVE_COMPILER_FLAGS("-Wall" CACHE)
+  ADD_COMPILER_FLAGS("-Wextra --Wno-unused-parameter" CACHE)
+ELSE()
+  REMOVE_COMPILER_FLAGS("-Wextra --Wno-unused-parameter" CACHE)
+  ADD_COMPILER_FLAGS("-Wall" CACHE)
+ENDIF()
+
+# General linker flags
+SET_LINKER_FLAGS("--no-undefined" CACHE)
Index: code/branches/buildsystem3/cmake/BuildConfigMSVC.cmake
===================================================================
--- code/branches/buildsystem3/cmake/BuildConfigMSVC.cmake	(revision 2664)
+++ code/branches/buildsystem3/cmake/BuildConfigMSVC.cmake	(revision 2664)
@@ -0,0 +1,119 @@
+ #
+ #             ORXONOX - the hottest 3D action shooter ever to exist
+ #                             > www.orxonox.net <
+ #
+ #        This program is free software; you can redistribute it and/or
+ #         modify it under the terms of the GNU General Public License
+ #        as published by the Free Software Foundation; either version 2
+ #            of the License, or (at your option) any later version.
+ #
+ #       This program is distributed in the hope that it will be useful,
+ #        but WITHOUT ANY WARRANTY; without even the implied warranty of
+ #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ #                 GNU General Public License for more details.
+ #
+ #   You should have received a copy of the GNU General Public License along
+ #      with this program; if not, write to the Free Software Foundation,
+ #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ #
+ #
+ #  Author:
+ #    Reto Grieder
+ #  Description:
+ #    Sets the right compiler and linker flags for the Microsoft Compiler.
+ #
+
+######################## Options ########################
+
+OPTION(ACTIVATE_VISUAL_LEAK_DETECTOR "Memory leak detector" FALSE)
+
+#################### Compiler Flags #####################
+
+# -MD    Minimal Rebuild
+# -RTC1  Both basic runtime checks
+# -MD[d] Multithreaded [debug] DLL
+# -Zi    Program Database
+# -ZI    Program Database for Edit & Continue
+# -WX    General warning Level X
+# -wdX   Disable specific warning X
+# -wnX   Set warning level of specific warning X to level n
+
+# Overwrite CMake default flags first. Be careful with this
+# Only add (not set) the general compiler flags.
+# CMake default flags : -DWIN32 -D_WINDOWS -W3 -Zm1000
+# additionally for CXX: -EHsc -GR
+ADD_COMPILER_FLAGS("-D__WIN32__ -D_WIN32"      CACHE)
+ADD_COMPILER_FLAGS("-D_CRT_SECURE_NO_WARNINGS" CACHE)
+ADD_COMPILER_FLAGS("-DUNICODE -D_UNICODE"      CACHE)
+
+# Overwrite CMake default flags here.
+SET_COMPILER_FLAGS("-MDd -Od -ZI -D_DEBUG -Gm -RTC1" Debug          CACHE)
+SET_COMPILER_FLAGS("-MD  -O2     -DNDEBUG -MP2"      Release        CACHE)
+SET_COMPILER_FLAGS("-MD  -O2 -Zi -DNDEBUG"           RelWithDebInfo CACHE)
+SET_COMPILER_FLAGS("-MD  -O1     -DNDEBUG -MP2"      MinSizeRel     CACHE)
+
+
+####################### Warnings ########################
+
+# Increase warning level if requested
+IF(EXTRA_WARNINGS)
+  REMOVE_COMPILER_FLAGS("-W1 -W2 -W3" CACHE)
+  ADD_COMPILER_FLAGS   ("-W4" CACHE)
+ELSE()
+  REMOVE_COMPILER_FLAGS("-W1 -W2 -W4" CACHE)
+  ADD_COMPILER_FLAGS   ("-W3" CACHE)
+ENDIF()
+
+# "<type> needs to have dll-interface to be used by clients'
+# Happens on STL member variables which are not public
+ADD_COMPILER_FLAGS("-w44251" CACHE)
+
+# Multiple assignment operators specified
+ADD_COMPILER_FLAGS("-w44522" CACHE)
+
+# Forcing values to bool
+ADD_COMPILER_FLAGS("-w44800" CACHE)
+
+# This warns about truncation to 255 characters in debug/browse info
+# ADD_COMPILER_FLAGS("-w44786 -w44503" CACHE)
+
+# conversion from 'double' to 'float', possible loss of data
+# conversion from 'ogg_int64_t' to 'long', possible loss of data
+# ADD_COMPILER_FLAGS("-w44244" CACHE)
+
+# "conversion from 'size_t' to 'unsigned int', possible loss of data
+# ADD_COMPILER_FLAGS("-w44267" CACHE)
+
+# "truncation from 'double' to 'float'
+# ADD_COMPILER_FLAGS("-w44305" CACHE)
+
+# "non dll-interface class used as base for dll-interface class"
+# ADD_COMPILER_FLAGS("-w44275" CACHE)
+
+# "C++ Exception Specification ignored"
+# This is because MSVC 6 did not implement all the C++ exception
+# specifications in the ANSI C++ draft.
+# ADD_COMPILER_FLAGS("-w44290" CACHE)
+
+# "no suitable definition provided for explicit template
+# instantiation request" Occurs in VC7 for no justifiable reason.
+# ADD_COMPILER_FLAGS("-w44661" CACHE)
+
+# Deprecation warnings when using CRT calls in VC8
+# These show up on all C runtime lib code in VC8, disable since they clutter
+# the warnings with things we may not be able to do anything about (e.g.
+# generated code from nvparse etc). I doubt very much that these calls
+# will ever be actually removed from VC anyway, it would break too much code.
+# Note: Probably handled by "-DCRT_SECURE_NO_WARNINGS"
+# ADD_COMPILER_FLAGS("-w44996" CACHE)
+
+# "conditional expression constant"
+# ADD_COMPILER_FLAGS("-w4201" CACHE)
+
+
+##################### Linker Flags ######################
+
+# CMake default flags: -MANIFEST -STACK:10000000 -machine:I386
+# and INCREMENTAL and DEBUG for debug versions
+ADD_LINKER_FLAGS("-OPT:REF -OPT:ICF" Release MinSizeRel CACHE)
+ADD_LINKER_FLAGS("-OPT:NOWIN98" MSVC80 CACHE)
Index: code/branches/buildsystem3/cmake/CheckOGREPlugins.cmake
===================================================================
--- code/branches/buildsystem3/cmake/CheckOGREPlugins.cmake	(revision 2664)
+++ code/branches/buildsystem3/cmake/CheckOGREPlugins.cmake	(revision 2664)
@@ -0,0 +1,116 @@
+ #
+ #             ORXONOX - the hottest 3D action shooter ever to exist
+ #                             > www.orxonox.net <
+ #
+ #        This program is free software; you can redistribute it and/or
+ #         modify it under the terms of the GNU General Public License
+ #        as published by the Free Software Foundation; either version 2
+ #            of the License, or (at your option) any later version.
+ #
+ #       This program is distributed in the hope that it will be useful,
+ #        but WITHOUT ANY WARRANTY; without even the implied warranty of
+ #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ #                 GNU General Public License for more details.
+ #
+ #   You should have received a copy of the GNU General Public License along
+ #      with this program; if not, write to the Free Software Foundation,
+ #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ #
+ #
+ #  Author:
+ #    Reto Grieder
+ #  Description:
+ #    Function that checks each OGRE plugin for existance. Also looks for debug
+ #    versions and sets them accordingly.
+ #    All the plugins specified as function arguments have to be found or the
+ #    script will issue a fatal error. Additionally, all release plugins have
+ #    to be found in the same folder. Analogously for debug plugins.
+ #    Output:
+ #    OGRE_PLUGINS_FOLDER_DEBUG   Folder with the debug plugins
+ #    OGRE_PLUGINS_FOLDER_RELEASE Folder with the release plugins
+ #    OGRE_PLUGINS_DEBUG          Names of the debug plugins without extension
+ #    OGRE_PLUGINS_RELEASE        Names of the release plugins without ext.
+ #
+
+FUNCTION(CHECK_OGRE_PLUGINS)
+
+  SET(OGRE_PLUGINS ${ARGN})
+
+  IF(WIN32)
+    # On Windows we need only *.dll, not *.lib. Especially the MSVC generator doesn't look for *.dll
+    SET(CMAKE_FIND_LIBRARY_SUFFIXES .dll)
+  ENDIF(WIN32)
+  # Do not prefix "lib" on any platform
+  SET(CMAKE_FIND_LIBRARY_PREFIXES "")
+
+  SET(OGRE_RENDER_SYSTEM_FOUND FALSE)
+  FOREACH(_plugin ${OGRE_PLUGINS})
+    FIND_LIBRARY(OGRE_PLUGIN_${_plugin}_OPTIMIZED
+      NAMES ${_plugin}
+      PATHS $ENV{OGRE_HOME} $ENV{OGRE_PLUGIN_DIR}
+      PATH_SUFFIXES bin/Release bin/release Release release lib lib/OGRE bin
+    )
+    FIND_LIBRARY(OGRE_PLUGIN_${_plugin}_DEBUG
+      NAMES ${_plugin}d ${_plugin}_d ${_plugin}
+      PATHS $ENV{OGRE_HOME} $ENV{OGRE_PLUGIN_DIR}
+      PATH_SUFFIXES bin/Debug bin/debug Debug debug lib lib/OGRE bin
+    )
+    # We only need at least one render system. Check at the end.
+    IF(NOT ${_plugin} MATCHES "RenderSystem")
+      IF(NOT OGRE_PLUGIN_${_plugin}_OPTIMIZED)
+        MESSAGE(FATAL_ERROR "Could not find OGRE plugin named ${_plugin}")
+      ENDIF()
+    ELSEIF(OGRE_PLUGIN_${_plugin}_OPTIMIZED)
+      SET(OGRE_RENDER_SYSTEM_FOUND TRUE)
+    ENDIF()
+
+    IF(OGRE_PLUGIN_${_plugin}_OPTIMIZED)
+      # If debug version is not available, release will do as well
+      IF(OGRE_PLUGIN_${_plugin}_DEBUG STREQUAL OGRE_PLUGIN_${_plugin}_OPTIMIZED)
+        # In this case the library finder didn't find real debug versions
+        SET(OGRE_PLUGIN_${_plugin}_DEBUG "OGRE_PLUGIN_${_plugin}_DEBUG-NOTFOUND" CACHE STRING "" FORCE)
+      ENDIF()
+      MARK_AS_ADVANCED(OGRE_PLUGIN_${_plugin}_OPTIMIZED OGRE_PLUGIN_${_plugin}_DEBUG)
+
+      ### Set variables to configure orxonox.ini correctly afterwards in bin/ ###
+      # Check and set the folders
+      GET_FILENAME_COMPONENT(_plugins_folder ${OGRE_PLUGIN_${_plugin}_OPTIMIZED} PATH)
+      IF(OGRE_PLUGINS_FOLDER_RELEASE AND NOT OGRE_PLUGINS_FOLDER_RELEASE STREQUAL _plugins_folder)
+        MESSAGE(FATAL_ERROR "Ogre release plugins have to be in the same folder!")
+      ENDIF()
+      SET(OGRE_PLUGINS_FOLDER_RELEASE ${_plugins_folder})
+      IF(OGRE_PLUGIN_${_plugin}_DEBUG)
+        GET_FILENAME_COMPONENT(_plugins_folder ${OGRE_PLUGIN_${_plugin}_DEBUG} PATH)
+      ENDIF()
+      IF(OGRE_PLUGINS_FOLDER_DEBUG AND NOT OGRE_PLUGINS_FOLDER_DEBUG STREQUAL _plugins_folder)
+        MESSAGE(FATAL_ERROR "Ogre debug plugins have to be in the same folder!")
+      ENDIF()
+      SET(OGRE_PLUGINS_FOLDER_DEBUG ${_plugins_folder})
+
+      # Create a list with the plugins for release and debug configurations
+      LIST(APPEND OGRE_PLUGINS_RELEASE ${_plugin})
+      # Determine debug postfix ("d" or "_d" or none)
+      IF(OGRE_PLUGIN_${_plugin}_DEBUG MATCHES "_d\\.|_d$")
+        LIST(APPEND OGRE_PLUGINS_DEBUG "${_plugin}_d")
+      ELSEIF(OGRE_PLUGIN_${_plugin}_DEBUG MATCHES "d\\.|d$")
+        LIST(APPEND OGRE_PLUGINS_DEBUG "${_plugin}d")
+      ELSE()
+        LIST(APPEND OGRE_PLUGINS_DEBUG "${_plugin}")
+      ENDIF()
+    ENDIF(OGRE_PLUGIN_${_plugin}_OPTIMIZED)
+  ENDFOREACH(_plugin)
+  IF(NOT OGRE_RENDER_SYSTEM_FOUND)
+      MESSAGE(FATAL_ERROR "Could not find an OGRE render system plugin")
+  ENDIF()
+
+  # List has to be comma separated for orxonox.ini
+  STRING(REPLACE ";" ", " OGRE_PLUGINS_RELEASE "${OGRE_PLUGINS_RELEASE}")
+  STRING(REPLACE ";" ", " OGRE_PLUGINS_DEBUG   "${OGRE_PLUGINS_DEBUG}")
+
+  # Set variables outside function scope
+  SET(OGRE_PLUGINS_FOLDER_DEBUG ${OGRE_PLUGINS_FOLDER_DEBUG} PARENT_SCOPE)
+  SET(OGRE_PLUGINS_FOLDER_RELEASE ${OGRE_PLUGINS_FOLDER_RELEASE} PARENT_SCOPE)
+  SET(OGRE_PLUGINS_RELEASE ${OGRE_PLUGINS_RELEASE} PARENT_SCOPE)
+  SET(OGRE_PLUGINS_DEBUG ${OGRE_PLUGINS_DEBUG} PARENT_SCOPE)
+
+ENDFUNCTION(CHECK_OGRE_PLUGINS)
Index: code/branches/buildsystem3/cmake/CheckTardis.cmake
===================================================================
--- code/branches/buildsystem3/cmake/CheckTardis.cmake	(revision 2663)
+++ 	(revision )
@@ -1,31 +1,0 @@
-################# Tardis check ##################
-# This code checks whether the current machine  #
-# is an ETH tardis box.                         #
-#################################################
-
-# only run this test on a lunix/unix machine
-IF (UNIX)
-
-  FIND_PROGRAM(UNAME_CMD "uname"
-  PATHS "/usr/bin /bin")
-  IF(NOT UNAME_CMD)
-    MESSAGE(ERROR "Unable to find uname. Tardis-Check cannot be done.")
-  ENDIF(NOT UNAME_CMD)
-
-  # run uname -n to get nodename
-  EXECUTE_PROCESS(
-  COMMAND "${UNAME_CMD}" "-n"
-  RESULT_VARIABLE UNAME_RV
-  ERROR_VARIABLE UNAME_EV
-  OUTPUT_VARIABLE UNAME_OV)
-
-  IF (NOT "${UNAME_RV}" STREQUAL "0")
-    MESSAGE(ERROR "ERROR: uname terminated unclean.")
-  ENDIF (NOT "${UNAME_RV}" STREQUAL "0")
-
-  # check wheter we are on a tardis machine
-  IF ("${UNAME_OV}" MATCHES "tardis")
-    SET (IS_TARDIS ON)
-  ENDIF ("${UNAME_OV}" MATCHES "tardis")
-
-ENDIF (UNIX)
Index: code/branches/buildsystem3/cmake/CompareVersionStrings.cmake
===================================================================
--- code/branches/buildsystem3/cmake/CompareVersionStrings.cmake	(revision 2664)
+++ code/branches/buildsystem3/cmake/CompareVersionStrings.cmake	(revision 2664)
@@ -0,0 +1,78 @@
+# Computes the relationship between two version strings.  A version
+# string is a number delineated by '.'s such as 1.3.2 and 0.99.9.1.
+# You can feed version strings with different number of dot versions,
+# and the shorter version number will be padded with zeros: 9.2 <
+# 9.2.1 will actually compare 9.2.0 < 9.2.1.
+#
+# Input: a_in - value, not variable
+#        b_in - value, not variable
+#        result_out - variable with value:
+#                         -1 : a_in <  b_in
+#                          0 : a_in == b_in
+#                          1 : a_in >  b_in
+#        optional argument - TRUE or default FALSE:
+#              When passing 1.2.3 and 1.2 and this switch is on
+#              the function will actually compare 1.2 < 1.2
+#              Caution: Only the first string is adjusted!
+#
+# Written by James Bigler.
+# Extended with an optional argument by Reto Grieder
+
+FUNCTION(COMPARE_VERSION_STRINGS a_in b_in result_out)
+  # Additional argument can be a switch to change compare behaviour
+  SET(cut_first ${ARGN})
+
+  # Replace '.' with ';' to allow easy tokenization of the string.
+  STRING(REPLACE "." ";" a ${a_in})
+  STRING(REPLACE "." ";" b ${b_in})
+
+  # Check the size of each list to see if they are equal.
+  LIST(LENGTH a a_length)
+  LIST(LENGTH b b_length)
+
+  # Pad the shorter list with zeros.
+
+  IF(a_length LESS b_length)
+    # a is shorter
+    SET(shorter a)
+    MATH(EXPR pad_range "${b_length} - ${a_length} - 1")
+  ELSE(a_length LESS b_length)
+    # b is shorter
+    SET(shorter b)
+    SET(first_longer a)
+    MATH(EXPR pad_range "${a_length} - ${b_length} - 1")
+  ENDIF(a_length LESS b_length)
+
+  # PAD out if we need to
+  IF(NOT pad_range LESS 0)
+    FOREACH(pad RANGE ${pad_range})
+      # Since shorter is an alias for b, we need to get to it by dereferencing shorter.
+      IF(cut_first AND first_longer)
+        LIST(REMOVE_AT a -1) # remove last element
+      ELSE(cut_first AND first_longer)
+        LIST(APPEND ${shorter} 0)
+      ENDIF(cut_first AND first_longer)
+    ENDFOREACH(pad)
+  ENDIF(NOT pad_range LESS 0)
+
+  SET(result 0)
+  SET(index 0)
+  FOREACH(a_version ${a})
+    IF(result EQUAL 0)
+      # Only continue to compare things as long as they are equal
+      LIST(GET b ${index} b_version)
+      # LESS
+      IF(a_version LESS b_version)
+        SET(result -1)
+      ENDIF(a_version LESS b_version)
+      # GREATER
+      IF(a_version GREATER b_version)
+        SET(result 1)
+      ENDIF(a_version GREATER b_version)
+    ENDIF(result EQUAL 0)
+    MATH(EXPR index "${index} + 1")
+  ENDFOREACH(a_version)
+
+  # Copy out the return result
+  SET(${result_out} ${result} PARENT_SCOPE)
+ENDFUNCTION(COMPARE_VERSION_STRINGS)
Index: code/branches/buildsystem3/cmake/DetermineVersion.cmake
===================================================================
--- code/branches/buildsystem3/cmake/DetermineVersion.cmake	(revision 2664)
+++ code/branches/buildsystem3/cmake/DetermineVersion.cmake	(revision 2664)
@@ -0,0 +1,58 @@
+ #
+ #             ORXONOX - the hottest 3D action shooter ever to exist
+ #                             > www.orxonox.net <
+ #
+ #        This program is free software; you can redistribute it and/or
+ #         modify it under the terms of the GNU General Public License
+ #        as published by the Free Software Foundation; either version 2
+ #            of the License, or (at your option) any later version.
+ #
+ #       This program is distributed in the hope that it will be useful,
+ #        but WITHOUT ANY WARRANTY; without even the implied warranty of
+ #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ #                 GNU General Public License for more details.
+ #
+ #   You should have received a copy of the GNU General Public License along
+ #      with this program; if not, write to the Free Software Foundation,
+ #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ #
+ #
+ #  Author:
+ #    Reto Grieder
+ #  Description:
+ #    Inspects a given file for the following expressions
+ #    "NAME_MAJOR_VERSION #"
+ #    "NAME_MINOR_VERSION #"
+ #    "NAME_PATCH_VERSION #"
+ #    and sets NAME_VERSION accordingly. NAME_PART_VERSION variables are also
+ #    set. If you wish to look for different parts (e.g. "first" "second", etc.)
+ #    simply deliver them as additional arguments (have to be three though).
+ #
+
+FUNCTION(DETERMINE_VERSION _name _file)
+  IF(EXISTS ${_file})
+    FILE(READ ${_file} _file_content)
+    SET(_parts ${ARGN})
+    LIST(LENGTH _parts _parts_length)
+    IF(NOT ${_parts_length} EQUAL 3)
+      SET(_parts MAJOR MINOR PATCH)
+    ENDIF()
+
+    FOREACH(_part ${_parts})
+      STRING(REGEX MATCH "${_name}_VERSION_${_part} +([0-9]+)" _match ${_file_content})
+      IF(_match)
+        SET(${_name}_VERSION_${_part} ${CMAKE_MATCH_1})
+        SET(${_name}_VERSION_${_part} ${CMAKE_MATCH_1} PARENT_SCOPE)
+      ELSE()
+        SET(${_name}_VERSION_${_part} "0")
+        SET(${_name}_VERSION_${_part} "0" PARENT_SCOPE)
+      ENDIF()
+      IF("${_parts}" MATCHES "^${_part}") # First?
+        SET(${_name}_VERSION "${${_name}_VERSION_${_part}}")
+      ELSE()
+        SET(${_name}_VERSION "${${_name}_VERSION}.${${_name}_VERSION_${_part}}")
+      ENDIF()
+    ENDFOREACH(_part)
+    SET(${_name}_VERSION "${${_name}_VERSION}" PARENT_SCOPE)
+  ENDIF(EXISTS ${_file})
+ENDFUNCTION(DETERMINE_VERSION)
Index: code/branches/buildsystem3/cmake/FindALUT.cmake
===================================================================
--- code/branches/buildsystem3/cmake/FindALUT.cmake	(revision 2663)
+++ code/branches/buildsystem3/cmake/FindALUT.cmake	(revision 2664)
@@ -2,5 +2,5 @@
 # This module defines
 #  ALUT_LIBRARY
-#  ALUT_FOUND, if false, do not try to link to Alut
+#  ALUT_FOUND, if false, do not try to link against Alut
 #  ALUT_INCLUDE_DIR, where to find the headers
 #
@@ -18,37 +18,18 @@
 #
 # Several changes and additions by Fabian 'x3n' Landau
+# Some simplifications by Adrian Friedli and Reto Grieder
 #                 > www.orxonox.net <
 
-IF (ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
-  SET (ALUT_FIND_QUIETLY TRUE)
-ENDIF (ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
+INCLUDE(FindPackageHandleStandardArgs)
+INCLUDE(HandleLibraryTypes)
 
 FIND_PATH(ALUT_INCLUDE_DIR AL/alut.h
-  $ENV{ALUTDIR}/include
-  ~/Library/Frameworks/OpenAL.framework/Headers
-  /Library/Frameworks/OpenAL.framework/Headers
-  /System/Library/Frameworks/OpenAL.framework/Headers # Tiger
-  /usr/pack/openal-0.0.8-cl/include # Tardis specific hack
-  /usr/local/include/
-  /usr/local/include/OpenAL
-  /usr/local/include
-  /usr/include/
-  /usr/include/OpenAL
-  /usr/include
-  /sw/include/ # Fink
-  /sw/include/OpenAL
-  /sw/include
-  /opt/local/include/AL # DarwinPorts
-  /opt/local/include/OpenAL
-  /opt/local/include
-  /opt/csw/include/ # Blastwave
-  /opt/csw/include/OpenAL
-  /opt/csw/include
-  /opt/include/
-  /opt/include/OpenAL
-  /opt/include
-  ../libs/freealut-1.1.0/include
-  ${DEPENDENCY_DIR}/freealut-1.1.0/include
-  )
+  PATHS
+  $ENV{ALUTDIR}
+  ~/Library/Frameworks/OpenAL.framework
+  /Library/Frameworks/OpenAL.framework
+  /System/Library/Frameworks/OpenAL.framework # Tiger
+  PATH_SUFFIXES include include/OpenAL include/AL Headers
+)
 
 # I'm not sure if I should do a special casing for Apple. It is
@@ -57,4 +38,5 @@
 # do they want the -framework option also?
 IF(${ALUT_INCLUDE_DIR} MATCHES ".framework")
+
   STRING(REGEX REPLACE "(.*)/.*\\.framework/.*" "\\1" ALUT_FRAMEWORK_PATH_TMP ${ALUT_INCLUDE_DIR})
   IF("${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
@@ -62,54 +44,37 @@
       )
     # String is in default search path, don't need to use -F
-    SET (ALUT_LIBRARY "-framework OpenAL" CACHE STRING "OpenAL framework for OSX")
-  ELSE("${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
-      OR "${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
-      )
+    SET (ALUT_LIBRARY_OPTIMIZED "-framework OpenAL" CACHE STRING "OpenAL framework for OSX")
+  ELSE()
     # String is not /Library/Frameworks, need to use -F
-    SET(ALUT_LIBRARY "-F${ALUT_FRAMEWORK_PATH_TMP} -framework OpenAL" CACHE STRING "OpenAL framework for OSX")
-  ENDIF("${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
-    OR "${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
-    )
+    SET(ALUT_LIBRARY_OPTIMIZED "-F${ALUT_FRAMEWORK_PATH_TMP} -framework OpenAL" CACHE STRING "OpenAL framework for OSX")
+  ENDIF()
   # Clear the temp variable so nobody can see it
   SET(ALUT_FRAMEWORK_PATH_TMP "" CACHE INTERNAL "")
 
-ELSE(${ALUT_INCLUDE_DIR} MATCHES ".framework")
-  FIND_LIBRARY(ALUT_LIBRARY
+ELSE()
+  FIND_LIBRARY(ALUT_LIBRARY_OPTIMIZED
     NAMES alut
-    PATHS
-    $ENV{ALUTDIR}/lib
-    $ENV{ALUTDIR}/libs
-    /usr/pack/openal-0.0.8-cl/i686-debian-linux3.1/lib
-    /usr/local/lib
-    /usr/lib
-    /sw/lib
-    /opt/local/lib
-    /opt/csw/lib
-    /opt/lib
-    ../libs/freealut-1.1.0/src/.libs
-    ../libs/freealut-1.1.0/lib
-    ${DEPENDENCY_DIR}/freealut-1.1.0/lib
-    )
-ENDIF(${ALUT_INCLUDE_DIR} MATCHES ".framework")
+    PATHS $ENV{ALUTDIR}
+    PATH_SUFFIXES lib libs
+  )
+  FIND_LIBRARY(ALUT_LIBRARY_DEBUG
+    NAMES alutd alut_d alutD alut_D
+    PATHS $ENV{ALUTDIR}
+    PATH_SUFFIXES lib libs
+  )
+ENDIF()
 
-SET (ALUT_FOUND "NO")
-IF (ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
-  SET (ALUT_FOUND "YES")
-  IF (NOT ALUT_FIND_QUIETLY)
-    MESSAGE (STATUS "FreeAlut was found.")
-    IF (VERBOSE_FIND)
-      MESSAGE (STATUS "  include path: ${ALUT_INCLUDE_DIR}")
-      MESSAGE (STATUS "  library path: ${ALUT_LIBRARY}")
-      MESSAGE (STATUS "  libraries:    alut")
-    ENDIF (VERBOSE_FIND)
-  ENDIF (NOT ALUT_FIND_QUIETLY)
-ELSE (ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
-  IF (NOT ALUT_INCLUDE_DIR)
-    MESSAGE (SEND_ERROR "FreeAlut include path was not found.")
-  ENDIF (NOT ALUT_INCLUDE_DIR)
-  IF (NOT ALUT_LIBRARY)
-    MESSAGE (SEND_ERROR "FreeAlut library was not found.")
-  ENDIF (NOT ALUT_LIBRARY)
-ENDIF (ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
+# Handle the REQUIRED argument and set ALUT_FOUND
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(ALUT DEFAULT_MSG
+    ALUT_LIBRARY_OPTIMIZED
+    ALUT_INCLUDE_DIR
+)
 
+# Collect optimized and debug libraries
+HANDLE_LIBRARY_TYPES(ALUT)
 
+MARK_AS_ADVANCED(
+    ALUT_INCLUDE_DIR
+    ALUT_LIBRARY_OPTIMIZED
+    ALUT_LIBRARY_DEBUG
+)
Index: code/branches/buildsystem3/cmake/FindBoost.cmake
===================================================================
--- code/branches/buildsystem3/cmake/FindBoost.cmake	(revision 2663)
+++ 	(revision )
@@ -1,316 +1,0 @@
-# THIS FILE HAS BEEN MODIFIED TO WORK ON THE TARDIS INFRASTURUCTURE of THE ETH.
-# use with caution
-# Nicolas Schlumberger <nico AT orxonx DOT net> (C) 2007
-#
-# Several changes and additions by Fabian 'x3n' Landau
-#                 > www.orxonox.net <
-#
-# - Find the Boost includes and libraries.
-# The following variables are set if Boost is found.  If Boost is not
-# found, Boost_FOUND is set to false.
-#  Boost_FOUND                  - True when the Boost include directory is found.
-#  Boost_INCLUDE_DIRS           - the path to where the boost include files are.
-#  Boost_LIBRARY_DIRS           - The path to where the boost library files are.
-#  Boost_LIB_DIAGNOSTIC_DEFINITIONS - Only set if using Windows.
-#  Boost_<library>_FOUND        - True if the Boost <library> is found.
-#  Boost_<library>_INCLUDE_DIRS - The include path for Boost <library>.
-#  Boost_<library>_LIBRARIES    - The libraries to link to to use Boost <library>.
-#  Boost_LIBRARIES              - The libraries to link to to use all Boost libraries.
-#
-# The following variables can be set to configure how Boost is found:
-#  Boost_LIB_PREFIX             - Look for Boost libraries prefixed with this, e.g. "lib"
-#  Boost_LIB_SUFFIX             - Look for Boost libraries ending with this, e.g. "vc80-mt"
-#  Boost_LIB_SUFFIX_DEBUG       - As for Boost_LIB_SUFFIX but for debug builds, e.g. "vs80-mt-gd"
-
-# ----------------------------------------------------------------------------
-# If you have installed Boost in a non-standard location or you have
-# just staged the boost files using bjam then you have three
-# options. In the following comments, it is assumed that <Your Path>
-# points to the root directory of the include directory of Boost. e.g
-# If you have put boost in C:\development\Boost then <Your Path> is
-# "C:/development/Boost" and in this directory there will be two
-# directories called "include" and "lib".
-# 1) After CMake runs, set Boost_INCLUDE_DIR to <Your Path>/include/boost<-version>
-# 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/include. This will allow FIND_PATH()
-#    to locate Boost_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g.
-#    SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "<Your Path>/include")
-# 3) Set an environment variable called ${BOOST_ROOT} that points to the root of where you have
-#    installed Boost, e.g. <Your Path>. It is assumed that there is at least a subdirectory called
-#    include in this path.
-#
-# Note:
-#  1) If you are just using the boost headers, then you do not need to use
-#     Boost_LIBRARY_DIRS in your CMakeLists.txt file.
-#  2) If Boost has not been installed, then when setting Boost_LIBRARY_DIRS
-#     the script will look for /lib first and, if this fails, then for /stage/lib.
-#
-# Usage:
-# In your CMakeLists.txt file do something like this:
-# ...
-# # Boost
-# FIND_PACKAGE(Boost)
-# ...
-# INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
-# LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
-
-#
-# TODO:
-#
-# 1) Automatically find the Boost library files and eliminate the need
-#    to use Link Directories.
-#
-
-IF (Boost_INCLUDE_DIR)
-  SET (Boost_INCLUDE_FIND_QUIETLY TRUE)
-ENDIF (Boost_INCLUDE_DIR)
-
-IF(WIN32)
-# In windows, automatic linking is performed, so you do not have to specify the libraries.
-# If you are linking to a dynamic runtime, then you can choose to link to either a static or a
-# dynamic Boost library, the default is to do a static link.  You can alter this for a specific
-# library "whatever" by defining BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to
-# be linked dynamically.  Alternatively you can force all Boost libraries to dynamic link by
-# defining BOOST_ALL_DYN_LINK.
-
-# This feature can be disabled for Boost library "whatever" by defining BOOST_WHATEVER_NO_LIB,
-# or for all of Boost by defining BOOST_ALL_NO_LIB.
-
-# If you want to observe which libraries are being linked against then defining
-# BOOST_LIB_DIAGNOSTIC will cause the auto-linking code to emit a #pragma message each time
-# a library is selected for linking.
-#  SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC")
-#  SET(Boost_LIB_PREFIX "lib")
-#  SET(Boost_LIB_SUFFIX "gcc-mt-1_33_1.lib")
-ENDIF(WIN32)
-
-
-SET(BOOST_INCLUDE_PATH_DESCRIPTION "directory containing the boost include files.")
-
-SET(BOOST_DIR_MESSAGE "Set the Boost_INCLUDE_DIR cmake cache entry to the ${BOOST_INCLUDE_PATH_DESCRIPTION}")
-
-SET(BOOST_DIR_SEARCH $ENV{BOOST_ROOT})
-IF(BOOST_DIR_SEARCH)
-  FILE(TO_CMAKE_PATH ${BOOST_DIR_SEARCH} BOOST_DIR_SEARCH)
-  SET(BOOST_DIR_SEARCH ${BOOST_DIR_SEARCH}/include)
-ENDIF(BOOST_DIR_SEARCH)
-
-# Add in some path suffixes. These will have to be updated whenever a new Boost version comes out.
-SET(SUFFIX_FOR_PATH
- boost
- boost-1_35_0
- boost-1_35
- boost-1_34_1
- boost-1_34_0
- boost-1_34
- boost-1_33_1
- boost-1_33_0
-)
-
-#
-# Look for an installation.
-#
-FIND_PATH(Boost_INCLUDE_DIR NAMES boost/config.hpp PATH_SUFFIXES ${SUFFIX_FOR_PATH} PATHS
-
-# Look in other places.
-  ${BOOST_DIR_SEARCH}
-
-#    ../libs/boost_1_33_1
-    ../libs/boost_1_34_1
-#    ../libs/boost-1_35_0
-    ${DEPENDENCY_DIR}/boost-1.35.0/include
-
-# Help the user find it if we cannot.
-  DOC "The ${BOOST_INCLUDE_PATH_DESCRIPTION}"
-)
-
-# Assume we didn't find it.
-SET(Boost_FOUND 0)
-
-# Now try to get the include and library path.
-IF(Boost_INCLUDE_DIR)
-
-# Look for the boost library path.
-# Note that the user may not have installed any libraries
-# so it is quite possible the Boost_LIBRARY_PATH may not exist.
-  SET(Boost_LIBRARY_DIR ${Boost_INCLUDE_DIR})
-
-  IF("${Boost_LIBRARY_DIR}" MATCHES "boost-[0-9]+")
-    GET_FILENAME_COMPONENT(Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR} PATH)
-  ENDIF ("${Boost_LIBRARY_DIR}" MATCHES "boost-[0-9]+")
-
-  IF("${Boost_LIBRARY_DIR}" MATCHES "/include$")
-# Strip off the trailing "/include" in the path.
-    GET_FILENAME_COMPONENT(Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR} PATH)
-  ENDIF("${Boost_LIBRARY_DIR}" MATCHES "/include$")
-
-  IF(EXISTS "${Boost_LIBRARY_DIR}/lib")
-    SET (Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR}/lib)
-  ELSEIF(EXISTS "${Boost_LIBRARY_DIR}/bin/boost/libs/thread/build/boost_thread.dll/gcc/release/threading-multi")
-    SET (Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR}/bin/boost/libs/thread/build/boost_thread.dll/gcc/release/threading-multi)
-  ELSE(EXISTS "${Boost_LIBRARY_DIR}/lib")
-    IF(EXISTS "${Boost_LIBRARY_DIR}/stage/lib")
-      SET(Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR}/stage/lib)
-    ELSE(EXISTS "${Boost_LIBRARY_DIR}/stage/lib")
-      IF(EXISTS "${Boost_LIBRARY_DIR}/../../lib")
-        SET(Boost_LIBRARY_DIR "${Boost_LIBRARY_DIR}/../../lib")
-      ELSE(EXISTS "${Boost_LIBRARY_DIR}/../../lib")
-        SET(Boost_LIBRARY_DIR "")
-      ENDIF(EXISTS "${Boost_LIBRARY_DIR}/../../lib")
-    ENDIF(EXISTS "${Boost_LIBRARY_DIR}/stage/lib")
-  ENDIF(EXISTS "${Boost_LIBRARY_DIR}/lib")
-
-
-  IF(EXISTS "${Boost_INCLUDE_DIR}")
-    SET(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
-# We have found boost. It is possible that the user has not
-# compiled any libraries so we set Boost_FOUND to be true here.
-    SET(Boost_FOUND 1)
-    MARK_AS_ADVANCED(Boost_INCLUDE_DIR)
-  ENDIF(EXISTS "${Boost_INCLUDE_DIR}")
-  IF(Boost_LIBRARY_DIR AND EXISTS "${Boost_LIBRARY_DIR}")
-    SET(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIR})
-  ENDIF(Boost_LIBRARY_DIR AND EXISTS "${Boost_LIBRARY_DIR}")
-ENDIF(Boost_INCLUDE_DIR)
-
-
-#
-# Find boost libraries
-#
-
-# List of library suffixes to search, e.g. libboost_date_time-gcc
-SET(BOOST_SUFFIX_SEARCH
-  mt
-  gcc41-mt
-  gcc
-  il
-  gcc-1_33_1
-  gcc-mt-1_33_1
-  mgw34-mt-1_34_1
-  mgw34-mt-1_35
-  vc80-mt-1_35
-  vc80-mt-gd-1_35
-)
-
-# List of all boost libraries
-SET(BOOST_ALL_LIBRARIES
-  date_time
-  filesystem
-  graph
-  iostreams
-  program_options
-  regex
-  serialization
-  signals
-  unit_test_framework
-  thread
-  wave
-)
-
-# Macro to find boost library called name
-MACRO(BOOST_FIND_LIBRARY name)
-
-# User can specify a particular build variant via the variables:
-#   Boost_LIB_PREFIX, Boost_LIB_SUFFIX, Boost_LIB_SUFFIX_DEBUG
-# otherwise we'll search the BOOST_SUFFIX_SEARCH list
-
-  SET(BOOST_LIB_NAMES ${Boost_LIB_PREFIX}boost_${name}-${Boost_LIB_SUFFIX})
-  IF(NOT Boost_LIB_SUFFIX)
-    FOREACH(suffix ${BOOST_SUFFIX_SEARCH})
-      SET(BOOST_LIB_NAMES ${BOOST_LIB_NAMES} ${Boost_LIB_PREFIX}boost_${name}-${suffix})
-    ENDFOREACH(suffix)
-  ENDIF(NOT Boost_LIB_SUFFIX)
-
-# Find the library in the Boost_LIBRARY_DIRS
-  FIND_LIBRARY(Boost_${name}_LIBRARY
-    NAMES ${BOOST_LIB_NAMES}
-    PATHS ${Boost_LIBRARY_DIRS})
-
-# For MSVC builds find debug library
-  IF(WIN32 AND MSVC AND Boost_${name}_LIBRARY)
-    FIND_LIBRARY(Boost_${name}_LIBRARY_DEBUG
-      NAMES ${Boost_LIB_PREFIX}boost_${name}-${Boost_LIB_SUFFIX_DEBUG}
-      PATHS ${Boost_LIBRARY_DIRS})
-
-    IF(MSVC_IDE)
-      IF(Boost_${name}_LIBRARY AND Boost_${name}_LIBRARY_DEBUG)
-        SET(Boost_${name}_LIBRARIES debug ${Boost_${name}_LIBRARY_DEBUG} optimized ${Boost_${name}_LIBRARY})
-      ELSE(Boost_${name}_LIBRARY AND Boost_${name}_LIBRARY_DEBUG)
-        MESSAGE(FATAL_ERROR "Could not find the debug and release version of Boost ${name} library.")
-      ENDIF(Boost_${name}_LIBRARY AND Boost_${name}_LIBRARY_DEBUG)
-    ELSE(MSVC_IDE)
-      STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
-      IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
-        SET(Boost_${name}_LIBRARIES ${Boost_${name}_LIBRARY_DEBUG})
-      ELSE(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
-        SET(Boost_${name}_LIBRARIES ${Boost_${name}_LIBRARY})
-      ENDIF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
-    ENDIF(MSVC_IDE)
-  ELSE(WIN32 AND MSVC AND Boost_${name}_LIBRARY)
-    SET(Boost_${name}_LIBRARIES ${Boost_${name}_LIBRARY})
-  ENDIF(WIN32 AND MSVC AND Boost_${name}_LIBRARY)
-
-# If we've got it setup appropriate variables or issue error message
-  IF(Boost_${name}_LIBRARY)
-    SET(Boost_${name}_FOUND 1)
-    SET(Boost_${name}_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
-    MARK_AS_ADVANCED(Boost_${name}_LIBRARY Boost_${name}_LIBRARY_DEBUG)
-  ELSE(Boost_${name}_LIBRARY)
-    IF(NOT Boost_FIND_QUIETLY)
-      MESSAGE(SEND_ERROR "Boost ${name} library was not found.")
-    ELSE(NOT Boost_FIND_QUIETLY)
-      IF(Boost_FIND_REQUIRED_${name})
-        MESSAGE(FATAL_ERROR "Could NOT find required Boost ${name} library.")
-      ENDIF(Boost_FIND_REQUIRED_${name})
-    ENDIF(NOT Boost_FIND_QUIETLY)
-  ENDIF(Boost_${name}_LIBRARY)
-ENDMACRO(BOOST_FIND_LIBRARY)
-
-IF(Boost_LIBRARY_DIRS)
-
-# If the user specified required components e.g. via
-# FIND_PACKAGE(Boost REQUIRED date_time regex)
-# find (just) those libraries. Otherwise find all libraries.
-  IF(Boost_FIND_COMPONENTS)
-    SET(Boost_FIND_LIBRARIES ${Boost_FIND_COMPONENTS})
-  ELSE(Boost_FIND_COMPONENTS)
-    SET(Boost_FIND_LIBRARIES ${BOOST_ALL_LIBRARIES})
-  ENDIF(Boost_FIND_COMPONENTS)
-
-  SET(Boost_LIBRARIES)
-  FOREACH(library ${Boost_FIND_LIBRARIES})
-    IF (Boost_${library}_LIBRARY)
-      SET (Boost_${name}_LIBRARY_FIND_QUIETLY TRUE)
-    ENDIF (Boost_${library}_LIBRARY)
-
-    BOOST_FIND_LIBRARY(${library})
-    IF(Boost_${library}_FOUND)
-      SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${library}_LIBRARIES})
-      IF (NOT Boost_${name}_LIBRARY_FIND_QUIETLY)
-        MESSAGE(STATUS "Found BoostLibrary: ${library}")
-        IF (VERBOSE_FIND)
-          MESSAGE (STATUS "  library path: ${Boost_${library}_LIBRARIES}")
-        ENDIF (VERBOSE_FIND)
-      ENDIF (NOT Boost_${name}_LIBRARY_FIND_QUIETLY)
-    ENDIF(Boost_${library}_FOUND)
-  ENDFOREACH(library)
-ELSE(Boost_LIBRARY_DIRS)
-  MESSAGE(SEND_ERROR "Boost libraries not found: ${Boost_FIND_COMPONENTS}")
-ENDIF(Boost_LIBRARY_DIRS)
-
-IF(NOT Boost_FOUND)
-  IF(NOT Boost_FIND_QUIETLY)
-    MESSAGE(SEND_ERROR "Boost was not found. ${BOOST_DIR_MESSAGE}")
-  ELSE(NOT Boost_FIND_QUIETLY)
-    IF(Boost_FIND_REQUIRED)
-      MESSAGE(SEND_ERROR "Boost was not found. ${BOOST_DIR_MESSAGE}")
-    ENDIF(Boost_FIND_REQUIRED)
-  ENDIF(NOT Boost_FIND_QUIETLY)
-ELSE(NOT Boost_FOUND)
-  IF (NOT Boost_INCLUDE_FIND_QUIETLY)
-    MESSAGE(STATUS "Boost include path was found.")
-    IF (VERBOSE_FIND)
-      MESSAGE (STATUS "  include path: ${Boost_INCLUDE_DIR}")
-    ENDIF (VERBOSE_FIND)
-  ENDIF (NOT Boost_INCLUDE_FIND_QUIETLY)
-ENDIF(NOT Boost_FOUND)
-
Index: code/branches/buildsystem3/cmake/FindCEGUI.cmake
===================================================================
--- code/branches/buildsystem3/cmake/FindCEGUI.cmake	(revision 2663)
+++ code/branches/buildsystem3/cmake/FindCEGUI.cmake	(revision 2664)
@@ -3,7 +3,15 @@
 # This module defines
 #  CEGUI_INCLUDE_DIR
-#  CEGUI_LIBRARIES, the libraries to link against to use CEGUI.
-#  CEGUI_LIB_DIR, the location of the libraries
+#  CEGUI_LIBRARY, the library to link against to use CEGUI.
 #  CEGUI_FOUND, If false, do not try to use CEGUI
+#  CEGUI_VERSION, the version as string "x.y.z"
+#  CEGUILUA_LIBRARY, Script module library
+#  CEGUILUA_USE_INTERNAL_LIBRARY, True if CEGUILUA_LIBRARY was not defined here
+#
+# Input:
+#  ENV{CEGUIDIR}, CEGUI path, optional
+#  FIND CEGUILUA_INTERNAL_SUPPORT, List of all CEGUILua version supported
+#                                  in the source repository
+#  CEGUILUA_USE_EXTERNAL_LIBRARY, Force finding of CEGUILua
 #
 # Created by Matt Williams to find OGRE libraries
@@ -17,97 +25,79 @@
 #
 # Several changes and additions by Fabian 'x3n' Landau
+# Lots of simplifications by Adrian Friedli and Reto Grieder
+# Version checking and CEGUILua finding by Reto Grieder
 #                 > www.orxonox.net <
 
-IF (CEGUI_LIBRARIES AND CEGUI_INCLUDE_DIR AND CEGUI_LIB_DIR)# AND CEGUI_SCRIPT_LIBRARIES)
-    SET(CEGUI_FIND_QUIETLY TRUE) # Already in cache, be silent
-ENDIF (CEGUI_LIBRARIES AND CEGUI_INCLUDE_DIR AND CEGUI_LIB_DIR)# AND CEGUI_SCRIPT_LIBRARIES)
+INCLUDE(DetermineVersion)
+INCLUDE(FindPackageHandleAdvancedArgs)
+INCLUDE(HandleLibraryTypes)
 
-IF (WIN32) #Windows
-    FIND_PATH(CEGUI_INCLUDE_DIR CEGUI.h
-        ../libs/cegui-0.6.1/include
-        ${DEPENDENCY_DIR}/cegui-0.6.1/include
-    )
+FIND_PATH(CEGUI_INCLUDE_DIR CEGUI.h
+  PATHS $ENV{CEGUIDIR}
+  PATH_SUFFIXES include include/CEGUI CEGUI.framework/Headers
+)
+FIND_LIBRARY(CEGUI_LIBRARY_OPTIMIZED
+  NAMES CEGUIBase CEGUI
+  PATHS $ENV{CEGUIDIR}
+  PATH_SUFFIXES lib bin
+)
+FIND_LIBRARY(CEGUI_LIBRARY_DEBUG
+  NAMES
+    CEGUIBased CEGUIBase_d CEGUIBaseD CEGUIBase_D
+    CEGUId CEGUI_d CEGUID CEGUI_D
+  PATHS $ENV{CEGUIDIR}
+  PATH_SUFFIXES lib bin
+)
 
-    SET(CEGUI_LIBRARIES debug CEGUIBase_d optimized CEGUIBase)
-    FIND_LIBRARY(CEGUI_LIBDIR NAMES ${CEGUI_LIBRARIES} PATHS
-        ../libs/cegui-0.6.1/bin
-        ${DEPENDENCY_DIR}/cegui-0.6.1/lib
-    )
+# Inspect CEGUIVersion.h for the version number
+DETERMINE_VERSION(CEGUI ${CEGUI_INCLUDE_DIR}/CEGUIVersion.h)
 
-    # Strip the filename from the path
-    IF (CEGUI_LIBDIR)
-        GET_FILENAME_COMPONENT(CEGUI_LIBDIR ${CEGUI_LIBDIR} PATH)
-        SET (CEGUI_LIB_DIR ${CEGUI_LIBDIR} CACHE FILEPATH "")
-    ENDIF (CEGUI_LIBDIR)
+# 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_LIBRARY_OPTIMIZED
+  CEGUI_INCLUDE_DIR
+)
 
-#    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)
+# Collect optimized and debug libraries
+HANDLE_LIBRARY_TYPES(CEGUI)
 
-#    # Strip the filename from the path
-#    IF (CEGUI_SCRIPT_LIBDIR)
-#        GET_FILENAME_COMPONENT(CEGUI_SCRIPT_LIBDIR ${CEGUI_SCRIPT_LIBDIR} PATH)
-#        SET (CEGUI_SCRIPT_LIB_DIR ${CEGUI_SCRIPT_LIBDIR} CACHE FILEPATH "")
-#    ENDIF (CEGUI_SCRIPT_LIBDIR)
+MARK_AS_ADVANCED(
+  CEGUI_INCLUDE_DIR
+  CEGUI_LIBRARY_OPTIMIZED
+  CEGUI_LIBRARY_DEBUG
+)
 
-ELSE (WIN32) #Unix
-    FIND_PACKAGE(PkgConfig)
-    PKG_SEARCH_MODULE(CEGUI CEGUI /usr/pack/cegui-0.5.0-sd/i686-debian-linux3.1/lib/pkgconfig/CEGUI.pc) # tardis specific hack
-    SET(CEGUI_INCLUDE_DIR ${CEGUI_INCLUDE_DIRS})
-    SET(CEGUI_LIB_DIR ${CEGUI_LIBDIR})
-    SET(CEGUI_LIBRARIES ${CEGUI_LIBRARIES} CACHE STRING "")
-#    SET(CEGUI_SCRIPT_LIBRARIES "CEGUILuaScriptModule")
-#    SET(CEGUI_SCRIPT_LIB_DIR)
-ENDIF (WIN32)
+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
+  )
 
-IF (CEGUI_INCLUDE_DIR AND CEGUI_LIBRARIES AND CEGUI_LIB_DIR)# AND CEGUI_SCRIPT_LIBRARIES)
-    SET(CEGUI_FOUND TRUE)
+  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
+  )
 
-    #Do some preparation
-    SEPARATE_ARGUMENTS(CEGUI_INCLUDE_DIR)
-    SEPARATE_ARGUMENTS(CEGUI_LIBRARIES)
+  # Collect optimized and debug libraries
+  HANDLE_LIBRARY_TYPES(CEGUILUA)
 
-    SET(CEGUI_INCLUDE_DIR ${CEGUI_INCLUDE_DIR} CACHE PATH "")
-    SET(CEGUI_LIBRARIES ${CEGUI_LIBRARIES} CACHE STRING "")
-    SET(CEGUI_LIB_DIR ${CEGUI_LIB_DIR} CACHE PATH "")
-#    SET(CEGUI_SCRIPT_LIBRARIES ${CEGUI_SCRIPT_LIBRARIES} CACHE PATH "")
-ENDIF (CEGUI_INCLUDE_DIR AND CEGUI_LIBRARIES AND CEGUI_LIB_DIR)# AND CEGUI_SCRIPT_LIBRARIES)
+  MARK_AS_ADVANCED(
+    CEGUILUA_LIBRARY_OPTIMIZED
+    CEGUILUA_LIBRARY_DEBUG
+  )
 
-IF (CEGUI_FOUND)
-    IF (NOT CEGUI_FIND_QUIETLY)
-        MESSAGE(STATUS "CEGUI was found.")
-        IF (VERBOSE_FIND)
-            MESSAGE (STATUS "  include path: ${CEGUI_INCLUDE_DIR}")
-            MESSAGE (STATUS "  library path: ${CEGUI_LIB_DIR}")
-            MESSAGE (STATUS "  libraries:    ${CEGUI_LIBRARIES}")
-#            MESSAGE (STATUS "           :    ${CEGUI_SCRIPT_LIBRARIES}")
-        ENDIF (VERBOSE_FIND)
-    ENDIF (NOT CEGUI_FIND_QUIETLY)
-ELSE (CEGUI_FOUND)
-    IF (NOT CEGUI_INCLUDE_DIR)
-        MESSAGE(SEND_ERROR "CEGUI include path was not found.")
-    ENDIF (NOT CEGUI_INCLUDE_DIR)
-    IF (NOT CEGUI_LIB_DIR)
-        MESSAGE(SEND_ERROR "CEGUI library was not found.")
-    ENDIF (NOT CEGUI_LIB_DIR)
-    IF (NOT CEGUI_LIBRARIES)
-        MESSAGE(SEND_ERROR "CEGUI libraries not known.")
-    ENDIF (NOT CEGUI_LIBRARIES)
-#    IF (NOT CEGUI_SCRIPT_LIBRARIES)
-#        MESSAGE(SEND_ERROR "CEGUI Lua script module was not found.")
-#    ENDIF (NOT CEGUI_SCRIPT_LIBRARIES)
-ENDIF (CEGUI_FOUND)
+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/buildsystem3/cmake/FindCEGUI_OGRE.cmake
===================================================================
--- code/branches/buildsystem3/cmake/FindCEGUI_OGRE.cmake	(revision 2663)
+++ 	(revision )
@@ -1,69 +1,0 @@
-# Find CEGUI_OGRE includes and library
-#
-# This module defines
-#  CEGUI_OGRE_INCLUDE_DIR
-#  CEGUI_OGRE_LIBRARIES, the libraries to link against to use CEGUI_OGRE.
-#  CEGUI_OGRE_LIB_DIR, the location of the libraries
-#  CEGUI_OGRE_FOUND, If false, do not try to use CEGUI_OGRE
-#
-# Created by Matt Williams to find OGRE libraries
-# Copyright © 2007, Matt Williams
-#
-# Modified by Nicolas Schlumberger to find CEGUI-OGRE libraries
-# and make it run on the Tardis-Infrastucture of the ETH Zurich
-# Copyright 2007, Nicolas Schlumberger
-#
-# Redistribution and use is allowed according to the terms of the BSD license.
-#
-# Several changes and additions by Fabian 'x3n' Landau
-#                 > www.orxonox.net <
-
-IF (CEGUI_OGRE_LIBRARIES AND CEGUI_OGRE_INCLUDE_DIR AND CEGUI_OGRE_LIB_DIR)
-    SET(CEGUI_OGRE_FIND_QUIETLY TRUE) # Already in cache, be silent
-ENDIF (CEGUI_OGRE_LIBRARIES AND CEGUI_OGRE_INCLUDE_DIR AND CEGUI_OGRE_LIB_DIR)
-
-IF (WIN32) #Windows
-    MESSAGE(STATUS "Looking for CEGUI_OGRE")
-    SET(CEGUI_OGRE_INCLUDE_DIR ../libs/ogre/Samples/Common/CEGUIRenderer/include)
-    SET(CEGUI_OGRE_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../libs/ogre/Samples/Common/bin/Release/lib)
-    SET(CEGUI_OGRE_LIBRARIES debug OgreGUIRenderer_d optimized OgreGUIRenderer)
-ELSE (WIN32) #Unix
-    FIND_PACKAGE(PkgConfig)
-    PKG_SEARCH_MODULE(CEGUI_OGRE CEGUI-OGRE /usr/pack/ogre-1.4.5-sd/i686-debian-linux3.1/lib/pkgconfig/CEGUI-OGRE.pc) # tardis specific hack
-    SET(CEGUI_OGRE_INCLUDE_DIR ${CEGUI_OGRE_INCLUDE_DIRS})
-    SET(CEGUI_OGRE_LIB_DIR ${CEGUI_OGRE_LIBDIR})
-    SET(CEGUI_OGRE_LIBRARIES ${CEGUI_OGRE_LIBRARIES} CACHE STRING "")
-ENDIF (WIN32)
-
-#Do some preparation
-SEPARATE_ARGUMENTS(CEGUI_OGRE_INCLUDE_DIR)
-SEPARATE_ARGUMENTS(CEGUI_OGRE_LIBRARIES)
-
-SET(CEGUI_OGRE_INCLUDE_DIR ${CEGUI_OGRE_INCLUDE_DIR} CACHE PATH "")
-SET(CEGUI_OGRE_LIBRARIES ${CEGUI_OGRE_LIBRARIES} CACHE STRING "")
-SET(CEGUI_OGRE_LIB_DIR ${CEGUI_OGRE_LIB_DIR} CACHE PATH "")
-
-IF (CEGUI_OGRE_INCLUDE_DIR AND CEGUI_OGRE_LIBRARIES AND CEGUI_OGRE_LIB_DIR)
-    SET(CEGUI_OGRE_FOUND TRUE)
-ENDIF (CEGUI_OGRE_INCLUDE_DIR AND CEGUI_OGRE_LIBRARIES AND CEGUI_OGRE_LIB_DIR)
-
-IF (CEGUI_OGRE_FOUND)
-    IF (NOT CEGUI_OGRE_FIND_QUIETLY)
-        MESSAGE(STATUS "CEGUI_Ogre was found.")
-        IF (VERBOSE_FIND)
-            MESSAGE (STATUS "  include path: ${CEGUI_OGRE_INCLUDE_DIR}")
-            MESSAGE (STATUS "  library path: ${CEGUI_OGRE_LIB_DIR}")
-            MESSAGE (STATUS "  libraries:    ${CEGUI_OGRE_LIBRARIES}")
-        ENDIF (VERBOSE_FIND)
-    ENDIF (NOT CEGUI_OGRE_FIND_QUIETLY)
-ELSE (CEGUI_OGRE_FOUND)
-    IF (NOT CEGUI_OGRE_INCLUDE_DIR)
-        MESSAGE(SEND_ERROR "CEGUI_Ogre include path was not found.")
-    ENDIF (NOT CEGUI_OGRE_INCLUDE_DIR)
-    IF (NOT CEGUI_OGRE_LIB_DIR)
-        MESSAGE(SEND_ERROR "CEGUI_Ogre library was not found.")
-    ENDIF (NOT CEGUI_OGRE_LIB_DIR)
-    IF (NOT CEGUI_OGRE_LIBRARIES)
-        MESSAGE(SEND_ERROR "CEGUI_Ogre libraries not known.")
-    ENDIF (NOT CEGUI_OGRE_LIBRARIES)
-ENDIF (CEGUI_OGRE_FOUND)
Index: code/branches/buildsystem3/cmake/FindDirectX.cmake
===================================================================
--- code/branches/buildsystem3/cmake/FindDirectX.cmake	(revision 2663)
+++ code/branches/buildsystem3/cmake/FindDirectX.cmake	(revision 2664)
@@ -1,49 +1,53 @@
-IF(WIN32)
-  # - Test for DirectX
-  # Once loaded this will define
-  #   DirectX_FOUND        - system has DirectX
-  #   DirectX_INCLUDE_DIR  - include directory for DirectX
-  #   DirectX_LIB_DIR      - lib directory for DirectX
-  #
-  # Several changes and additions by Fabian 'x3n' Landau
-  #                 > www.orxonox.net <
+# Find script for DirectX on Windows
+# Specifically designed to find dxguid and dinput8 for OIS
+# Once loaded this will define
+#   DIRECTX_FOUND        - system has DirectX
+#   DIRECTX_INCLUDE_DIR  - include directory for DirectX
+#   DIRECTX_LIBRARIES    - libraries for DirectX
+#
+# Set ENV{DXSD_DIR} if that has not been done the SDK installation.
+#
+# Several changes and additions by Fabian 'x3n' Landau
+# Simplifications and CMake 2.6.0 bugfix by Reto Grieder
+#                 > www.orxonox.net <
 
-  IF (DirectX_INCLUDE_DIR AND DirectX_LIB_DIR)
-    SET(DirectX_FIND_QUIETLY TRUE)
-  ENDIF (DirectX_INCLUDE_DIR AND DirectX_LIB_DIR)
+INCLUDE(FindPackageHandleStandardArgs)
+INCLUDE(HandleLibraryTypes)
 
-  set(DirectX_FOUND "NO")
+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
+  NO_DEFAULT_PATH # Or else CMake 2.6.0 will find the dll in system32 on windows
+)
+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
+  NO_DEFAULT_PATH # Or else CMake 2.6.0 will find the dll in system32 on windows
+)
+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"
-    ../libs/DXSDK/Include
-    $ENV{DXSDK_DIR}/Include
-  )
+# Handle the REQUIRED argument and set DIRECTX_FOUND
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(DirectX DEFAULT_MSG
+  DIRECTX_LIBRARY_input
+  DIRECTX_LIBRARY_guid
+  DIRECTX_INCLUDE_DIR
+)
 
-  FIND_PATH(DirectX_LIB_DIR "dinput8.lib"
-    ../libs/DXSDK/Lib
-    ../libs/DXSDK/Lib/x86
-    $ENV{DXSDK_DIR}/lib/x86
-  )
+SET(DIRECTX_LIBRARIES ${DIRECTX_LIBRARY_input} ${DIRECTX_LIBRARY_guid})
 
-  IF (DirectX_INCLUDE_DIR AND DirectX_LIB_DIR)
-    SET (DirectX_FOUND "YES")
-  ENDIF (DirectX_INCLUDE_DIR AND DirectX_LIB_DIR)
-
-  IF (DirectX_FOUND)
-    IF (NOT DirectX_FIND_QUIETLY)
-      MESSAGE(STATUS "DirectX was found.")
-      IF (VERBOSE_FIND)
-        MESSAGE (STATUS "  include path: ${DirectX_INCLUDE_DIR}")
-        MESSAGE (STATUS "  library path: ${DirectX_LIB_DIR}")
-        MESSAGE (STATUS "  libraries:    dinput8.lib")
-      ENDIF (VERBOSE_FIND)
-    ENDIF (NOT DirectX_FIND_QUIETLY)
-  ELSE (DirectX_FOUND)
-    IF (NOT DirectX_INCLUDE_DIR)
-      MESSAGE(SEND_ERROR "DirectX include path was not found.")
-    ENDIF (NOT DirectX_INCLUDE_DIR)
-    IF (NOT DirectX_LIB_DIR)
-      MESSAGE(SEND_ERROR "DirectX library was not found.")
-    ENDIF (NOT DirectX_LIB_DIR)
-  ENDIF (DirectX_FOUND)
-ENDIF(WIN32)
+MARK_AS_ADVANCED(
+  DIRECTX_INCLUDE_DIR
+  DIRECTX_LIBRARY_input
+  DIRECTX_LIBRARY_guid
+)
Index: code/branches/buildsystem3/cmake/FindENet.cmake
===================================================================
--- code/branches/buildsystem3/cmake/FindENet.cmake	(revision 2663)
+++ code/branches/buildsystem3/cmake/FindENet.cmake	(revision 2664)
@@ -3,7 +3,8 @@
 #
 #  ENET_FOUND - system has enet
-#  ENET_INCLUDE_DIR - the enet include directory
-#  ENET_LIBRARIES - the libraries needed to use enet
-#  ENET_DEFINITIONS - Compiler switches required for using enet
+#  ENet_INCLUDE_DIR - the enet include directory
+#  ENet_LIBRARY - the library needed to link against enet
+#
+# $ENETDIR is an environment variable used for finding enet.
 #
 #  Borrowed from The Mana World
@@ -11,55 +12,60 @@
 #
 # Several changes and additions by Fabian 'x3n' Landau
+# Lots of simplifications by Adrian Friedli and Reto Grieder
+# Version checking by Reto Grieder
 #                 > www.orxonox.net <
 
-IF (ENet_INCLUDE_DIR AND ENet_LIBRARY)
-   SET(ENet_FIND_QUIETLY TRUE)
-ENDIF (ENet_INCLUDE_DIR AND ENet_LIBRARY)
+INCLUDE(FindPackageHandleAdvancedArgs)
+INCLUDE(HandleLibraryTypes)
 
-FIND_PATH(ENet_INCLUDE_DIR enet/enet.h
-    /usr/include
-    /usr/local/include
-    /usr/pack/enet-2007-sd/include
-    ../libs/enet-1.1/include
-    ${DEPENDENCY_DIR}/enet-1.2/include
-    )
+FIND_PATH(ENET_INCLUDE_DIR enet/enet.h
+  PATHS $ENV{ENETDIR}
+  PATH_SUFFIXES include
+)
+FIND_LIBRARY(ENET_LIBRARY_OPTIMIZED
+  NAMES enet
+  PATHS $ENV{ENETDIR}
+  PATH_SUFFIXES lib
+)
+FIND_LIBRARY(ENET_LIBRARY_DEBUG
+  NAMES enetd enet_d enet_D
+  PATHS $ENV{ENETDIR}
+  PATH_SUFFIXES lib
+)
 
-FIND_LIBRARY(ENet_LIBRARY
-    NAMES enet
-    PATHS /usr/lib /usr/local/lib /usr/pack/enet-2007-sd/i686-debian-linux3.1/lib/
-    ../libs/enet-1.1
-    ${DEPENDENCY_DIR}/enet-1.2/lib
-    )
+# 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()
+    SET(ENET_VERSION 1.0)
+  ENDIF()
+ELSE()
+  SET(ENET_VERSION 0) # Script doesn't support versions below 1.0
+ENDIF()
 
-SET(ENET_FOUND FALSE)
-IF (ENet_INCLUDE_DIR AND ENet_LIBRARY)
-    SET(ENET_FOUND TRUE)
-    SET(ENET_INCLUDE_DIR ${ENet_INCLUDE_DIR})
+# 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_LIBRARY_OPTIMIZED
+  ENET_INCLUDE_DIR
+)
 
-    IF(WIN32)
-        SET(WINDOWS_ENET_DEPENDENCIES "ws2_32;winmm")
-        SET(ENet_LIBRARY ${ENet_LIBRARY} ${WINDOWS_ENET_DEPENDENCIES})
-    ENDIF(WIN32)
+# 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()
+  HANDLE_LIBRARY_TYPES(ENET)
+ENDIF()
 
-    SET(ENET_LIBRARIES ${ENet_LIBRARY})
-ENDIF (ENet_INCLUDE_DIR AND ENet_LIBRARY)
-
-IF (ENET_FOUND)
-    IF (NOT ENet_FIND_QUIETLY)
-        MESSAGE(STATUS "ENet was found.")
-        IF (VERBOSE_FIND)
-            MESSAGE (STATUS "  include path: ${ENet_INCLUDE_DIR}")
-            MESSAGE (STATUS "  library path: ${ENet_LIBRARY}")
-            MESSAGE (STATUS "  libraries:    enet")
-        ENDIF (VERBOSE_FIND)
-    ENDIF (NOT ENet_FIND_QUIETLY)
-ELSE (ENET_FOUND)
-    IF (NOT ENet_INCLUDE_DIR)
-        MESSAGE(SEND_ERROR "ENet include path was not found.")
-    ENDIF (NOT ENet_INCLUDE_DIR)
-    IF (NOT ENet_LIBRARY)
-        MESSAGE(SEND_ERROR "ENet library was not found.")
-    ENDIF (NOT ENet_LIBRARY)
-ENDIF (ENET_FOUND)
-
-MARK_AS_ADVANCED(ENet_INCLUDE_DIR ENet_LIBRARY)
+MARK_AS_ADVANCED(
+  ENET_INCLUDE_DIR
+  ENET_LIBRARY_OPTIMIZED
+  ENET_LIBRARY_DEBUG
+)
Index: code/branches/buildsystem3/cmake/FindLua.cmake
===================================================================
--- code/branches/buildsystem3/cmake/FindLua.cmake	(revision 2663)
+++ code/branches/buildsystem3/cmake/FindLua.cmake	(revision 2664)
@@ -1,101 +1,184 @@
-#  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 <
+ #
+ #             ORXONOX - the hottest 3D action shooter ever to exist
+ #                             > www.orxonox.net <
+ #
+ #        This program is free software; you can redistribute it and/or
+ #         modify it under the terms of the GNU General Public License
+ #        as published by the Free Software Foundation; either version 2
+ #            of the License, or (at your option) any later version.
+ #
+ #       This program is distributed in the hope that it will be useful,
+ #        but WITHOUT ANY WARRANTY; without even the implied warranty of
+ #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ #                 GNU General Public License for more details.
+ #
+ #   You should have received a copy of the GNU General Public License along
+ #      with this program; if not, write to the Free Software Foundation,
+ #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ #
+ #
+ #  Author:
+ #    Reto Grieder
+ #  Description:
+ #    Finds either Lua 5.0 or Lua 5.1 on the system. The script regards the
+ #    VERSION, EXACT, REQUIRED and QUIET arguments. A note about the EXACT
+ #    argument: EXACT 5 will match all Lua 5 versions.
+ #    When the search was successful, the following variables are set:
+ #    LUA_INCLUDE_DIR, LUA_LIBRARIES, LUA_VERSION, LUA_FOUND
+ #
 
-IF (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
+INCLUDE(CompareVersionStrings)
+INCLUDE(FindPackageHandleAdvancedArgs)
+INCLUDE(HandleLibraryTypes)
 
-  # 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)
+# Macro that determines Lua version. Should work for versions 2.2 and above (current release: 5.1.4)
+FUNCTION(DETERMINE_LUA_VERSION _file _varname)
+  IF(EXISTS ${_file})
+    FILE(STRINGS ${_file} _file_content REGEX "LUA_VERSION|LUA_RELEASE")
+  ELSE()
+    SET(${_varname} "0" PARENT_SCOPE)
+    RETURN()
+  ENDIF()
+  STRING(REGEX REPLACE "^.*LUA_RELEASE[ \t]+\"Lua[ \t]+([.0-9]+)\".*$" "\\1" ${_varname} "${_file_content}")
+  IF(${_varname} STREQUAL "${_file_content}")
+    # At most version 5.1.0
+    STRING(REGEX REPLACE "^.*LUA_VERSION[ \t]+\"Lua[ \t]+([.0-9]+)\".*$" "\\1" ${_varname} "${_file_content}")
+    IF(${_varname} STREQUAL "${_file_content}")
+      MESSAGE(FATAL_ERROR "Could not determine Lua version which means this script has a bug")
+    ENDIF()
+    IF(${_varname} MATCHES "^[0-9]+\\.[0-9]+$")
+      SET(${_varname} "${${_varname}}.0") # E.g. "3.2" is "3.2.0" actually
+    ENDIF()
+  ENDIF()
+  SET(${_varname} "${${_varname}}" PARENT_SCOPE)
+ENDFUNCTION(DETERMINE_LUA_VERSION)
 
 
-  IF (Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
+# Find Lua 5.1
+FIND_PATH(LUA_5.1_INCLUDE_DIR lua.h
+  PATHS $ENV{LUA_DIR}
+  PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include
+)
+IF(LUA_5.1_INCLUDE_DIR)
+  DETERMINE_LUA_VERSION(${LUA_5.1_INCLUDE_DIR}/lua.h LUA_5.1_VERSION)
+  COMPARE_VERSION_STRINGS("${LUA_5.1_VERSION}" "5.1" _version_compare TRUE)
+  IF(NOT _version_compare EQUAL 0)
+    # Incorrect version found, abort search
+    SET(LUA_5.1_INCLUDE_DIR "LUA_5.1_INCLUDE_DIR-NOTFOUND" CACHE PATH "" FORCE)
+  ELSE()
+    FIND_LIBRARY(LUA_5.1_LIBRARY_OPTIMIZED
+      NAMES lua51 lua5.1 lua
+      PATHS $ENV{LUA_DIR}
+      PATH_SUFFIXES lib64 lib
+    )
+    FIND_LIBRARY(LUA_5.1_LIBRARY_DEBUG
+      NAMES lua51d lua51_d lua5.1d lua5.1_d luad lua_d
+            lua51D lua51_D lua5.1D lua5.1_D luad lua_D
+      PATHS $ENV{LUA_DIR}
+      PATH_SUFFIXES lib64 lib
+    )
+    HANDLE_LIBRARY_TYPES(LUA_5.1)
+    SET(LUA_5.1_LIBRARIES ${LUA_5.1_LIBRARY})
+    IF(LUA_5.1_LIBRARIES)
+      SET(LUA_5.1_FOUND TRUE)
+    ENDIF()
+  ENDIF(NOT _version_compare EQUAL 0)
+ENDIF(LUA_5.1_INCLUDE_DIR)
 
-    # 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)
+# Find Lua 5.0
+FIND_PATH(LUA_5.0_INCLUDE_DIR lua.h
+  PATHS $ENV{LUA_DIR}
+  PATH_SUFFIXES include/lua50 include/lua5.0 include/lua5 include/lua include
+)
+IF(LUA_5.0_INCLUDE_DIR)
+  DETERMINE_LUA_VERSION(${LUA_5.0_INCLUDE_DIR}/lua.h LUA_5.0_VERSION)
+  COMPARE_VERSION_STRINGS("${LUA_5.0_VERSION}" "5.0" _version_compare TRUE)
+  IF(NOT _version_compare EQUAL 0)
+    # Incorrect version found, abourt search
+    SET(LUA_5.0_INCLUDE_DIR "LUA_5.0_INCLUDE_DIR-NOTFOUND" CACHE PATH "" FORCE)
+  ELSE()
+    FIND_LIBRARY(LUA_5.0_LUA_LIBRARY_OPTIMIZED
+      NAMES lua50 lua5.0 lua5 lua
+      PATHS $ENV{LUA_DIR}
+      PATH_SUFFIXES lib64 lib
+    )
+    FIND_LIBRARY(LUA_5.0_LUA_LIBRARY_DEBUG
+      NAMES lua50d lua50_d lua5.0d lua5.0_d lua5d lua5_d luad lua_d
+            lua50D lua50_D lua5.0D lua5.0_D lua5d lua5_D luaD lua_D
+      PATHS $ENV{LUA_DIR}
+      PATH_SUFFIXES lib64 lib
+    )
+    HANDLE_LIBRARY_TYPES(LUA_5.0_LUA)
 
-    # 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")
+    # In an OS X framework, lualib is usually included as part of the framework
+    # (like GLU in OpenGL.framework)
+    IF(${LUA_5.0_LUA_LIBRARY} MATCHES "framework")
+      SET(LUA_5.0_LIBRARIES ${LUA_5.0_LUA_LIBRARY})
+    ELSE()
+      FIND_LIBRARY(LUA_5.0_LUALIB_LIBRARY_OPTIMIZED
+        NAMES lualib50 lualib5.0 lualib5 lualib
+        PATHS $ENV{LUALIB_DIR} $ENV{LUA_DIR}
+        PATH_SUFFIXES lib64 lib
+      )
+      FIND_LIBRARY(LUA_5.0_LUALIB_LIBRARY_DEBUG
+        NAMES lualib50d lualib50_d lualib5.0d lualib5.0_d
+              lualib5d lualib5_d lualibd lualib_d
+              lualib50D lualib50_D lualib5.0D lualib5.0_D
+              lualib5D lualib5_D lualibD lualib_D
+        PATHS $ENV{LUALIB_DIR} $ENV{LUA_DIR}
+        PATH_SUFFIXES lib64 lib
+      )
+      HANDLE_LIBRARY_TYPES(LUA_5.0_LUALIB)
+      # Both libraries are required for Lua 5.0 to be found
+      IF(LUA_5.0_LUA_LIBRARY AND LUA_5.0_LUALIB_LIBRARY)
+        SET(LUA_5.0_LIBRARIES ${LUA_5.0_LUA_LIBRARY} ${LUA_5.0_LUALIB_LIBRARY})
+      ENDIF()
+    ENDIF(${LUA_5.0_LUA_LIBRARY} MATCHES "framework")
+    
+    IF(LUA_5.0_LIBRARIES)
+      SET(LUA_5.0_FOUND TRUE)
+    ENDIF()
+  ENDIF(NOT _version_compare EQUAL 0)
+ENDIF(LUA_5.0_INCLUDE_DIR)
 
-  ENDIF (Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
-	
+# Pick the right version
+IF(Lua_FIND_VERSION_EXACT AND NOT Lua_FIND_VERSION MATCHES "^[0-9]*$")
+  STRING(REGEX REPLACE "^([0-9]+\\.[0-9]+)(\\..*)?$" "\\1" LUA_VERSION_SELECTION ${Lua_FIND_VERSION})
+ELSE()
+  IF(LUA_5.1_FOUND) # Prefer version 5.1 if found
+    SET(LUA_VERSION_SELECTION "5.1")
+  ELSEIF(LUA_5.0_FOUND)
+    SET(LUA_VERSION_SELECTION "5.0")
+  ENDIF()
+ENDIF()
 
-  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)
+SET(LUA_INCLUDE_DIR "${LUA_${LUA_VERSION_SELECTION}_INCLUDE_DIR}")
+SET(LUA_LIBRARIES "${LUA_${LUA_VERSION_SELECTION}_LIBRARIES}")
+SET(LUA_VERSION_LONG "${LUA_${LUA_VERSION_SELECTION}_VERSION}")
+SET(LUA_VERSION "${LUA_VERSION_SELECTION}")
 
-    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)
+FIND_PACKAGE_HANDLE_ADVANCED_ARGS(Lua DEFAULT_MSG "${LUA_VERSION_LONG}"
+  LUA_LIBRARIES
+  LUA_INCLUDE_DIR
+)
 
-    MESSAGE(SEND_ERROR "Lua was not found.")
-  ENDIF (Lua_FOUND)
+# Include the math library for Unix only
+IF(LUA_FOUND)
+  IF(UNIX AND NOT APPLE)
+    FIND_LIBRARY(UNIX_MATH_LIBRARY m)
+    SET(LUA_LIBRARIES ${LUA_LIBRARIES} ${UNIX_MATH_LIBRARY})
+  ENDIF()
+ENDIF(LUA_FOUND)
 
-ENDIF (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
-
+MARK_AS_ADVANCED(
+  LUA_5.0_INCLUDE_DIR
+  LUA_5.0_LUA_LIBRARY_OPTIMIZED
+  LUA_5.0_LUA_LIBRARY_DEBUG
+  LUA_5.0_LUALIB_LIBRARY_OPTIMIZED
+  LUA_5.0_LUALIB_LIBRARY_DEBUG
+  LUA_5.1_INCLUDE_DIR
+  LUA_5.1_LIBRARY_OPTIMIZED
+  LUA_5.1_LIBRARY_DEBUG
+  UNIX_MATH_LIBRARY
+)
Index: code/branches/buildsystem3/cmake/FindOGRE.cmake
===================================================================
--- code/branches/buildsystem3/cmake/FindOGRE.cmake	(revision 2663)
+++ code/branches/buildsystem3/cmake/FindOGRE.cmake	(revision 2664)
@@ -3,75 +3,53 @@
 # This module defines
 #  OGRE_INCLUDE_DIR
-#  OGRE_LIBRARIES, the libraries to link against to use OGRE.
-#  OGRE_LIB_DIR, the location of the libraries
+#  OGRE_LIBRARY, the library to link against to use OGRE.
 #  OGRE_FOUND, If false, do not try to use OGRE
 #
 # Copyright © 2007, Matt Williams
-# Modified by Nicolas Schlumberger to make it work on the Tardis-Infrastucture of the ETH Zurich
+# Modified by Nicolas Schlumberger to make it work on the Tardis-Infrastucture
+# of the ETH Zurich (removed later on)
 #
 # Redistribution and use is allowed according to the terms of the BSD license.
 #
 # Several changes and additions by Fabian 'x3n' Landau
+# Lots of simplifications by Adrian Friedli
+# Version checking by Reto Grieder
 #                 > www.orxonox.net <
 
-IF (OGRE_LIBRARIES AND OGRE_INCLUDE_DIR AND OGRE_LIB_DIR)
-    SET (OGRE_FIND_QUIETLY TRUE) # Already in cache, be silent
-ENDIF (OGRE_LIBRARIES AND OGRE_INCLUDE_DIR AND OGRE_LIB_DIR)
+INCLUDE(DetermineVersion)
+INCLUDE(FindPackageHandleAdvancedArgs)
+INCLUDE(HandleLibraryTypes)
 
-IF (WIN32) #Windows
-    FIND_PATH(OGRE_INCLUDE_DIR Ogre.h
-        ../libs/ogre/OgreMain/include
-        ${DEPENDENCY_DIR}/ogre-1.4.9/include
-    )
+FIND_PATH(OGRE_INCLUDE_DIR Ogre.h
+  PATHS $ENV{OGRE_HOME}
+  PATH_SUFFIXES include include/OGRE Ogre.framework/Headers
+)
+FIND_LIBRARY(OGRE_LIBRARY_OPTIMIZED
+  NAMES OgreMain Ogre
+  PATHS $ENV{OGRE_HOME}
+  PATH_SUFFIXES lib bin/Release bin/release Release release
+)
+FIND_LIBRARY(OGRE_LIBRARY_DEBUG
+  NAMES OgreMaind OgreMain_d OgreMainD OgreMain_D Ogred Ogre_d OgreD Ogre_d
+  PATHS $ENV{OGRE_HOME}
+  PATH_SUFFIXES lib bin/Debug bin/debug Debug debug Versions/A
+)
 
-    SET(OGRE_LIBRARIES debug OgreMain_d optimized OgreMain)
-    FIND_LIBRARY(OGRE_LIBDIR NAMES ${OGRE_LIBRARIES} PATHS
-        ../libs/ogre/Samples/Common/bin/Release
-        ${DEPENDENCY_DIR}/ogre-1.4.9/lib
-    )
+# Inspect OgrePrerquisites.h for the version number
+DETERMINE_VERSION(OGRE ${OGRE_INCLUDE_DIR}/OgrePrerequisites.h)
 
-    # Strip the filename from the path
-    IF (OGRE_LIBDIR)
-        GET_FILENAME_COMPONENT(OGRE_LIBDIR ${OGRE_LIBDIR} PATH)
-        SET (OGRE_LIB_DIR ${OGRE_LIBDIR} CACHE FILEPATH "")
-    ENDIF (OGRE_LIBDIR)
-ELSE (WIN32) #Unix
-    FIND_PACKAGE(PkgConfig)
-    PKG_SEARCH_MODULE(OGRE OGRE /usr/pack/ogre-1.4.5-sd/i686-debian-linux3.1/lib/pkgconfig/OGRE.pc) # tardis specific hack
-    SET(OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIRS})
-    SET(OGRE_LIB_DIR ${OGRE_LIBDIR})
-    SET(OGRE_LIBRARIES ${OGRE_LIBRARIES})
-ENDIF (WIN32)
+# Handle the REQUIRED argument and set OGRE_FOUND
+# Also check the version requirements
+FIND_PACKAGE_HANDLE_ADVANCED_ARGS(OGRE DEFAULT_MSG ${OGRE_VERSION}
+  OGRE_LIBRARY_OPTIMIZED
+  OGRE_INCLUDE_DIR
+)
 
-#Do some preparation
-SEPARATE_ARGUMENTS(OGRE_INCLUDE_DIR)
-SEPARATE_ARGUMENTS(OGRE_LIBRARIES)
+# Collect optimized and debug libraries
+HANDLE_LIBRARY_TYPES(OGRE)
 
-SET (OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIR} CACHE PATH "")
-SET (OGRE_LIBRARIES ${OGRE_LIBRARIES} CACHE STRING "")
-SET (OGRE_LIB_DIR ${OGRE_LIB_DIR} CACHE PATH "")
-
-IF (OGRE_INCLUDE_DIR AND OGRE_LIBRARIES AND OGRE_LIB_DIR)
-    SET(OGRE_FOUND TRUE)
-ENDIF (OGRE_INCLUDE_DIR AND OGRE_LIBRARIES AND OGRE_LIB_DIR)
-
-IF (OGRE_FOUND)
-    IF (NOT OGRE_FIND_QUIETLY)
-        MESSAGE(STATUS "Ogre was found.")
-        IF (VERBOSE_FIND)
-            MESSAGE (STATUS "  include path: ${OGRE_INCLUDE_DIR}")
-            MESSAGE (STATUS "  library path: ${OGRE_LIB_DIR}")
-            MESSAGE (STATUS "  libraries:    ${OGRE_LIBRARIES}")
-        ENDIF (VERBOSE_FIND)
-    ENDIF (NOT OGRE_FIND_QUIETLY)
-ELSE (OGRE_FOUND)
-    IF (NOT OGRE_INCLUDE_DIR)
-        MESSAGE(SEND_ERROR "Ogre include path was not found.")
-    ENDIF (NOT OGRE_INCLUDE_DIR)
-    IF (NOT OGRE_LIB_DIR)
-        MESSAGE(SEND_ERROR "Ogre library was not found.")
-    ENDIF (NOT OGRE_LIB_DIR)
-    IF (NOT OGRE_LIBRARIES)
-        MESSAGE(SEND_ERROR "Ogre libraries not known.")
-    ENDIF (NOT OGRE_LIBRARIES)
-ENDIF (OGRE_FOUND)
+MARK_AS_ADVANCED(
+  OGRE_INCLUDE_DIR
+  OGRE_LIBRARY_OPTIMIZED
+  OGRE_LIBRARY_DEBUG
+)
Index: code/branches/buildsystem3/cmake/FindOgg.cmake
===================================================================
--- code/branches/buildsystem3/cmake/FindOgg.cmake	(revision 2664)
+++ code/branches/buildsystem3/cmake/FindOgg.cmake	(revision 2664)
@@ -0,0 +1,47 @@
+# - Try to find ogg
+# 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
+# Debug versions and simplifications by Reto Grieder
+#                 > www.orxonox.net <
+
+INCLUDE(FindPackageHandleStandardArgs)
+INCLUDE(HandleLibraryTypes)
+
+FIND_PATH(OGG_INCLUDE_DIR ogg/ogg.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 oggD ogg_D
+  PATHS $ENV{OGGDIR}
+  PATH_SUFFIXES lib
+)
+
+# Handle the REQUIRED argument and set OGG_FOUND
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ogg DEFAULT_MSG
+  OGG_LIBRARY_OPTIMIZED
+  OGG_INCLUDE_DIR
+)
+
+# Collect optimized and debug libraries
+HANDLE_LIBRARY_TYPES(OGG)
+
+MARK_AS_ADVANCED(
+  OGG_INCLUDE_DIR
+  OGG_LIBRARY_OPTIMIZED
+  OGG_LIBRARY_DEBUG
+)
Index: code/branches/buildsystem3/cmake/FindOggVorbis.cmake
===================================================================
--- code/branches/buildsystem3/cmake/FindOggVorbis.cmake	(revision 2663)
+++ 	(revision )
@@ -1,156 +1,0 @@
-# Several changes and additions by Fabian 'x3n' Landau
-#                 > www.orxonox.net <
-
-IF (OGG_INCLUDE_DIR AND OGG_LIBRARY)
-  SET(OGG_FIND_QUIETLY TRUE)
-ENDIF (OGG_INCLUDE_DIR AND OGG_LIBRARY)
-
-IF (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISENC_LIBRARY AND VORBISFILE_LIBRARY)
-  SET(VORBIS_FIND_QUIETLY TRUE)
-ENDIF (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISENC_LIBRARY AND VORBISFILE_LIBRARY) 
-
-
-#SET(OGGVORBIS_LIBRARY_DIR "/usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0/lib")
-#SET(OGGVORBIS_LIBRARY "-L ${OGGVORBIS_LIBRARY_DIR} -lvorbisenc -lvorbisfile -logg -lvorbis ")
-#SET(OGGVORBIS_INCLUDE_DIR "/usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0/include")
-
-#
-# Includes
-#
-
-FIND_PATH(OGG_INCLUDE_DIR ogg/ogg.h
-  /usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0/include 		# Tardis specific hack
-  /usr/local/include
-  /usr/include
-  /sw/include
-  /opt/local/include
-  /opt/csw/include
-  /opt/csw/include
-  /opt/include
-  ../libs/libogg-1.1.3/include
-  ${DEPENDENCY_DIR}/libogg-1.1.3/include
-  )
-
-FIND_PATH(VORBIS_INCLUDE_DIR vorbis/codec.h
-  /usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0/include 		# Tardis specific hack
-  /usr/local/include
-  /usr/include
-  /sw/include
-  /opt/local/include
-  /opt/csw/include
-  /opt/csw/include
-  /opt/include
-  ../libs/libvorbis-1.2.0/include
-  ${DEPENDENCY_DIR}/libvorbis-1.2.0/include
-  )
-
-#
-# Libs
-#
-
-FIND_LIBRARY(OGG_LIBRARY
-  NAMES ogg
-  PATHS
-  /usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.1/lib
-  /usr/local/lib
-  /usr/lib
-  /sw/lib
-  /opt/local/lib
-  /opt/csw/lib
-  /opt/lib
-  ../libs/libogg-1.1.3/src/.libs
-  ${DEPENDENCY_DIR}/libogg-1.1.3/lib
-  )
-
-FIND_LIBRARY(VORBIS_LIBRARY
-  NAMES vorbis
-  PATHS
-  /usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.1/lib
-  /usr/local/lib
-  /usr/lib
-  /sw/lib
-  /opt/local/lib
-  /opt/csw/lib
-  /opt/lib
-  ../libs/libvorbis-1.2.0/lib/.libs
-  ${DEPENDENCY_DIR}/libvorbis-1.2.0/lib
-  )
-
-#FIND_LIBRARY(VORBISENC_LIBRARY
-#  NAMES vorbisenc
-#  PATHS
-#  /usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.1/lib
-#  /usr/local/lib
-#  /usr/lib
-#  /sw/lib
-#  /opt/local/lib
-#  /opt/csw/lib
-#  /opt/lib
-#  ../libs/libvorbis-1.2.0/lib/.libs
-#  )
-
-FIND_LIBRARY(VORBISFILE_LIBRARY
-  NAMES vorbisfile
-  PATHS
-  /usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.1/lib
-  /usr/local/lib
-  /usr/lib
-  /sw/lib
-  /opt/local/lib
-  /opt/csw/lib
-  /opt/lib
-  ../libs/libvorbis-1.2.0/lib/.libs
-  ${DEPENDENCY_DIR}/libvorbis-1.2.0/lib
-  )
-
-SET (OGG_FOUND "NO")
-
-IF (OGG_INCLUDE_DIR AND OGG_LIBRARY)
-  SET (OGG_FOUND "YES")
-  IF (NOT OGG_FIND_QUIETLY)
-    MESSAGE (STATUS "Ogg was found.")
-    IF (VERBOSE_FIND)
-      MESSAGE (STATUS "  include path: ${OGG_INCLUDE_DIR}")
-      MESSAGE (STATUS "  library path: ${OGG_LIBRARY}")
-      MESSAGE (STATUS "  libraries:    ogg")
-    ENDIF (VERBOSE_FIND)
-  ENDIF (NOT OGG_FIND_QUIETLY)
-ELSE (OGG_INCLUDE_DIR AND OGG_LIBRARY)
-  IF (NOT OGG_INCLUDE_DIR)
-    MESSAGE (SEND_ERROR "Ogg include path was not found.")
-  ENDIF (NOT OGG_INCLUDE_DIR)
-  IF (NOT OGG_LIBRARY)
-    MESSAGE (SEND_ERROR "Ogg library was not found.")
-  ENDIF (NOT OGG_LIBRARY)
-ENDIF (OGG_INCLUDE_DIR AND OGG_LIBRARY)
-
-
-SET (VORBIS_FOUND "NO")
-
-IF (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY)# AND VORBISENC_LIBRARY)
-  SET (VORBIS_FOUND "YES")
-  IF (NOT VORBIS_FIND_QUIETLY)
-    MESSAGE (STATUS "Vorbis was found.")
-    IF (VERBOSE_FIND)
-      MESSAGE (STATUS "  include path: ${VORBIS_INCLUDE_DIR}")
-      MESSAGE (STATUS "  library path: ${VORBIS_LIBRARY}")
-      #MESSAGE (STATUS "  library path: ${VORBISENC_LIBRARY}")
-      MESSAGE (STATUS "  library path: ${VORBISFILE_LIBRARY}")
-      MESSAGE (STATUS "  libraries:    vorbis vorbisenc vorbisfile")
-    ENDIF (VERBOSE_FIND)
-  ENDIF (NOT VORBIS_FIND_QUIETLY)
-ELSE (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY)# AND VORBISENC_LIBRARY)
-  IF (NOT VORBIS_INCLUDE_DIR)
-    MESSAGE (SEND_ERROR "Vorbis include path was not found.")
-  ENDIF (NOT VORBIS_INCLUDE_DIR)
-  IF (NOT VORBIS_LIBRARY)
-    MESSAGE (SEND_ERROR "Vorbis library \"vorbis\" was not found.")
-  ENDIF (NOT VORBIS_LIBRARY)
-  #IF (NOT VORBISENC_LIBRARY)
-  #  MESSAGE (SEND_ERROR "Vorbis library \"vorbisenc\" was not found.")
-  #ENDIF (NOT VORBISENC_LIBRARY)
-  IF (NOT VORBISFILE_LIBRARY)
-    MESSAGE (SEND_ERROR "Vorbis library \"vorbisfile\" was not found.")
-  ENDIF (NOT VORBISFILE_LIBRARY)
-ENDIF (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY)# AND VORBISENC_LIBRARY)
-
Index: code/branches/buildsystem3/cmake/FindOpenAL.cmake
===================================================================
--- code/branches/buildsystem3/cmake/FindOpenAL.cmake	(revision 2663)
+++ 	(revision )
@@ -1,113 +1,0 @@
-# - Locate OpenAL
-# This module defines
-#  OPENAL_LIBRARY
-#  OPENAL_FOUND, if false, do not try to link to OpenAL
-#  OPENAL_INCLUDE_DIR, where to find the headers
-#
-# $OPENALDIR is an environment variable that would
-# correspond to the ./configure --prefix=$OPENALDIR
-# used in building OpenAL.
-#
-# Several changes and additions by Fabian 'x3n' Landau
-#                 > www.orxonox.net <
-
-IF (OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR)
-  SET(OPENAL_FIND_QUIETLY TRUE)
-ENDIF (OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR)
-
-# Created by Eric Wing. This was influenced by the FindSDL.cmake module.
-# On OSX, this will prefer the Framework version (if found) over others.
-# People will have to manually change the cache values of
-# OPENAL_LIBRARY to override this selection.
-# Tiger will include OpenAL as part of the System.
-# But for now, we have to look around.
-# Other (Unix) systems should be able to utilize the non-framework paths.
-FIND_PATH(OPENAL_INCLUDE_DIR AL/al.h
-  $ENV{OPENALDIR}/include
-  ~/Library/Frameworks/OpenAL.framework/Headers
-  /Library/Frameworks/OpenAL.framework/Headers
-  /System/Library/Frameworks/OpenAL.framework/Headers # Tiger
-  /usr/pack/openal-0.0.8-cl/include # Tardis specific hack
-  /usr/local/include/
-  /usr/local/include/OpenAL
-  /usr/local/include
-  /usr/include/
-  /usr/include/OpenAL
-  /usr/include
-  /sw/include # Fink
-  /sw/include/OpenAL
-  /sw/include
-  /opt/local/include # DarwinPorts
-  /opt/local/include/OpenAL
-  /opt/local/include
-  /opt/csw/include # Blastwave
-  /opt/csw/include/OpenAL
-  /opt/csw/include
-  /opt/include
-  /opt/include/OpenAL
-  /opt/include
-  ../libs/openal-0.0.8/common/include
-  ${DEPENDENCY_DIR}/openal-1.1/include
-  )
-# I'm not sure if I should do a special casing for Apple. It is
-# unlikely that other Unix systems will find the framework path.
-# But if they do ([Next|Open|GNU]Step?),
-# do they want the -framework option also?
-IF(${OPENAL_INCLUDE_DIR} MATCHES ".framework")
-  STRING(REGEX REPLACE "(.*)/.*\\.framework/.*" "\\1" OPENAL_FRAMEWORK_PATH_TMP ${OPENAL_INCLUDE_DIR})
-  IF("${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
-      OR "${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
-      )
-    # String is in default search path, don't need to use -F
-    SET (OPENAL_LIBRARY "-framework OpenAL" CACHE STRING "OpenAL framework for OSX")
-  ELSE("${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
-      OR "${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
-      )
-    # String is not /Library/Frameworks, need to use -F
-    SET(OPENAL_LIBRARY "-F${OPENAL_FRAMEWORK_PATH_TMP} -framework OpenAL" CACHE STRING "OpenAL framework for OSX")
-  ENDIF("${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
-    OR "${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
-    )
-  # Clear the temp variable so nobody can see it
-  SET(OPENAL_FRAMEWORK_PATH_TMP "" CACHE INTERNAL "")
-
-ELSE(${OPENAL_INCLUDE_DIR} MATCHES ".framework")
-  FIND_LIBRARY(OPENAL_LIBRARY
-    NAMES openal al OpenAL32
-    PATHS
-    $ENV{OPENALDIR}/lib
-    $ENV{OPENALDIR}/libs
-    /usr/pack/openal-0.0.8-cl/i686-debian-linux3.1/lib
-    /usr/local/lib
-    /usr/lib
-    /sw/lib
-    /opt/local/lib
-    /opt/csw/lib
-    /opt/lib
-    ../libs/openal-0.0.8/src/.libs
-    ${DEPENDENCY_DIR}/openal-1.1/lib
-    )
-ENDIF(${OPENAL_INCLUDE_DIR} MATCHES ".framework")
-
-SET (OPENAL_FOUND "NO")
-
-IF (OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR)
-  SET (OPENAL_FOUND "YES")
-  IF (NOT OPENAL_FIND_QUIETLY)
-    MESSAGE (STATUS "OpenAL was found.")
-    IF (VERBOSE_FIND)
-      MESSAGE (STATUS "  include path: ${OPENAL_INCLUDE_DIR}")
-      MESSAGE (STATUS "  library path: ${OPENAL_LIBRARY}")
-      MESSAGE (STATUS "  libraries:    openal al OpenAL32")
-    ENDIF (VERBOSE_FIND)
-  ENDIF (NOT OPENAL_FIND_QUIETLY)
-ELSE (OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR)
-  IF (NOT OPENAL_INCLUDE_DIR)
-    MESSAGE (SEND_ERROR "OpenAL include path was not found.")
-  ENDIF (NOT OPENAL_INCLUDE_DIR)
-  IF (NOT OPENAL_LIBRARY)
-    MESSAGE (SEND_ERROR "OpenAL library was not found.")
-  ENDIF (NOT OPENAL_LIBRARY)
-ENDIF (OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR)
-
-
Index: code/branches/buildsystem3/cmake/FindPackageHandleAdvancedArgs.cmake
===================================================================
--- code/branches/buildsystem3/cmake/FindPackageHandleAdvancedArgs.cmake	(revision 2664)
+++ code/branches/buildsystem3/cmake/FindPackageHandleAdvancedArgs.cmake	(revision 2664)
@@ -0,0 +1,66 @@
+ #
+ #             ORXONOX - the hottest 3D action shooter ever to exist
+ #                             > www.orxonox.net <
+ #
+ #        This program is free software; you can redistribute it and/or
+ #         modify it under the terms of the GNU General Public License
+ #        as published by the Free Software Foundation; either version 2
+ #            of the License, or (at your option) any later version.
+ #
+ #       This program is distributed in the hope that it will be useful,
+ #        but WITHOUT ANY WARRANTY; without even the implied warranty of
+ #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ #                 GNU General Public License for more details.
+ #
+ #   You should have received a copy of the GNU General Public License along
+ #      with this program; if not, write to the Free Software Foundation,
+ #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ #
+ #
+ #  Author:
+ #    Reto Grieder
+ #  Description:
+ #    Extension of the standard module "FindPackageHandleStandardArgs".
+ #    This function also checks the version requirements. Also regards the
+ #    EXACT keyword if specified in FIND_PACKAGE(...).
+ #
+ 
+INCLUDE(FindPackageHandleStandardArgs)
+INCLUDE(CompareVersionStrings)
+
+FUNCTION(FIND_PACKAGE_HANDLE_ADVANCED_ARGS _name _fail_msg _version)
+
+  # Modify the message to include version requirements
+  IF("${_fail_msg}" STREQUAL "DEFAULT_MSG")
+    SET(_fail_msg_adv "Could NOT find ${_name}")
+  ELSE()
+    SET(_fail_msg_adv "${_fail_msg}")
+  ENDIF()
+  IF(${_name}_FIND_VERSION_EXACT)
+    SET(_fail_msg_adv "${_fail_msg_adv} (version requirements: exactly ${${_name}_FIND_VERSION})")
+  ELSE()
+    SET(_fail_msg_adv "${_fail_msg_adv} (version requirements: at least ${${_name}_FIND_VERSION})")
+  ENDIF()
+  FIND_PACKAGE_HANDLE_STANDARD_ARGS("${_name}" "${_fail_msg_adv}" ${ARGN})
+  STRING(TOUPPER ${_name} _NAME_UPPER)
+
+  # Also check version requirements if given to FindPackage(...)
+  IF(${_name}_FIND_VERSION)
+    # Note: the last argument of the function tells it to cut the first
+    #       version string instead of padding it with zeros if necessary
+    COMPARE_VERSION_STRINGS("${_version}" "${${_name}_FIND_VERSION}" _compatible TRUE)
+    IF(${_name}_FIND_VERSION_EXACT AND NOT _compatible EQUAL 0)
+      MESSAGE(FATAL_ERROR "Exact ${_name} version required is ${${_name}_FIND_VERSION}\n"
+                          "Your version is ${_version}")
+      SET(${_NAME_UPPER}_FOUND FALSE)
+    ELSEIF(_compatible LESS 0)
+      MESSAGE(FATAL_ERROR "Minimum ${_name} version required is ${${_name}_FIND_VERSION}\n"
+                          "Your version is ${_version}")
+      SET(${_NAME_UPPER}_FOUND FALSE)
+    ENDIF()
+  ENDIF(${_name}_FIND_VERSION)
+
+  # Raise scope (FindPackageHandleStandardArgs uses PARENT_SCOPE)
+  SET(${_NAME_UPPER}_FOUND ${${_NAME_UPPER}_FOUND} PARENT_SCOPE)
+
+ENDFUNCTION(FIND_PACKAGE_HANDLE_ADVANCED_ARGS)
Index: code/branches/buildsystem3/cmake/FindPkgConfig.cmake
===================================================================
--- code/branches/buildsystem3/cmake/FindPkgConfig.cmake	(revision 2663)
+++ 	(revision )
@@ -1,360 +1,0 @@
-# - a pkg-config module for CMake
-#
-# Usage:
-#   pkg_check_modules(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
-#     checks for all the given modules
-#
-#   pkg_search_module(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
-#     checks for given modules and uses the first working one
-#
-# When the 'REQUIRED' argument was set, macros will fail with an error
-# when module(s) could not be found
-#
-# It sets the following variables:
-#   PKG_CONFIG_FOUND         ... true iff pkg-config works on the system
-#   PKG_CONFIG_EXECUTABLE    ... pathname of the pkg-config program
-#   <PREFIX>_FOUND           ... set to 1 iff module(s) exist
-#
-# For the following variables two sets of values exist; first one is the
-# common one and has the given PREFIX. The second set contains flags
-# which are given out when pkgconfig was called with the '--static'
-# option.
-#   <XPREFIX>_LIBRARIES      ... only the libraries (w/o the '-l')
-#   <XPREFIX>_LIBRARY_DIRS   ... the paths of the libraries (w/o the '-L')
-#   <XPREFIX>_LDFLAGS        ... all required linker flags
-#   <XPREFIX>_LDFLAGS_OTHERS ... all other linker flags
-#   <XPREFIX>_INCLUDE_DIRS   ... the '-I' preprocessor flags (w/o the '-I')
-#   <XPREFIX>_CFLAGS         ... all required cflags
-#   <XPREFIX>_CFLAGS_OTHERS  ... the other compiler flags
-#
-#   <XPREFIX> = <PREFIX>        for common case
-#   <XPREFIX> = <PREFIX>_STATIC for static linking
-#
-# There are some special variables whose prefix depends on the count
-# of given modules. When there is only one module, <PREFIX> stays
-# unchanged. When there are multiple modules, the prefix will be
-# changed to <PREFIX>_<MODNAME>:
-#   <XPREFIX>_VERSION    ... version of the module
-#   <XPREFIX>_PREFIX     ... prefix-directory of the module
-#   <XPREFIX>_INCLUDEDIR ... include-dir of the module
-#   <XPREFIX>_LIBDIR     ... lib-dir of the module
-#
-#   <XPREFIX> = <PREFIX>  when |MODULES| == 1, else
-#   <XPREFIX> = <PREFIX>_<MODNAME>
-#
-# A <MODULE> parameter can have the following formats:
-#   {MODNAME}            ... matches any version
-#   {MODNAME}>={VERSION} ... at least version <VERSION> is required
-#   {MODNAME}={VERSION}  ... exactly version <VERSION> is required
-#   {MODNAME}<={VERSION} ... modules must not be newer than <VERSION>
-#
-# Examples
-#   pkg_check_modules (GLIB2   glib-2.0)
-#
-#   pkg_check_modules (GLIB2   glib-2.0>=2.10)
-#     requires at least version 2.10 of glib2 and defines e.g.
-#       GLIB2_VERSION=2.10.3
-#
-#   pkg_check_modules (FOO     glib-2.0>=2.10 gtk+-2.0)
-#     requires both glib2 and gtk2, and defines e.g.
-#       FOO_glib-2.0_VERSION=2.10.3
-#       FOO_gtk+-2.0_VERSION=2.8.20
-#
-#   pkg_check_modules (XRENDER REQUIRED xrender)
-#     defines e.g.:
-#       XRENDER_LIBRARIES=Xrender;X11
-#       XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp
-#
-#   pkg_search_module (BAR     libxml-2.0 libxml2 libxml>=2)
-
-
-# Copyright (C) 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-#
-# Redistribution and use, with or without modification, are permitted
-# provided that the following conditions are met:
-# 
-#    1. Redistributions must retain the above copyright notice, this
-#       list of conditions and the following disclaimer.
-#    2. The name of the author may not be used to endorse or promote
-#       products derived from this software without specific prior
-#       written permission.
-# 
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
-# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-### Common stuff ####
-set(PKG_CONFIG_VERSION 1)
-set(PKG_CONFIG_FOUND   0)
-
-find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-config executable")
-mark_as_advanced(PKG_CONFIG_EXECUTABLE)
-
-if(PKG_CONFIG_EXECUTABLE)
-  set(PKG_CONFIG_FOUND 1)
-endif(PKG_CONFIG_EXECUTABLE)
-
-
-# Unsets the given variables
-macro(_pkgconfig_unset var)
-  set(${var} "" CACHE INTERNAL "")
-endmacro(_pkgconfig_unset)
-
-macro(_pkgconfig_set var value)
-  set(${var} ${value} CACHE INTERNAL "")
-endmacro(_pkgconfig_set)
-
-# Invokes pkgconfig, cleans up the result and sets variables
-macro(_pkgconfig_invoke _pkglist _prefix _varname _regexp)
-  set(_pkgconfig_invoke_result)
-
-  execute_process(
-    COMMAND ${PKG_CONFIG_EXECUTABLE} ${ARGN} ${_pkglist}
-    OUTPUT_VARIABLE _pkgconfig_invoke_result
-    RESULT_VARIABLE _pkgconfig_failed)
-
-  if (_pkgconfig_failed)
-    set(_pkgconfig_${_varname} "")
-    _pkgconfig_unset(${_prefix}_${_varname})
-  else(_pkgconfig_failed)
-    string(REGEX REPLACE "[\r\n]"                  " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}")
-    string(REGEX REPLACE " +$"                     ""  _pkgconfig_invoke_result "${_pkgconfig_invoke_result}")
-
-    if (NOT ${_regexp} STREQUAL "")
-      string(REGEX REPLACE "${_regexp}" " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}")
-    endif(NOT ${_regexp} STREQUAL "")
-
-    separate_arguments(_pkgconfig_invoke_result)
-
-    #message(STATUS "  ${_varname} ... ${_pkgconfig_invoke_result}")
-    set(_pkgconfig_${_varname} ${_pkgconfig_invoke_result})
-    _pkgconfig_set(${_prefix}_${_varname} "${_pkgconfig_invoke_result}")
-  endif(_pkgconfig_failed)
-endmacro(_pkgconfig_invoke)
-
-# Invokes pkgconfig two times; once without '--static' and once with
-# '--static'
-macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp)
-  _pkgconfig_invoke("${_pkglist}" ${_prefix}        ${_varname} "${cleanup_regexp}" ${ARGN})
-  _pkgconfig_invoke("${_pkglist}" ${_prefix} STATIC_${_varname} "${cleanup_regexp}" --static  ${ARGN})
-endmacro(_pkgconfig_invoke_dyn)
-
-# Splits given arguments into options and a package list
-macro(_pkgconfig_parse_options _result _is_req)
-  set(${_is_req} 0)
-  
-  foreach(_pkg ${ARGN})
-    if (_pkg STREQUAL "REQUIRED")
-      set(${_is_req} 1)
-    endif (_pkg STREQUAL "REQUIRED")
-  endforeach(_pkg ${ARGN})
-
-  set(${_result} ${ARGN})
-  list(REMOVE_ITEM ${_result} "REQUIRED")
-endmacro(_pkgconfig_parse_options)
-
-###
-macro(_pkg_check_modules_internal _is_required _is_silent _prefix)
-  _pkgconfig_unset(${_prefix}_FOUND)
-  _pkgconfig_unset(${_prefix}_VERSION)
-  _pkgconfig_unset(${_prefix}_PREFIX)
-  _pkgconfig_unset(${_prefix}_INCLUDEDIR)
-  _pkgconfig_unset(${_prefix}_LIBDIR)
-  _pkgconfig_unset(${_prefix}_LIBS)
-  _pkgconfig_unset(${_prefix}_LIBS_L)
-  _pkgconfig_unset(${_prefix}_LIBS_PATHS)
-  _pkgconfig_unset(${_prefix}_LIBS_OTHER)
-  _pkgconfig_unset(${_prefix}_CFLAGS)
-  _pkgconfig_unset(${_prefix}_CFLAGS_I)
-  _pkgconfig_unset(${_prefix}_CFLAGS_OTHER)
-  _pkgconfig_unset(${_prefix}_STATIC_LIBDIR)
-  _pkgconfig_unset(${_prefix}_STATIC_LIBS)
-  _pkgconfig_unset(${_prefix}_STATIC_LIBS_L)
-  _pkgconfig_unset(${_prefix}_STATIC_LIBS_PATHS)
-  _pkgconfig_unset(${_prefix}_STATIC_LIBS_OTHER)
-  _pkgconfig_unset(${_prefix}_STATIC_CFLAGS)
-  _pkgconfig_unset(${_prefix}_STATIC_CFLAGS_I)
-  _pkgconfig_unset(${_prefix}_STATIC_CFLAGS_OTHER)
-
-  # create a better addressable variable of the modules and calculate its size
-  set(_pkg_check_modules_list ${ARGN})
-  list(LENGTH _pkg_check_modules_list _pkg_check_modules_cnt)
-
-  if(PKG_CONFIG_EXECUTABLE)
-    # give out status message telling checked module
-    if (NOT ${_is_silent})
-      if (_pkg_check_modules_cnt EQUAL 1)
-        message(STATUS "checking for module '${_pkg_check_modules_list}'")
-      else(_pkg_check_modules_cnt EQUAL 1)
-        message(STATUS "checking for modules '${_pkg_check_modules_list}'")
-      endif(_pkg_check_modules_cnt EQUAL 1)
-    endif(NOT ${_is_silent})
-    
-    set(_pkg_check_modules_packages)
-    set(_pkg_check_modules_failed)
-
-    # iterate through module list and check whether they exist and match the required version
-    foreach (_pkg_check_modules_pkg ${_pkg_check_modules_list})
-      set(_pkg_check_modules_exist_query)
-
-      # check whether version is given
-      if (_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
-        string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\1" _pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}")
-        string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\2" _pkg_check_modules_pkg_op   "${_pkg_check_modules_pkg}")
-        string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\3" _pkg_check_modules_pkg_ver  "${_pkg_check_modules_pkg}")
-      else(_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
-        set(_pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}")
-        set(_pkg_check_modules_pkg_op)
-        set(_pkg_check_modules_pkg_ver)
-      endif(_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
-
-      # handle the operands
-      if (_pkg_check_modules_pkg_op STREQUAL ">=")
-        list(APPEND _pkg_check_modules_exist_query --atleast-version)
-      endif(_pkg_check_modules_pkg_op STREQUAL ">=")
-
-      if (_pkg_check_modules_pkg_op STREQUAL "=")
-        list(APPEND _pkg_check_modules_exist_query --exact-version)
-      endif(_pkg_check_modules_pkg_op STREQUAL "=")
-      
-      if (_pkg_check_modules_pkg_op STREQUAL "<=")
-        list(APPEND _pkg_check_modules_exist_query --max-version)
-      endif(_pkg_check_modules_pkg_op STREQUAL "<=")
-
-      # create the final query which is of the format:
-      # * --atleast-version <version> <pkg-name>
-      # * --exact-version <version> <pkg-name>      
-      # * --max-version <version> <pkg-name>
-      # * --exists <pkg-name>
-      if (_pkg_check_modules_pkg_op)
-        list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_ver}")
-      else(_pkg_check_modules_pkg_op)
-        list(APPEND _pkg_check_modules_exist_query --exists)
-      endif(_pkg_check_modules_pkg_op)
-
-      _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_VERSION)
-      _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_PREFIX)
-      _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_INCLUDEDIR)
-      _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_LIBDIR)
-
-      list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_name}")
-      list(APPEND _pkg_check_modules_packages    "${_pkg_check_modules_pkg_name}")
-
-      # execute the query
-      execute_process(
-        COMMAND ${PKG_CONFIG_EXECUTABLE} ${_pkg_check_modules_exist_query}
-        RESULT_VARIABLE _pkgconfig_retval)
-
-      # evaluate result and tell failures
-      if (_pkgconfig_retval)
-        if(NOT ${_is_silent})
-          message(STATUS "  package '${_pkg_check_modules_pkg}' not found")
-        endif(NOT ${_is_silent})
-
-        set(_pkg_check_modules_failed 1)
-      endif(_pkgconfig_retval)
-    endforeach(_pkg_check_modules_pkg)
-
-    if(_pkg_check_modules_failed)
-      # fail when requested
-      if (${_is_required})
-        message(SEND_ERROR "A required package was not found")
-      endif (${_is_required})
-    else(_pkg_check_modules_failed)
-      # when we are here, we checked whether requested modules
-      # exist. Now, go through them and set variables
-      
-      _pkgconfig_set(${_prefix}_FOUND 1)
-      list(LENGTH _pkg_check_modules_packages pkg_count)
-
-      # iterate through all modules again and set individual variables
-      foreach (_pkg_check_modules_pkg ${_pkg_check_modules_packages})
-        # handle case when there is only one package required
-        if (pkg_count EQUAL 1)
-          set(_pkg_check_prefix "${_prefix}")
-        else(pkg_count EQUAL 1)
-          set(_pkg_check_prefix "${_prefix}_${_pkg_check_modules_pkg}")
-        endif(pkg_count EQUAL 1)
-        
-        _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" VERSION    ""   --modversion )
-        _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" PREFIX     ""   --variable=prefix )
-        _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" INCLUDEDIR ""   --variable=includedir )
-        _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" LIBDIR     ""   --variable=libdir )
-
-        message(STATUS "  found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}")
-      endforeach(_pkg_check_modules_pkg)
-
-      # set variables which are combined for multiple modules
-      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARIES           "(^| )-l" --libs-only-l )
-      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARY_DIRS        "(^| )-L" --libs-only-L )
-      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS             ""        --libs )
-      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS_OTHER       ""        --libs-only-other )
-
-      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" INCLUDE_DIRS        "(^| )-I" --cflags-only-I )
-      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS              ""        --cflags )
-      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER        ""        --cflags-only-other )
-    endif(_pkg_check_modules_failed)
-  else(PKG_CONFIG_EXECUTABLE)
-    if (${_is_required})
-      message(SEND_ERROR "pkg-config tool not found")
-    endif (${_is_required})
-  endif(PKG_CONFIG_EXECUTABLE)
-endmacro(_pkg_check_modules_internal)
-
-###
-### User visible macros start here
-###
-
-###
-macro(pkg_check_modules _prefix _module0)
-  # check cached value
-  if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})
-    _pkgconfig_parse_options   (_pkg_modules _pkg_is_required "${_module0}" ${ARGN})
-    _pkg_check_modules_internal("${_pkg_is_required}" 0 "${_prefix}" ${_pkg_modules})
-
-    _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
-  endif(NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})
-endmacro(pkg_check_modules)
-
-###
-macro(pkg_search_module _prefix _module0)
-  # check cached value
-  if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})
-    set(_pkg_modules_found 0)
-    _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required "${_module0}" ${ARGN})
-
-    message(STATUS "checking for one of the modules '${_pkg_modules_alt}'")
-
-    # iterate through all modules and stop at the first working one.
-    foreach(_pkg_alt ${_pkg_modules_alt})
-      if(NOT _pkg_modules_found)
-        _pkg_check_modules_internal(0 1 "${_prefix}" "${_pkg_alt}")
-      endif(NOT _pkg_modules_found)
-
-      if (${_prefix}_FOUND)
-        set(_pkg_modules_found 1)
-      endif(${_prefix}_FOUND)
-    endforeach(_pkg_alt)
-
-    if (NOT ${_prefix}_FOUND)
-      if(${_pkg_is_required})
-        message(SEND_ERROR "None of the required '${_pkg_modules_alt}' found")
-      endif(${_pkg_is_required})
-    endif(NOT ${_prefix}_FOUND)
-    
-    _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
-  endif(NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})  
-endmacro(pkg_search_module)
-
-### Local Variables:
-### mode: cmake
-### End:
Index: code/branches/buildsystem3/cmake/FindTCL.cmake
===================================================================
--- code/branches/buildsystem3/cmake/FindTCL.cmake	(revision 2663)
+++ 	(revision )
@@ -1,90 +1,0 @@
-# - Find Tcl includes and libraries.
-# This module finds if TCL is installed and determines where the
-# include files and libraries are. It also determines what the name of
-# the library is. This code sets the following variables:
-#  TCL_LIBRARY        = path to Tcl library (tcl tcl80)
-#  TCL_LIBRARY_DEBUG  = path to Tcl library (debug)
-#  TCL_INCLUDE_PATH   = path to where tcl.h can be found
-#
-# Several changes and additions by Fabian 'x3n' Landau
-#                 > www.orxonox.net <
-
-IF (TCL_LIBRARY AND TCL_INCLUDE_PATH)
-  SET(TCL_FIND_QUIETLY TRUE)
-ENDIF (TCL_LIBRARY AND TCL_INCLUDE_PATH)
-
-SET (TCLTK_POSSIBLE_LIB_PATHS
-  "${TCL_TCLSH_PATH}/../lib"
-  "${TK_WISH_PATH}/../lib"
-  "${TCL_INCLUDE_PATH}/../lib"
-  "${TK_INCLUDE_PATH}/../lib"
-  "$ENV{ProgramFiles}/Tcl/Lib"
-  "C:/Program Files/Tcl/lib" 
-  "C:/Tcl/lib" 
-  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/lib
-  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/lib
-  /usr/lib 
-  /usr/local/lib
-  /usr/pack/tcltk-8.4.9.linux-mo/lib
-  ../libs/tcl8.5.2/win
-  ../libs/tcl8.5.2/unix
-  ../libs/tcl8.5.2/macosx
-  ${DEPENDENCY_DIR}/tcl-8.5.2/lib
-)
-
-FIND_LIBRARY(TCL_LIBRARY
-  NAMES tcl tcl85 tcl8.5 tcl84 tcl8.4 tcl85t
-  PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
-)
-
-FIND_LIBRARY(TCL_LIBRARY_DEBUG
-  NAMES tcld tcl85d tcl8.5d tcl84d tcl8.4d
-  PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
-)
-
-SET (TCLTK_POSSIBLE_INCLUDE_PATHS
-  ${TCL_TCLSH_PATH}/../include
-  ${TK_WISH_PATH}/../include
-  "${TCL_LIBRARY_PATH}/../include"
-  "${TK_LIBRARY_PATH}/../include"
-  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/include
-  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/include
-  "$ENV{ProgramFiles}/Tcl/include"
-  "C:/Program Files/Tcl/include"
-  C:/Tcl/include
-  /usr/include
-  /usr/local/include
-  /usr/include/tcl8.5
-  /usr/include/tcl8.4
-  ../libs/tcl8.5.2/generic
-  ${DEPENDENCY_DIR}/tcl-8.5.2/include
-)
-
-FIND_PATH(TCL_INCLUDE_PATH tcl.h
-  ${TCL_FRAMEWORK_INCLUDES} ${TCLTK_POSSIBLE_INCLUDE_PATHS}
-)
-
-
-IF (TCL_LIBRARY AND TCL_INCLUDE_PATH)
-  IF (NOT TCL_FIND_QUIETLY)
-    MESSAGE(STATUS "Tcl was found")
-    IF (VERBOSE_FIND)
-      MESSAGE (STATUS "  include path: ${TCL_INCLUDE_PATH}")
-      MESSAGE (STATUS "  library path: ${TCL_LIBRARY}")
-      MESSAGE (STATUS "  libraries:    tcld tcl85d tcl8.5d tcl84d tcl8.4d")
-    ENDIF (VERBOSE_FIND)
-  ENDIF (NOT TCL_FIND_QUIETLY)
-ELSE (TCL_LIBRARY AND TCL_INCLUDE_PATH)
-  IF (NOT TCL_INCLUDE_PATH)
-    MESSAGE(SEND_ERROR "Tcl include path was not found.")
-  ENDIF (NOT TCL_INCLUDE_PATH)
-  IF (NOT TCL_LIBRARY )
-    MESSAGE(SEND_ERROR "Tcl library was not found.")
-  ENDIF (NOT TCL_LIBRARY )
-ENDIF (TCL_LIBRARY AND TCL_INCLUDE_PATH)
-
-IF(TCL_INCLUDE_PATH)
-  IF(TCL_LIBRARY)
-    SET(TCL_FOUND 1)
-  ENDIF(TCL_LIBRARY)
-ENDIF(TCL_INCLUDE_PATH)
Index: code/branches/buildsystem3/cmake/FindVorbis.cmake
===================================================================
--- code/branches/buildsystem3/cmake/FindVorbis.cmake	(revision 2664)
+++ code/branches/buildsystem3/cmake/FindVorbis.cmake	(revision 2664)
@@ -0,0 +1,62 @@
+# - Try to find ogg/vorbis
+# Once done this will define
+#
+#  VORBIS_FOUND - system has vorbis
+#  VORBIS_INCLUDE_DIR
+#  VORBIS_LIBRARIES - vorbis and vorbisfile libraries
+#
+# $VORBISDIR is an environment variable used
+# for finding vorbis.
+#
+# Several changes and additions by Fabian 'x3n' Landau
+# Most of all rewritten by Adrian Friedli
+# Debug versions and simplifications by Reto Grieder
+#                 > 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 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 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/buildsystem3/cmake/FindZLIB.cmake
===================================================================
--- code/branches/buildsystem3/cmake/FindZLIB.cmake	(revision 2663)
+++ 	(revision )
@@ -1,76 +1,0 @@
-# - Find zlib
-# Find the native ZLIB includes and library
-#
-#  ZLIB_INCLUDE_DIR - where to find zlib.h, etc.
-#  ZLIB_LIBRARY     - List of libraries when using zlib.
-#  ZLIB_FOUND       - True if zlib found.
-#
-#  Modified by Nicolas Schlumberger, (c) 2007
-#  to make it work on the Tardis Infrastucture of the ETH Zurich
-#
-# Several changes and additions by Fabian 'x3n' Landau
-#                 > www.orxonox.net <
-
-IF (ZLIB_INCLUDE_DIR)
-  SET(ZLIB_FIND_QUIETLY TRUE)
-ENDIF (ZLIB_INCLUDE_DIR)
-
-IF(UNIX)
-  FIND_PATH(ZLIB_INCLUDE_DIR zlib.h
-    /usr/pack/zziplib-0.13.49-sd/include/
-    /usr/local/include
-    /usr/include
-  )
-
-  SET(ZLIB_NAMES z zlib zdll)
-  FIND_LIBRARY(ZLIB_LIBRARY
-    NAMES ${ZLIB_NAMES}
-    PATHS /usr/pack/zziplib-0.13.49-sd/i686-debian-linux3.1/lib/ /usr/lib /usr/local/lib
-  )
-ENDIF(UNIX)
-
-IF(WIN32)
-  IF(EXISTS "../libs/zlib")
-    SET (ZLIB_LIBRARY_DIR "../libs/zlib")
-  ENDIF(EXISTS "../libs/zlib")
-
-  FIND_PATH(ZLIB_INCLUDE_DIR zlib.h
-    ../libs/zlib/include
-    ${DEPENDENCY_DIR}/zlib-1.2.3/include
-  )
-
-  FIND_LIBRARY(ZLIB_LIBRARY
-    NAMES zlib
-    PATHS ${ZLIB_LIBRARY_DIR}
-    ${DEPENDENCY_DIR}/zlib-1.2.3/lib
-  )
-ENDIF(WIN32)
-
-SET(ZLIB_FOUND FALSE)
-IF (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
-  SET(ZLIB_FOUND TRUE)
-ENDIF (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
-
-IF (ZLIB_FOUND)
-  IF (NOT ZLIB_FIND_QUIETLY)
-    MESSAGE(STATUS "ZLIB was found.")
-    IF (VERBOSE_FIND)
-      MESSAGE (STATUS "  include path: ${ZLIB_INCLUDE_DIR}")
-      MESSAGE (STATUS "  library path: ${ZLIB_LIBRARY}")
-      MESSAGE (STATUS "  libraries:    zlib")
-    ENDIF (VERBOSE_FIND)
-  ENDIF (NOT ZLIB_FIND_QUIETLY)
-ELSE (ZLIB_FOUND)
-  IF (NOT ZLIB_INCLUDE_DIR)
-    MESSAGE(SEND_ERROR "ZLIB include path was not found.")
-  ENDIF (NOT ZLIB_INCLUDE_DIR)
-  IF (NOT ZLIB_LIBRARY)
-    MESSAGE(SEND_ERROR "ZLIB was not found.")
-    MESSAGE(STATUS "Looked for Z libraries named ${ZLIBS_NAMES}.")
-  ENDIF (NOT ZLIB_LIBRARY)
-ENDIF (ZLIB_FOUND)
-
-MARK_AS_ADVANCED(
-  ZLIB_LIBRARY
-  ZLIB_INCLUDE_DIR
-)
Index: code/branches/buildsystem3/cmake/FlagUtilities.cmake
===================================================================
--- code/branches/buildsystem3/cmake/FlagUtilities.cmake	(revision 2664)
+++ code/branches/buildsystem3/cmake/FlagUtilities.cmake	(revision 2664)
@@ -0,0 +1,211 @@
+ #
+ #             ORXONOX - the hottest 3D action shooter ever to exist
+ #                             > www.orxonox.net <
+ #
+ #        This program is free software; you can redistribute it and/or
+ #         modify it under the terms of the GNU General Public License
+ #        as published by the Free Software Foundation; either version 2
+ #            of the License, or (at your option) any later version.
+ #
+ #       This program is distributed in the hope that it will be useful,
+ #        but WITHOUT ANY WARRANTY; without even the implied warranty of
+ #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ #                 GNU General Public License for more details.
+ #
+ #   You should have received a copy of the GNU General Public License along
+ #      with this program; if not, write to the Free Software Foundation,
+ #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ #
+ #
+ #  Author:
+ #    Reto Grieder
+ #  Description:
+ #    Sets the compiler/linker flags. After the flags you can specify more args:
+ #    Release, Debug, RelWithDebInfo, MinSizeRel: Build configs (inclusive)
+ #    ReleaseAll: Sets the flags of all three release builds
+ #    CACHE: Values are witten with SET_CACHE (see above)
+ #    FORCE: When writing to the cache, the values are set anyway
+ #    Any variable names (like WIN32, MSVC, etc.): Condition (combined with AND)
+ #    You can suffix the condition with a NOT if you wish
+ #  Functions:
+ #    [ADD/SET/REMOVE]_[COMPILER/LINKER]_FLAGS
+ #  Caution: -If you use CACHE after calling the macro without CACHE, the value
+ #            Will not get written unless FORCE is specified.
+ #          - Also be aware to always specify the flags in quotes.
+ #  Example:
+ #    REMOVE_COMPILER_FLAGS("/Gm "asdf" -q"test -foo" CXX ReleaseAll NOT UNIX)
+ #    This will only remove the CXX (C++) flags on a non Unix system for the
+ #    Release, RelWithDebInfo and MinSizeRel configurations. The macros should
+ #    be able to cope with "test -foo" that is like another flag in the string.
+ #
+
+# Write to the cache by force, but only if the user didn't edit the value
+# Additional argument is the value (may also be a list)
+MACRO(SET_CACHE _varname _type _docstring)
+  SET(_value ${ARGN})
+  IF(NOT "${_type}" MATCHES "^(STRING|BOOL|PATH|FILEPATH)$")
+    MESSAGE(FATAL_ERROR "${_type} is not a valid CACHE entry type")
+  ENDIF()
+
+  IF(NOT DEFINED _INTERNAL_${_varname} OR "${_INTERNAL_${_varname}}" STREQUAL "${${_varname}}")
+    SET(${_varname} "${_value}" CACHE ${_type} "${_docstring}" FORCE)
+    SET(_INTERNAL_${_varname} "${_value}" CACHE INTERNAL "Do not edit in any case!")
+  ENDIF()
+ENDMACRO(SET_CACHE)
+
+# Separates a string of flags. " -" or " /" denotes the start of a flag.
+# The same sequence inside double quotation marks is ignored.
+# Spaces not within quotes are cleaned meaningfully.
+# This macro cannot cope with semicolons in the flag string!
+MACRO(SEPARATE_FLAGS _flags _output_variable)
+  SET(_flags_prep " ${_flags} -")
+  STRING(REPLACE " " " ;" _flag_chunks ${_flags_prep}) # Max loop iterations
+  SET(_flag_string)
+  SET(_parsed_flags)
+  # Loop is necessary because the regex engine is greedy
+  FOREACH(_chunk ${_flag_chunks})
+    SET(_flag_string "${_flag_string}${_chunk}")
+    # Replace all " -" and " /" inside quotation marks
+    STRING(REGEX REPLACE "^(([^\"]*\"[^\"]*\")*[^\"]*\"[^\"]*) [/-]([^\"]*\")"
+           "\\1@39535493@\\3" _flag_string "${_flag_string}")
+    # Extract one flag if possible
+    SET(_flag)
+    STRING(REGEX REPLACE "^.* [/-](.+)( [/-].*$)" "-\\1" _flag "${_flag_string}")
+    STRING(REGEX REPLACE "^.* [/-](.+)( [/-].*$)" "\\2"  _flag_string "${_flag_string}")
+    IF(NOT _flag STREQUAL _flag_string)
+      LIST(APPEND _parsed_flags "${_flag}")
+    ENDIF(NOT _flag STREQUAL _flag_string)
+  ENDFOREACH(_chunk)
+
+  # Re-replace all " -" and " /" inside quotation marks
+  STRING(REGEX REPLACE "@39535493@" " -" ${_output_variable} "${_parsed_flags}")
+ENDMACRO(SEPARATE_FLAGS)
+
+# Internal macro, do not use
+# Modifies the flags according to the mode: set, add or remove
+# Also sets flags according to the CACHE and FORCE parameter.
+# If only CACHE is specified, SET_CACHE() is used.
+MACRO(_INTERNAL_PARSE_FLAGS _mode _flags _varname _write_to_cache _force)
+  SEPARATE_FLAGS("${_flags}" _arg_flag_list)
+
+  IF("${_mode}" STREQUAL "SET")
+    # SET
+    SET(_flag_list "${_arg_flag_list}")
+  ELSE()
+    # ADD or REMOVE
+    SEPARATE_FLAGS("${${_varname}}" _flag_list)
+    FOREACH(_flag ${_arg_flag_list})
+      LIST(${_mode} _flag_list "${_flag}")
+    ENDFOREACH(_flag)
+  ENDIF()
+
+  LIST(REMOVE_DUPLICATES _flag_list)
+  LIST(SORT _flag_list)
+  STRING(REPLACE ";" " " _flag_list "${_flag_list}")
+
+  IF(_write_to_cache)
+    IF(_force)
+      SET(${_varname} "${_flag_list}" CACHE STRING "${${_varname}}" FORCE)
+      SET(${_varname} "${_flag_list}" CACHE STRING "${${_varname}}" FORCE)
+    ELSE()
+      SET_CACHE(${_varname} STRING "${${_varname}}" "${_flag_list}")
+    ENDIF()
+  ELSE()
+    SET(${_varname} "${_flag_list}")
+  ENDIF()
+ENDMACRO(_INTERNAL_PARSE_FLAGS)
+
+# Internal macro, do not use
+# Parses the given additional arguments and sets the flags to the
+# corresponding variables.
+MACRO(_INTERNAL_PARSE_FLAGS_ARGS _mode _keys _key_postfix _flags)
+  SET(_langs)
+  SET(_build_types)
+  SET(_cond TRUE)
+  SET(_invert_condition FALSE)
+  SET(_write_to_cache FALSE)
+  SET(_force FALSE)
+  STRING(REPLACE ";" "|" _key_regex "${_keys}")
+  SET(_key_regex "^(${_key_regex})$")
+
+  FOREACH(_arg ${ARGN})
+    IF(_arg MATCHES "${_key_regex}")
+      LIST(APPEND _langs "${_arg}")
+    ELSEIF(   _arg MATCHES "^(Debug|Release|MinSizeRel|RelWithDebInfo)$"
+           OR _arg MATCHES "^(DEBUG|RELEASE|MINSIZEREL|RELWITHDEBINFO)$")
+      STRING(TOUPPER "${_arg}" _upper_arg)
+      LIST(APPEND _build_types ${_upper_arg})
+    ELSEIF(_arg STREQUAL "ReleaseAll")
+      LIST(APPEND _build_types RELEASE MINSIZEREL RELWITHDEBINFO)
+    ELSEIF(_arg STREQUAL "CACHE")
+      SET(_write_to_cache TRUE)
+    ELSEIF(_arg STREQUAL "FORCE")
+      SET(_force TRUE)
+    ELSEIF(_arg MATCHES "^[Nn][Oo][Tt]$")
+      SET(_invert_condition TRUE)
+    ELSE()
+      IF(_invert_condition)
+        SET(_invert_condition FALSE)
+    IF(${_arg})
+          SET(_arg_cond FALSE)
+    ELSE()
+          SET(_arg_cond TRUE)
+    ENDIF()
+      ELSE()
+        SET(_arg_cond ${${_arg}})
+      ENDIF()
+      IF(_cond AND _arg_cond)
+        SET(_cond TRUE)
+      ELSE()
+        SET(_cond FALSE)
+      ENDIF()
+    ENDIF()
+  ENDFOREACH(_arg)
+
+  # No language specified, use all: C and CXX or EXE, SHARED and MODULE
+  IF(NOT DEFINED _langs)
+    SET(_langs ${_keys})
+  ENDIF()
+
+  IF(_cond)
+    FOREACH(_lang ${_langs})
+      SET(_varname "CMAKE_${_lang}${_key_postfix}_FLAGS")
+      IF(DEFINED _build_types)
+        FOREACH(_build_type ${_build_types})
+          _INTERNAL_PARSE_FLAGS(${_mode} "${_flags}" ${_varname}_${_build_type} ${_write_to_cache} ${_force})
+        ENDFOREACH(_build_type)
+      ELSE()
+        _INTERNAL_PARSE_FLAGS(${_mode} "${_flags}" ${_varname} ${_write_to_cache} ${_force})
+      ENDIF()
+    ENDFOREACH(_lang ${_langs})
+  ENDIF(_cond)
+ENDMACRO(_INTERNAL_PARSE_FLAGS_ARGS)
+
+
+# Compiler flags, additional arguments:
+# C, CXX: Specify a language, default is both
+MACRO(SET_COMPILER_FLAGS _flags)
+  _INTERNAL_PARSE_FLAGS_ARGS(SET "C;CXX" "" "${_flags}" "${ARGN}")
+ENDMACRO(SET_COMPILER_FLAGS)
+# Add flags (flags don't get added twice)
+MACRO(ADD_COMPILER_FLAGS _flags)
+  _INTERNAL_PARSE_FLAGS_ARGS(APPEND "C;CXX" "" "${_flags}" "${ARGN}")
+ENDMACRO(ADD_COMPILER_FLAGS)
+# Remove flags
+MACRO(REMOVE_COMPILER_FLAGS _flags)
+  _INTERNAL_PARSE_FLAGS_ARGS(REMOVE_ITEM "C;CXX" "" "${_flags}" "${ARGN}")
+ENDMACRO(REMOVE_COMPILER_FLAGS)
+
+# Linker flags, additional arguments:
+# EXE, SHARED, MODULE: Specify a linker mode, default is all three
+MACRO(SET_LINKER_FLAGS _flags)
+  _INTERNAL_PARSE_FLAGS_ARGS(SET "EXE;SHARED;MODULE" "_LINKER" "${_flags}" "${ARGN}")
+ENDMACRO(SET_LINKER_FLAGS)
+# Add flags (flags don't get added twice)
+MACRO(ADD_LINKER_FLAGS _flags)
+  _INTERNAL_PARSE_FLAGS_ARGS(APPEND "EXE;SHARED;MODULE" "_LINKER" "${_flags}" "${ARGN}")
+ENDMACRO(ADD_LINKER_FLAGS)
+# Remove flags
+MACRO(REMOVE_LINKER_FLAGS _flags)
+  _INTERNAL_PARSE_FLAGS_ARGS(REMOVE_ITEM "EXE;SHARED;MODULE" "_LINKER" "${_flags}" "${ARGN}")
+ENDMACRO(REMOVE_LINKER_FLAGS)
Index: code/branches/buildsystem3/cmake/GenerateToluaBindings.cmake
===================================================================
--- code/branches/buildsystem3/cmake/GenerateToluaBindings.cmake	(revision 2664)
+++ code/branches/buildsystem3/cmake/GenerateToluaBindings.cmake	(revision 2664)
@@ -0,0 +1,70 @@
+ #
+ #             ORXONOX - the hottest 3D action shooter ever to exist
+ #                             > www.orxonox.net <
+ #
+ #        This program is free software; you can redistribute it and/or
+ #         modify it under the terms of the GNU General Public License
+ #        as published by the Free Software Foundation; either version 2
+ #            of the License, or (at your option) any later version.
+ #
+ #       This program is distributed in the hope that it will be useful,
+ #        but WITHOUT ANY WARRANTY; without even the implied warranty of
+ #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ #                 GNU General Public License for more details.
+ #
+ #   You should have received a copy of the GNU General Public License along
+ #      with this program; if not, write to the Free Software Foundation,
+ #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ #
+ #
+ #  Author:
+ #    Adrian Friedli
+ #  Description:
+ #    Sets the CMake options that will generate Tolua++ bindings.
+ #  Parameters:
+ #    _tolua_package - Name of the package, e.g. "Core"
+ #    _target_source_files - Variable name of the target source files, the
+ #                           script will add the generated files to this list.
+ #    ARGN - The header files in the style "INTPUTFILES Foo.h Bar.h"
+ #  Global Variables: (need to be set before)
+ #    TOLUA_PARSER_SOURCE - Lua file with the parser source code
+ #    TOLUA_PARSER_DEPENDENCIES - All the dependent lua files
+ #    ORXONOX_RUNTIME_LIBRARY_DIRECTORY - Working directory
+ #
+
+FUNCTION(GENERATE_TOLUA_BINDINGS _tolua_package _target_source_files)
+  SET(_tolua_inputfiles ${ARGN})
+  LIST(REMOVE_ITEM _tolua_inputfiles "INPUTFILES")
+
+  SET(_tolua_pkgfile "${CMAKE_CURRENT_BINARY_DIR}/tolua.pkg")
+  SET(_tolua_cxxfile "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/ToluaBind${_tolua_package}.cc")
+  SET(_tolua_hfile   "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/ToluaBind${_tolua_package}.h")
+
+  SET(${_target_source_files}
+    ${${_target_source_files}}
+    ${_tolua_cxxfile}
+    ${_tolua_hfile}
+    PARENT_SCOPE
+  )
+  SOURCE_GROUP("Tolua" FILES ${_tolua_cxxfile} ${_tolua_hfile})
+
+  # Create temporary package file
+  FILE(REMOVE ${_tolua_pkgfile})
+  FOREACH(_tolua_inputfile ${_tolua_inputfiles})
+    FILE(APPEND ${_tolua_pkgfile} "\$cfile \"${_tolua_inputfile}\"\n")
+  ENDFOREACH(_tolua_inputfile)
+
+  ADD_CUSTOM_COMMAND(
+    OUTPUT ${_tolua_cxxfile} ${_tolua_hfile}
+    COMMAND tolua++app_orxonox -n ${_tolua_package}
+                               -w ${CMAKE_CURRENT_SOURCE_DIR}
+                               -o ${_tolua_cxxfile}
+                               -H ${_tolua_hfile}
+                               -s ${TOLUA_PARSER_SOURCE}
+                                  ${_tolua_pkgfile}
+    DEPENDS              ${TOLUA_PARSER_DEPENDENCIES}
+    IMPLICIT_DEPENDS CXX ${_tolua_inputfiles}
+    WORKING_DIRECTORY    ${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}
+    COMMENT "Generating tolua bind files for package ${_tolua_package}"
+  )
+ENDFUNCTION(GENERATE_TOLUA_BINDINGS)
Index: code/branches/buildsystem3/cmake/HandleLibraryTypes.cmake
===================================================================
--- code/branches/buildsystem3/cmake/HandleLibraryTypes.cmake	(revision 2664)
+++ code/branches/buildsystem3/cmake/HandleLibraryTypes.cmake	(revision 2664)
@@ -0,0 +1,42 @@
+ #
+ #             ORXONOX - the hottest 3D action shooter ever to exist
+ #                             > www.orxonox.net <
+ #
+ #        This program is free software; you can redistribute it and/or
+ #         modify it under the terms of the GNU General Public License
+ #        as published by the Free Software Foundation; either version 2
+ #            of the License, or (at your option) any later version.
+ #
+ #       This program is distributed in the hope that it will be useful,
+ #        but WITHOUT ANY WARRANTY; without even the implied warranty of
+ #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ #                 GNU General Public License for more details.
+ #
+ #   You should have received a copy of the GNU General Public License along
+ #      with this program; if not, write to the Free Software Foundation,
+ #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ #
+ #
+ #  Author:
+ #    Reto Grieder
+ #  Description:
+ #    Checks debug and optimized libaries and sets the variable ${_name}_LIBRARY
+ #    accordingly. If only an optimized library was found, the "optimized"
+ #    keyword is omitted to support the debug version too.
+ #
+
+FUNCTION(HANDLE_LIBRARY_TYPES _name)
+  # Additional libraries can be added as additional arguments
+  IF(${_name}_LIBRARY_DEBUG AND ${_name}_LIBRARY_OPTIMIZED)
+    SET(${_name}_LIBRARY
+      optimized ${${_name}_LIBRARY_OPTIMIZED} ${ARGN}
+      debug     ${${_name}_LIBRARY_DEBUG}     ${ARGN}
+      PARENT_SCOPE
+    )
+  ELSE()
+    SET(${_name}_LIBRARY
+      ${${_name}_LIBRARY_OPTIMIZED} ${ARGN}
+      PARENT_SCOPE
+     )
+  ENDIF()
+ENDFUNCTION(HANDLE_LIBRARY_TYPES)
Index: code/branches/buildsystem3/cmake/InstallUtilities.cmake
===================================================================
--- code/branches/buildsystem3/cmake/InstallUtilities.cmake	(revision 2664)
+++ code/branches/buildsystem3/cmake/InstallUtilities.cmake	(revision 2664)
@@ -0,0 +1,34 @@
+ #
+ #             ORXONOX - the hottest 3D action shooter ever to exist
+ #                             > www.orxonox.net <
+ #
+ #        This program is free software; you can redistribute it and/or
+ #         modify it under the terms of the GNU General Public License
+ #        as published by the Free Software Foundation; either version 2
+ #            of the License, or (at your option) any later version.
+ #
+ #       This program is distributed in the hope that it will be useful,
+ #        but WITHOUT ANY WARRANTY; without even the implied warranty of
+ #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ #                 GNU General Public License for more details.
+ #
+ #   You should have received a copy of the GNU General Public License along
+ #      with this program; if not, write to the Free Software Foundation,
+ #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ #
+ #
+ #  Author:
+ #    Reto Grieder
+ #  Description:
+ #    Helps configuring the INSTALL command in more global way.
+ #  Parameters:
+ #    Specifiy the targets as additional parameter.
+ #
+
+FUNCTION(ORXONOX_INSTALL)
+  INSTALL(TARGETS ${ARGN}
+    RUNTIME DESTINATION ${ORXONOX_RUNTIME_INSTALL_PATH}
+    LIBRARY DESTINATION ${ORXONOX_LIBRARY_INSTALL_PATH}
+    #ARCHIVE DESTINATION ${ORXONOX_ARCHIVE_INSTALL_PATH}
+  )
+ENDFUNCTION(ORXONOX_INSTALL)
Index: code/branches/buildsystem3/cmake/LibraryConfig.cmake
===================================================================
--- code/branches/buildsystem3/cmake/LibraryConfig.cmake	(revision 2664)
+++ code/branches/buildsystem3/cmake/LibraryConfig.cmake	(revision 2664)
@@ -0,0 +1,201 @@
+ #
+ #             ORXONOX - the hottest 3D action shooter ever to exist
+ #                             > www.orxonox.net <
+ #
+ #        This program is free software; you can redistribute it and/or
+ #         modify it under the terms of the GNU General Public License
+ #        as published by the Free Software Foundation; either version 2
+ #            of the License, or (at your option) any later version.
+ #
+ #       This program is distributed in the hope that it will be useful,
+ #        but WITHOUT ANY WARRANTY; without even the implied warranty of
+ #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ #                 GNU General Public License for more details.
+ #
+ #   You should have received a copy of the GNU General Public License along
+ #      with this program; if not, write to the Free Software Foundation,
+ #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ #
+ #
+ #  Author:
+ #    Reto Grieder
+ #  Description:
+ #    Configures the external libraries. Whenever possible, the find scripts
+ #    from the CMake module path are used, but that required some adjustments
+ #    for certain libraries (Boost, OpenAL, TCL)
+ #
+ 
+INCLUDE(CompareVersionStrings)
+INCLUDE(FindPackageHandleStandardArgs)
+
+# Prevent CMake from finding libraries in the installation folder on windows
+# There might already be an installation from another compiler
+LIST(REMOVE_ITEM CMAKE_SYSTEM_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}")
+LIST(REMOVE_ITEM CMAKE_SYSTEM_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/bin")
+
+############## Platform Scripts #################
+
+# On Windows using a package causes way less problems
+SET(_option_msg "Set this to true to use precompiled dependecy archives")
+IF(WIN32)
+  OPTION(USE_DEPENDENCY_PACKAGE "${_option_msg}" ON)
+ELSE(WIN32)
+  OPTION(USE_DEPENDENCY_PACKAGE "${_option_msg}" FALSE)
+ENDIF(WIN32)
+
+# Scripts for specific library and CMake config
+INCLUDE(LibraryConfigTardis)
+INCLUDE(LibraryConfigApple)
+
+IF(USE_DEPENDENCY_PACKAGE)
+  FIND_PATH(DEPENDENCY_DIR
+    NAMES PackageConfigMSVC.cmake PackageConfigMinGW.cmake
+    PATHS
+      ${CMAKE_SOURCE_DIR}/dependencies
+      ${CMAKE_SOURCE_DIR}/../dependencies
+      ${CMAKE_SOURCE_DIR}/../lib_dist/dependencies
+  )
+  IF(NOT DEPENDENCY_DIR)
+    MESSAGE(STATUS "Warning: Could not find dependency directory."
+                   "Disable LIBRARY_USE_PACKAGE if you have none intalled.")
+  ELSE()
+    FILE(GLOB _package_config_files "${DEPENDENCY_DIR}/PackageConfig*.cmake")
+    FOREACH(_file ${_package_config_files})
+      INCLUDE(${_file})
+    ENDFOREACH(_file)
+
+    # On Windows, DLLs have to be in the executable folder
+    IF(DEP_BINARY_DIR AND WIN32)
+      # When installing a debug version, we really can't know which libraries
+      # are used in released mode because there might be deps of deps.
+      INSTALL(
+        DIRECTORY ${DEP_BINARY_DIR}/
+        DESTINATION bin
+        CONFIGURATIONS Debug
+        REGEX "^.*\\.pdb$" EXCLUDE
+      )
+
+      # Try to filter out all the debug libraries. If the regex doesn't do the
+      # job anymore, simply adjust it.
+      INSTALL(
+        DIRECTORY ${DEP_BINARY_DIR}/
+        DESTINATION bin
+        CONFIGURATIONS Release RelWithDebInfo MinSizeRel
+        REGEX "_[Dd]\\.[a-zA-Z0-9+-]+$|-mt-gd-|^.*\\.pdb$" EXCLUDE
+      )
+    ENDIF(DEP_BINARY_DIR AND WIN32)
+  ENDIF(NOT DEPENDENCY_DIR)
+ENDIF(USE_DEPENDENCY_PACKAGE)
+
+# User script
+SET(LIBRARY_CONFIG_USER_SCRIPT "" CACHE FILEPATH
+    "Specify a CMake script if you wish to write your own library path config.
+     See LibraryConfigTardis.cmake or LibraryConfigMinGW.cmake for examples.")
+IF(LIBRARY_CONFIG_USER_SCRIPT)
+  IF(EXISTS ${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT}.cmake)
+    INCLUDE(${LIBRARY_CONFIG_USER_SCRIPT})
+  ELSEIF(EXISTS ${LIBRARY_CONFIG_USER_SCRIPT})
+    INCLUDE(${LIBRARY_CONFIG_USER_SCRIPT})
+  ELSEIF(EXISTS ${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT})
+    INCLUDE(${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT})
+  ENDIF()
+ENDIF(LIBRARY_CONFIG_USER_SCRIPT)
+
+
+############### Library finding #################
+# Performs the search and sets the variables    #
+
+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 #####
+IF(CEGUILUA_USE_EXTERNAL_LIBRARY)
+  COMPARE_VERSION_STRINGS(${CEGUI_VERSION} "0.6" _version_comparison)
+  IF(version_comparison LESS 0)
+    SET(LUA_VERSION_REQUEST 5.0)
+  ELSE()
+    SET(LUA_VERSION_REQUEST 5.1)
+  ENDIF()
+ELSE()
+  SET(LUA_VERSION_REQUEST 5)
+ENDIF()
+FIND_PACKAGE(Lua ${LUA_VERSION_REQUEST} EXACT REQUIRED)
+
+##### OpenAL #####
+FIND_PACKAGE(OpenAL REQUIRED)
+# Also use parent include dir (without AL/) for ALUT
+IF(OPENAL_INCLUDE_DIR MATCHES "/AL$")
+  GET_FILENAME_COMPONENT(ALT_OPENAL_INCLUDE_DIR ${OPENAL_INCLUDE_DIR} PATH)
+ENDIF()
+SET(OPENAL_INCLUDE_DIRS ${OPENAL_INCLUDE_DIR} ${ALT_OPENAL_INCLUDE_DIR})
+# Notfiy user
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR)
+# Hide variables created by the script
+MARK_AS_ADVANCED(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)
+
+##### Boost #####
+# Expand the next statement if newer boost versions than 1.36.1 are released
+SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0)
+# MSVC seems to be the only compiler requiring date_time
+IF(MSVC)
+  FIND_PACKAGE(Boost 1.34 REQUIRED thread filesystem date_time)
+ELSE(MSVC)
+  FIND_PACKAGE(Boost 1.34 REQUIRED thread filesystem)
+ENDIF(MSVC)
+# Boost 1.35 and newer also need the 'System' library
+IF(NOT Boost_VERSION LESS 103500)
+  FIND_PACKAGE(Boost 1.35 REQUIRED system)
+ENDIF()
+
+####### Static/Dynamic linking options ##########
+
+# On Windows dynamically linked libraries need some special treatment
+# You may want to edit these settings if you provide your own libraries
+# Note: Default option in the libraries vary, but our default option is dynamic
+IF(WIN32)
+  OPTION(LINK_BOOST_DYNAMIC "Link Boost dynamically on Windows" TRUE)
+  OPTION(LINK_CEGUI_DYNAMIC "Link CEGUI dynamicylly on Windows" TRUE)
+  OPTION(LINK_ENET_DYNAMIC  "Link ENet dynamically on Windows" TRUE)
+  OPTION(LINK_OGRE_DYNAMIC  "Link OGRE dynamically on Windows" TRUE)
+  OPTION(LINK_TCL_DYNAMIC   "Link TCL dynamically on Windows" TRUE)
+  OPTION(LINK_ZLIB_DYNAMIC  "Link ZLib dynamically on Windows" TRUE)
+  COMPARE_VERSION_STRINGS("${LUA_VERSION}" "5.1" _version_comparison)
+  IF(_version_comparison LESS 0)
+    OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" FALSE)
+  ELSE(_version_comparison LESS 0)
+    OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" TRUE)
+  ENDIF(_version_comparison LESS 0)
+ENDIF(WIN32)
Index: code/branches/buildsystem3/cmake/LibraryConfigApple.cmake
===================================================================
--- code/branches/buildsystem3/cmake/LibraryConfigApple.cmake	(revision 2664)
+++ code/branches/buildsystem3/cmake/LibraryConfigApple.cmake	(revision 2664)
@@ -0,0 +1,43 @@
+ #
+ #             ORXONOX - the hottest 3D action shooter ever to exist
+ #                             > www.orxonox.net <
+ #
+ #        This program is free software; you can redistribute it and/or
+ #         modify it under the terms of the GNU General Public License
+ #        as published by the Free Software Foundation; either version 2
+ #            of the License, or (at your option) any later version.
+ #
+ #       This program is distributed in the hope that it will be useful,
+ #        but WITHOUT ANY WARRANTY; without even the implied warranty of
+ #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ #                 GNU General Public License for more details.
+ #
+ #   You should have received a copy of the GNU General Public License along
+ #      with this program; if not, write to the Free Software Foundation,
+ #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ #
+ #
+ #  Author:
+ #    Yuning Chai
+ #  Description:
+ #    Sets necessary library options and paths on Mac.
+ #
+ 
+IF(APPLE)
+  MESSAGE(STATUS "Running on Apple. Using customized paths and options.")
+
+  SET(ENV{OGRE_HOME} "/Developer/SDKs/OgreSDK/Dependencies")
+  SET(ENV{CEGUIDIR} "/Developer/SDKs/OgreSDK/Dependencies")
+
+  #MESSAGE(STATUS $ENV{OGRE_HOME})
+
+  SET(CMAKE_FIND_FRAMEWORK "FIRST")
+
+#  SET(OGRE_LIBRARY_OPTIMIZED "/Developer/SDKs/OgreSDK/Dependencies/Ogre.framework/Ogre")
+
+#  SET(CEGUI_LIBRARY_OPTIMIZED "/Developer/SDKs/OgreSDK/Dependencies/CEGUI.framework/CEGUI")
+
+#  SET(OGRE_LIBRARY_OPTIMIZED  "/Developer/SDKs/OgreSDK/Dependencies/Ogre.framework" CACHE STRING "Ogre lib for OSX")
+#  SET(CEGUI_LIBRARY_OPTIMIZED  "/Developer/SDKs/OgreSDK/Dependencies/CEGUI.framework" CACHE STRING "CEGUI lib for OSX")
+
+ENDIF(APPLE)
Index: code/branches/buildsystem3/cmake/LibraryConfigTardis.cmake
===================================================================
--- code/branches/buildsystem3/cmake/LibraryConfigTardis.cmake	(revision 2664)
+++ code/branches/buildsystem3/cmake/LibraryConfigTardis.cmake	(revision 2664)
@@ -0,0 +1,54 @@
+ #
+ #             ORXONOX - the hottest 3D action shooter ever to exist
+ #                             > www.orxonox.net <
+ #
+ #        This program is free software; you can redistribute it and/or
+ #         modify it under the terms of the GNU General Public License
+ #        as published by the Free Software Foundation; either version 2
+ #            of the License, or (at your option) any later version.
+ #
+ #       This program is distributed in the hope that it will be useful,
+ #        but WITHOUT ANY WARRANTY; without even the implied warranty of
+ #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ #                 GNU General Public License for more details.
+ #
+ #   You should have received a copy of the GNU General Public License along
+ #      with this program; if not, write to the Free Software Foundation,
+ #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ #
+ #
+ #  Author:
+ #    Adrian Friedli
+ #  Description:
+ #    Sets the correct find script paths on the ETH Tardis workstations.
+ #    Also sets the TARDIS variable.
+ #
+
+IF(UNIX AND NOT APPLE)
+  FILE(STRINGS /etc/hostname HOSTNAME LIMIT_COUNT 1)
+  IF(${HOSTNAME} MATCHES "^tardis-[a-z][0-9][0-9]$")
+    SET (TARDIS ON)
+  ENDIF()
+ENDIF()
+
+IF(TARDIS)
+  MESSAGE(STATUS "Running on D-ITET isg.ee Tardis Computer. Using customized paths.")
+
+  # We cannot use the default compiler (why?)
+  SET(CMAKE_C_COMPILER "gcc-4.1")
+  SET(CMAKE_CXX_COMPILER "g++-4.1")
+
+  # Note: When setting ENV${} variables, make sure to use quotes when
+  #       having multiple directories.
+  SET(BOOST_INCLUDEDIR "/usr/pack/boost-1.34.1-sd/include")
+  SET(BOOST_LIBRARYDIR "/usr/pack/boost-1.34.1-sd/i686-debian-linux3.1/lib")
+  SET(ENV{CEGUIDIR}    "/usr/pack/cegui-0.5.0-sd;/usr/pack/cegui-0.5.0-sd/i686-debian-linux3.1")
+  SET(ENV{ENETDIR}     "/usr/pack/enet-2007-sd;/usr/pack/enet-2007-sd/i686-debian-linux3.1")
+  SET(ENV{ALUTDIR}     "/usr/pack/openal-0.0.8-cl;/usr/pack/openal-0.0.8-cl/i686-debian-linux3.1")
+  SET(ENV{OGGDIR}      "/usr/pack/oggvorbis-1.0-ds;/usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0")
+  SET(ENV{VORBISDIR}   "/usr/pack/oggvorbis-1.0-ds;/usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0")
+  SET(ENV{LUA_DIR}     "/usr/pack/lua-5.0.3-sd;/usr/pack/lua-5.0.3-sd/i686-debian-linux3.1")
+  SET(ENV{OGRE_HOME}   "/usr/pack/ogre-1.4.5-sd;/usr/pack/ogre-1.4.5-sd/i686-debian-linux3.1")
+  SET(ENV{OPENALDIR}   "/usr/pack/openal-0.0.8-cl;/usr/pack/openal-0.0.8-cl/i686-debian-linux3.1")
+  #SET(TCL_INCLUDE_PATH "/usr/pack/tcltk-8.4.9.linux-mo/include")
+ENDIF(TARDIS)
Index: code/branches/buildsystem3/cmake/SourceFileUtilities.cmake
===================================================================
--- code/branches/buildsystem3/cmake/SourceFileUtilities.cmake	(revision 2664)
+++ code/branches/buildsystem3/cmake/SourceFileUtilities.cmake	(revision 2664)
@@ -0,0 +1,73 @@
+ #
+ #             ORXONOX - the hottest 3D action shooter ever to exist
+ #                             > www.orxonox.net <
+ #
+ #        This program is free software; you can redistribute it and/or
+ #         modify it under the terms of the GNU General Public License
+ #        as published by the Free Software Foundation; either version 2
+ #            of the License, or (at your option) any later version.
+ #
+ #       This program is distributed in the hope that it will be useful,
+ #        but WITHOUT ANY WARRANTY; without even the implied warranty of
+ #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ #                 GNU General Public License for more details.
+ #
+ #   You should have received a copy of the GNU General Public License along
+ #      with this program; if not, write to the Free Software Foundation,
+ #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ #
+ #
+ #  Author:
+ #    Reto Grieder
+ #  Description:
+ #    Several functions that help organising the source tree.
+ #    [ADD/SET]_SOURCE_FILES - Writes source files to the cache by force and
+ #                             adds the current directory.
+ #    GET_ALL_HEADER_FILES - Finds all header files recursively.
+ #    GENERATE_SOURCE_GROUPS - Set Visual Studio source groups.
+ #
+
+# Adds source files with the full path to a list
+FUNCTION(ADD_SOURCE_FILES _varname)
+  # Prefix the full path
+  SET(_fullpath_sources)
+  FOREACH(_file ${ARGN})
+    GET_SOURCE_FILE_PROPERTY(_filepath ${_file} LOCATION)
+    LIST(APPEND _fullpath_sources ${_filepath})
+  ENDFOREACH(_file)
+  # Write into the cache to avoid variable scoping in subdirs
+  SET(${_varname} ${${_varname}} ${_fullpath_sources} CACHE INTERNAL "Do not edit")
+ENDFUNCTION(ADD_SOURCE_FILES)
+
+
+# Sets source files with the full path
+FUNCTION(SET_SOURCE_FILES _varname)
+  # Prefix the full path
+  SET(_fullpath_sources)
+  FOREACH(_file ${ARGN})
+    GET_SOURCE_FILE_PROPERTY(_filepath ${_file} LOCATION)
+    LIST(APPEND _fullpath_sources ${_filepath})
+  ENDFOREACH(_file)
+  # Write into the cache to avoid variable scoping in subdirs
+  SET(${_varname} ${_fullpath_sources} CACHE INTERNAL "Do not edit")
+ENDFUNCTION(SET_SOURCE_FILES)
+
+
+# Search the entire directory tree for header files and add them to a variable
+MACRO(GET_ALL_HEADER_FILES _target_varname)
+  FILE(GLOB_RECURSE ${_target_varname} ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
+ENDMACRO(GET_ALL_HEADER_FILES)
+
+
+# Generate source groups according to the directory structure
+FUNCTION(GENERATE_SOURCE_GROUPS)
+
+  FOREACH(_file ${ARGN})
+    GET_SOURCE_FILE_PROPERTY(_full_filepath ${_file} LOCATION)
+    FILE(RELATIVE_PATH _relative_path ${CMAKE_CURRENT_SOURCE_DIR} ${_full_filepath})
+    GET_FILENAME_COMPONENT(_relative_path ${_relative_path} PATH)
+    STRING(REPLACE "/" "\\\\" _group_path "${_relative_path}")
+    SOURCE_GROUP("Source\\${_group_path}" FILES ${_file})
+  ENDFOREACH(_file)
+
+ENDFUNCTION(GENERATE_SOURCE_GROUPS)
