Index: code/branches/buildsystem2/bin-config/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/bin-config/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/bin-config/CMakeLists.txt	(revision 2621)
@@ -73,4 +73,5 @@
     STRING(REGEX REPLACE "^([A-Z]\\:)\\/.*$" "\\1" WINDOWS_DRIVE_CHANGE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
     STRING(REPLACE "/" "\\" CMAKE_RUNTIME_OUTPUT_DIRECTORY_WINDOWS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
+    STRING(REPLACE "/" "\\" ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS ${ORXONOX_RUNTIME_LIBRARY_DIRECTORY})
   ELSE(UNIX)
     SET(RUN_SCRIPT run)
Index: code/branches/buildsystem2/bin-config/run.bat
===================================================================
--- code/branches/buildsystem2/bin-config/run.bat	(revision 2620)
+++ code/branches/buildsystem2/bin-config/run.bat	(revision 2621)
@@ -1,4 +1,4 @@
 title @PROJECT_NAME@
-path @ORXONOX_LIBRARY_BIN_DIR@;%path%
+path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path%
 @WINDOWS_DRIVE_CHANGE@
 cd @CMAKE_RUNTIME_OUTPUT_DIRECTORY_WINDOWS@
Index: code/branches/buildsystem2/cmake/AddSourceFiles.cmake
===================================================================
--- code/branches/buildsystem2/cmake/AddSourceFiles.cmake	(revision 2620)
+++ 	(revision )
@@ -1,66 +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
-
-# BIG FAT NOTE:
-# There's possibly a bug in the CMake behaviour when using PARENT_SCOPE.
-# It seems like the parent variable doesn't get updated locally but written
-# correclty to the parent scope. So accessing a parent variable will always
-# return its value BEFORE the local scope was created! Mind this when
-# updating to a new CMake version.
-
-# Adds source files to the internal handler
-MACRO(ADD_SOURCE_FILES)
-  
-  # Write to parent scoped variables AND to our own scope
-  # (Also see the big fat note at the beginning of the file)
-  # --> _source_files_internal_parent stays constant here, not matter what!
-  SET(_source_files_internal_local ${_source_files_internal_local} ${ARGN})
-  SET(_source_files_internal_parent ${_source_files_internal_local} PARENT_SCOPE)
-
-ENDMACRO(ADD_SOURCE_FILES)
-
-
-# Adds a subdirectory to the internal souce file handler
-MACRO(ADD_SOURCE_DIRECTORY _directory)
-
-  # Save variable
-  SET(_source_files_internal_temp ${_source_files_internal_local})
-  # Clear the local variable because we use it in the child scope
-  SET(_source_files_internal_local)
-
-  # Subfolder puts source files into CMake variable _source_files_internal_parent
-  ADD_SUBDIRECTORY(${_directory})
-  # Recover our own local variable
-  SET(_source_files_internal_local ${_source_files_internal_temp})
-
-  # Put the directory name in front of each source file from the subfolder
-  SET(_source_files_internal_temp)
-  FOREACH(_source_file ${_source_files_internal_parent})
-    LIST(APPEND _source_files_internal_temp "${_directory}/${_source_file}")
-  ENDFOREACH(_source_file)
-
-  # Add the content of the temporary list
-  ADD_SOURCE_FILES(${_source_files_internal_temp})
-
-ENDMACRO(ADD_SOURCE_DIRECTORY)
-
-# Writes the content from the internal variables to a user specified one
-MACRO(WRITE_SOURCE_FILES _variable_name)
-
-  SET(${_variable_name} ${_source_files_internal_local})
-
-ENDMACRO(WRITE_SOURCE_FILES)
Index: code/branches/buildsystem2/cmake/BuildConfig.cmake
===================================================================
--- code/branches/buildsystem2/cmake/BuildConfig.cmake	(revision 2620)
+++ code/branches/buildsystem2/cmake/BuildConfig.cmake	(revision 2621)
@@ -35,7 +35,7 @@
 # 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_LIBRARY_BIN_DIR)
-  SET(ORXONOX_LIBRARY_BIN_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
-ENDIF(NOT ORXONOX_LIBRARY_BIN_DIR)
+IF(NOT ORXONOX_RUNTIME_LIBRARY_DIRECTORY)
+  SET(ORXONOX_RUNTIME_LIBRARY_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
+ENDIF(NOT ORXONOX_RUNTIME_LIBRARY_DIRECTORY)
 
 # Set Debug build to default when not having multi-config generator like msvc
@@ -54,11 +54,13 @@
 
 OPTION(EXTRA_WARNINGS "Enable some extra warnings (heavily pollutes the output)")
-IF(EXTRA_WARNINGS)
-  SET(ORXONOX_WARNING_FLAGS "-Wextra --Wno-unsued-parameter")
-ELSE(EXTRA_WARNINGS)
-  SET(ORXONOX_WARNING_FLAGS "-Wall")
-ENDIF(EXTRA_WARNINGS)
 
-SET(ORXONOX_MEDIA_DIRECTORY "${CMAKE_SOURCE_DIR}/../media")
+# Specify media directory
+GET_FILENAME_COMPONENT(_media_path "${CMAKE_SOURCE_DIR}/../media" ABSOLUTE)
+SET(ORXONOX_MEDIA_DIRECTORY ${_media_path} CACHE PATH
+    "Location of the media directory.")
+IF(NOT EXISTS ${ORXONOX_MEDIA_DIRECTORY})
+  MESSAGE(STATUS "Warning: The media directory does not exist ${ORXONOX_MEDIA_DIRECTORY}")
+ENDIF(NOT EXISTS ${ORXONOX_MEDIA_DIRECTORY})
+
 # More plugins: Plugin_BSPSceneManager, Plugin_OctreeSceneManager
 # Render systems may be optional, but at least one has to be found in FindOgre
@@ -78,10 +80,28 @@
 
 ############## Compiler Config ##################
-INCLUDE(BuildConfigGCC)
-INCLUDE(BuildConfigMSVC)
-# User can create his own file if required
-IF(EXISTS ${CMAKE_BINARY_DIR}/BuildConfigUser.cmake)
-  INCLUDE(${CMAKE_BINARY_DIR}/BuildConfigUser)
-ENDIF(EXISTS ${CMAKE_BINARY_DIR}/BuildConfigUser.cmake)
+
+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(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUC)
+  MESSAGE(STATUS "Warning: Your compiler is not officially supported.")
+ENDIF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUC)
+
+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(EXISTS ${CMAKE_MODULE_PATH}/${BUILD_CONFIG_USER_SCRIPT}.cmake)
+ENDIF(BUILD_CONFIG_USER_SCRIPT)
 
 
@@ -97,16 +117,15 @@
 
 
-################### Macros ######################
+####### Static/Dynamic linking defines ##########
 
-# Also define macros to easily extend the compiler flags
-# Additional argument is a condition
-MACRO(ADD_CXX_FLAGS _flag _cond)
-  IF(${_cond})
-    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}")
-  ENDIF(${_cond})
-ENDMACRO(ADD_CXX_FLAGS _flag)
-MACRO(ADD_C_FLAGS _flag)
-  IF(${_cond})
-    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_flag}")
-  ENDIF(${_cond})
-ENDMACRO(ADD_C_FLAGS _flag)
+# 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/buildsystem2/cmake/BuildConfigGCC.cmake
===================================================================
--- code/branches/buildsystem2/cmake/BuildConfigGCC.cmake	(revision 2620)
+++ code/branches/buildsystem2/cmake/BuildConfigGCC.cmake	(revision 2621)
@@ -26,21 +26,29 @@
  #
 
-###### Default Compiler/Linker Options ##########
-# Most people use GCC to compile orxonox, so use that as default
+# Also include environment flags. Could cause conflicts though
+SET_COMPILER_FLAGS("$ENV{CXXFLAGS}" CXX CACHE)
+SET_COMPILER_FLAGS("$ENV{CFLAGS}"   C   CACHE)
 
-SET(CMAKE_C_FLAGS   "$ENV{CFLAGS}   ${ORXONOX_WARNING_FLAGS} -fPIC")
-SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} ${ORXONOX_WARNING_FLAGS} -fPIC")
-# These flags are added to the flags above
-SET(CMAKE_C_FLAGS_DEBUG            "    -g -ggdb")
-SET(CMAKE_CXX_FLAGS_DEBUG          "    -g -ggdb")
-SET(CMAKE_C_FLAGS_RELEASE          "-O3          -DNDEBUG")
-SET(CMAKE_CXX_FLAGS_RELEASE        "-O3          -DNDEBUG")
-SET(CMAKE_C_FLAGS_RELWITHDEBINFO   "-O2 -g -ggdb -DNDEBUG")
-SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -ggdb -DNDEBUG")
-SET(CMAKE_C_FLAGS_MINSIZEREL       "-Os          -DNDEBUG")
-SET(CMAKE_CXX_FLAGS_MINSIZEREL     "-Os          -DNDEBUG")
+# 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)
 
-SET(CMAKE_LD_FLAGS "$ENV{LDFLAGS}")
-SET(CMAKE_EXE_LINKER_FLAGS    " --no-undefined")
-SET(CMAKE_SHARED_LINKER_FLAGS " --no-undefined")
-SET(CMAKE_MODULE_LINKER_FLAGS " --no-undefined")
+# 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(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
+
+# Increase warning level if requested
+IF(EXTRA_WARNINGS)
+  REMOVE_COMPILER_FLAGS("-Wall" CACHE)
+  ADD_COMPILER_FLAGS("-Wextra --Wno-unused-parameter" CACHE)
+ELSE(EXTRA_WARNINGS)
+  REMOVE_COMPILER_FLAGS("-Wextra --Wno-unused-parameter" CACHE)
+  ADD_COMPILER_FLAGS("-Wall" CACHE)
+ENDIF(EXTRA_WARNINGS) 
+
+# General linker flags
+SET_LINKER_FLAGS("--no-undefined" CACHE)
Index: code/branches/buildsystem2/cmake/BuildConfigMSVC.cmake
===================================================================
--- code/branches/buildsystem2/cmake/BuildConfigMSVC.cmake	(revision 2620)
+++ code/branches/buildsystem2/cmake/BuildConfigMSVC.cmake	(revision 2621)
@@ -25,66 +25,43 @@
  #      ...
  #
- 
-###################### MSVC config ########################
-# Set the library directories and special options when
-# using Visual Studio.
-###########################################################
 
-IF (MSVC)
+#################### Compiler Flags #####################
 
-  #################### 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
 
-  # /MD    Minimal Rebuild
-  # /RTC1  Both basic runtime checks
-  # /MD[d] Multithreaded [debug] DLL
-  # /Zi    Program Database
-  # /ZI    Program Database for Edit & Continue
-  # /WX    Warning Level X
-  # /wdX   Disable specific warning X
-  SET(MSVC_CL_FLAGS "
-    /D WIN32 /D __WIN32__ /D _WIN32 /D _WINDOWS
-    /D BOOST_ALL_DYN_LINK
-    /D OIS_DYNAMIC_LIB
-    /D ZLIB_WINAPI
-    /D LUA_BUILD_AS_DLL
-    /D _CRT_SECURE_NO_WARNINGS
-    /W3
-    /EHsc
-    /wd4522
-    /wd4251
-    /wd4800
-  ")
-  SET(CMAKE_C_FLAGS                  "${MSVC_CL_FLAGS}")
-  SET(CMAKE_CXX_FLAGS                "${MSVC_CL_FLAGS}")
+# 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)
+ADD_COMPILER_FLAGS("-w44522 -w44251 -w44800"   CACHE)
 
-  # Note: ${CMAKE_C_FLAGS} get added to the specific ones
-  SET(MSVC_CL_FLAGS_DEBUG            "/MDd /Od  /Zi /Gm /RTC1")
-  SET(MSVC_CL_FLAGS_RELEASE          "/MD  /MP2 /D TOLUA_RELEASE")
-  SET(CMAKE_C_FLAGS_DEBUG            "${MSVC_CL_FLAGS_DEBUG}")
-  SET(CMAKE_CXX_FLAGS_DEBUG          "${MSVC_CL_FLAGS_DEBUG}")
-  SET(CMAKE_C_FLAGS_RELEASE          "${MSVC_CL_FLAGS_RELEASE} /O2")
-  SET(CMAKE_CXX_FLAGS_RELEASE        "${MSVC_CL_FLAGS_RELEASE} /O2")
-  SET(CMAKE_C_FLAGS_RELWITHDEBINFO   "${MSVC_CL_FLAGS_RELEASE} /O2 /Zi")
-  SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${MSVC_CL_FLAGS_RELEASE} /O2 /Zi")
-  SET(CMAKE_C_FLAGS_MINSIZEREL       "${MSVC_CL_FLAGS_RELEASE} /O1")
-  SET(CMAKE_CXX_FLAGS_MINSIZEREL     "${MSVC_CL_FLAGS_RELEASE} /O1")
+# Increase warning level if requested
+IF(EXTRA_WARNINGS)
+  REMOVE_COMPILER_FLAGS("-W1 -W2 -W3" CACHE)
+  ADD_COMPILER_FLAGS   ("-W4" CACHE)
+ELSE(EXTRA_WARNINGS)
+  REMOVE_COMPILER_FLAGS("-W1 -W2 -W4" CACHE)
+  ADD_COMPILER_FLAGS   ("-W3" CACHE)
+ENDIF(EXTRA_WARNINGS) 
 
-  ##################### Linker Flags ######################
+# 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)
 
-  SET(MSVC_LINKER_FLAGS                        "")
-  SET(CMAKE_EXE_LINKER_FLAGS                   "${MSVC_LINKER_FLAGS}")
-  SET(CMAKE_SHARED_LINKER_FLAGS                "${MSVC_LINKER_FLAGS}")
+##################### Linker Flags ######################
 
-  # Note: ${CMAKE_EXE_LINKER_FLAGS} get added to the specific ones
-  SET(MSVC_LINKER_FLAGS_DEBUG                  "/INCREMENTAL:YES")
-  SET(MSVC_LINKER_FLAGS_RELEASE                "/INCREMENTAL:NO /OPT:REF /OPT:ICF")
-  SET(CMAKE_EXE_LINKER_FLAGS_DEBUG             "${MSVC_LINKER_FLAGS_DEBUG}")
-  SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG          "${MSVC_LINKER_FLAGS_DEBUG}")
-  SET(CMAKE_EXE_LINKER_FLAGS_RELEASE           "${MSVC_LINKER_FLAGS_RELEASE}")
-  SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE        "${MSVC_LINKER_FLAGS_RELEASE}")
-  SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO    "${MSVC_LINKER_FLAGS_RELEASE}")
-  SET(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${MSVC_LINKER_FLAGS_RELEASE}")
-  SET(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL        "${MSVC_LINKER_FLAGS_RELEASE}")
-  SET(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL     "${MSVC_LINKER_FLAGS_RELEASE}")
-
-ENDIF (MSVC)
+# CMake default flags: -MANIFEST -STACK:10000000 -machine:I386
+# and INCREMENTAL and DEBUG for debug versions
+ADD_LINKER_FLAGS("-OPT:REF -OPT:ICF -OPT:NOWIN98" Release MinSizeRel CACHE)
Index: code/branches/buildsystem2/cmake/GenerateToluaBindings.cmake
===================================================================
--- code/branches/buildsystem2/cmake/GenerateToluaBindings.cmake	(revision 2621)
+++ code/branches/buildsystem2/cmake/GenerateToluaBindings.cmake	(revision 2621)
@@ -0,0 +1,53 @@
+#    UseTolua.cmake - CMake Module to generate LUA Bindings with tolua
+#    Copyright (C) 2008  Adrian Friedli
+#
+#    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
+
+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}/ToluaBind${_tolua_package}.cc")
+  SET(_tolua_hfile   "${CMAKE_CURRENT_BINARY_DIR}/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/buildsystem2/cmake/LibraryConfigMSVC.cmake
===================================================================
--- code/branches/buildsystem2/cmake/LibraryConfigMSVC.cmake	(revision 2620)
+++ code/branches/buildsystem2/cmake/LibraryConfigMSVC.cmake	(revision 2621)
@@ -40,5 +40,5 @@
     MESSAGE(FATAL_ERROR "Could not find dependency directory for the Visual Studio libraries")
   ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/dependencies/orxonox_vc8)
-  SET(ORXONOX_LIBRARY_BIN_DIR ${MSVC_LIBRARY_DIR}/bin)
+  SET(ORXONOX_RUNTIME_LIBRARY_DIRECTORY ${MSVC_LIBRARY_DIR}/bin)
 
   # Set variables for the include directories and the libraries
Index: code/branches/buildsystem2/cmake/LibraryConfigMinGW.cmake
===================================================================
--- code/branches/buildsystem2/cmake/LibraryConfigMinGW.cmake	(revision 2620)
+++ code/branches/buildsystem2/cmake/LibraryConfigMinGW.cmake	(revision 2621)
@@ -42,5 +42,5 @@
     MESSAGE(FATAL_ERROR "Could not find dependency directory for the MinGW libraries")
   ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/libs)
-  SET(ORXONOX_LIBRARY_BIN_DIR ${MINGW_LIBRARY_DIR})
+  SET(ORXONOX_RUNTIME_LIBRARY_DIRECTORY ${MINGW_LIBRARY_DIR})
 
   # Note: When setting ENV${} variables, make sure to use quotes when
Index: code/branches/buildsystem2/cmake/UseTolua.cmake
===================================================================
--- code/branches/buildsystem2/cmake/UseTolua.cmake	(revision 2620)
+++ 	(revision )
@@ -1,49 +1,0 @@
-#    UseTolua.cmake - CMake Module to generate LUA Bindings with tolua
-#    Copyright (C) 2008  Adrian Friedli
-#
-#    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(TOLUA _tolua_package _tolua_srcfiles_varname)
-  # TODO: cleaner arguments handling
-  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}/ToluaBind${_tolua_package}.cc")
-  SET(_tolua_hfile   "${CMAKE_CURRENT_BINARY_DIR}/ToluaBind${_tolua_package}.h")
-  SET(${_tolua_srcfiles_varname} ${${_tolua_srcfiles_varname}} ${_tolua_cxxfile})
-
-  # TODO: check secureness of this temporary file
-  FILE(REMOVE ${_tolua_pkgfile})
-  FOREACH(_tolua_inputfile ${_tolua_inputfiles})
-    FILE(APPEND ${_tolua_pkgfile} "\$cfile \"${_tolua_inputfile}\"\n")
-  ENDFOREACH(_tolua_inputfile)
-
-  # Note: Some of the variables are already defined in src/tolua/CMakeLists.txt
-  #       or in the platform config
-  ADD_CUSTOM_COMMAND(
-    OUTPUT ${_tolua_cxxfile} ${_tolua_hfile}
-    COMMAND toluaexe_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_LIBRARY_BIN_DIR}
-    COMMENT "Generating tolua bind files for package ${_tolua_package}"
-  )
-ENDMACRO(TOLUA)
Index: code/branches/buildsystem2/src/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/CMakeLists.txt	(revision 2621)
@@ -1,2 +1,15 @@
+# various macro includes
+INCLUDE(FlagUtilities)
+INCLUDE(SourceFileUtilities)
+INCLUDE(GenerateToluaBindings)
+
+# Use TinyXML++
+ADD_COMPILER_FLAGS("-DTIXML_USE_TICPP")
+# OIS dynamic linking requires macro definition, at least for Windows
+ADD_COMPILER_FLAGS("-DOIS_DYNAMIC_LIB")
+
+OPTION(TOLUA_PARSER_RELEASE "Disable all debug messages from tolua bind files for Release and MinSizeRel build types." FALSE)
+ADD_COMPILER_FLAGS("-DTOLUA_RELEASE" Release MinSizeRel TOLUA_PARSER_RELEASE)
+
 ################ OrxonoxConfig.h ################
 
@@ -4,6 +17,10 @@
 CONFIGURE_FILE(OrxonoxConfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/OrxonoxConfig.h)
 
+
+############## Include Directories ##############
+
 # Set the search paths for include files
 INCLUDE_DIRECTORIES(
+  # External
   ${OGRE_INCLUDE_DIR}
   ${CEGUI_INCLUDE_DIR}
@@ -16,36 +33,31 @@
   ${LUA_INCLUDE_DIR}
   ${TCL_INCLUDE_PATH}
-  ${DirectX_INCLUDE_DIR}
+  ${DIRECTX_INCLUDE_DIR}
   ${ZLIB_INCLUDE_DIR}
-)
 
-# Check whether the required CEGUILua version is even available
-IF(NOT IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ceguilua/ceguilua-${CEGUI_VERSION})
-  MESSAGE(FATAL_ERROR "No matching CEGUILua version shipped with Orxonox (${CEGUI_VERSION})")
-ENDIF(NOT IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ceguilua/ceguilua-${CEGUI_VERSION})
-
-INCLUDE_DIRECTORIES(
-  ceguilua/ceguilua-${CEGUI_VERSION}
-)
-
-INCLUDE_DIRECTORIES(
+  # Internal
   .
   orxonox
-  # Required for tolua bind files that are in the build folder
+  # Required for tolua bind and config files that are in the binary folder
   ${CMAKE_CURRENT_BINARY_DIR}
   ${CMAKE_CURRENT_BINARY_DIR}/orxonox
 )
 
-# Set special macro symbols across all libraries
-ADD_CXX_FLAGS("-DTIXML_USE_TICPP" 1)
-ADD_C_FLAGS  ("-DTIXML_USE_TICPP" 1)
 
-# Include macros
-INCLUDE(AddSourceFiles)
-INCLUDE(UseTolua)
+################ Sub Directories ################
 
-# External libraries, but copied into the repository
+# Third party libraries
 ADD_SUBDIRECTORY(tolua)
-ADD_SUBDIRECTORY(ceguilua)
+
+# Include CEGUILua if not requested otherwise
+IF(CEGUILUA_USE_INTERNAL_LIBRARY)
+  IF(NOT IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ceguilua/ceguilua-${CEGUI_VERSION})
+    MESSAGE(FATAL_ERROR "CEGUILua version not found in src folder. Update list of supported versions in LibraryConfig.cmake!")
+  ENDIF(NOT IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ceguilua/ceguilua-${CEGUI_VERSION})
+
+  INCLUDE_DIRECTORIES(ceguilua/ceguilua-${CEGUI_VERSION})
+  ADD_SUBDIRECTORY(ceguilua)
+ENDIF(CEGUILUA_USE_INTERNAL_LIBRARY)
+
 ADD_SUBDIRECTORY(cpptcl)
 ADD_SUBDIRECTORY(ogreceguirenderer)
@@ -53,8 +65,8 @@
 ADD_SUBDIRECTORY(tinyxml)
 
-# Our own libraries
+# Orxonox code
 ADD_SUBDIRECTORY(util)
 ADD_SUBDIRECTORY(core)
-#ADD_SUBDIRECTORY(audio)
+ADD_SUBDIRECTORY(audio)
 ADD_SUBDIRECTORY(network)
 ADD_SUBDIRECTORY(orxonox)
Index: code/branches/buildsystem2/src/audio/AudioBuffer.h
===================================================================
--- code/branches/buildsystem2/src/audio/AudioBuffer.h	(revision 2620)
+++ code/branches/buildsystem2/src/audio/AudioBuffer.h	(revision 2621)
@@ -33,5 +33,5 @@
 
 #include <string>
-#include <AL/al.h>
+#include <al.h>
 
 namespace orxonox
Index: code/branches/buildsystem2/src/audio/AudioIncludes.h
===================================================================
--- code/branches/buildsystem2/src/audio/AudioIncludes.h	(revision 2620)
+++ code/branches/buildsystem2/src/audio/AudioIncludes.h	(revision 2621)
@@ -39,6 +39,6 @@
 #include <string>
 
-#include <AL/al.h>
-#include <AL/alc.h>
+#include <al.h>
+#include <alc.h>
 #include <AL/alut.h>
 #include <ogg/ogg.h>
Index: code/branches/buildsystem2/src/audio/AudioStream.h
===================================================================
--- code/branches/buildsystem2/src/audio/AudioStream.h	(revision 2620)
+++ code/branches/buildsystem2/src/audio/AudioStream.h	(revision 2621)
@@ -34,5 +34,5 @@
 #include <string>
 #include <iostream>
-#include <AL/al.h>
+#include <al.h>
 #include <vorbis/vorbisfile.h>
 #include <vorbis/codec.h>
Index: code/branches/buildsystem2/src/audio/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/audio/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/audio/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-SET ( AUDIO_SRC_FILES
+SET_SOURCE_FILES(AUDIO_SRC_FILES
   AudioBuffer.cc
   AudioManager.cc
@@ -5,11 +5,14 @@
   AudioStream.cc
 )
+GET_ALL_HEADER_FILES(AUDIO_HDR_FILES)
+SET(AUDIO_FILES ${AUDIO_SRC_FILES} ${AUDIO_HDR_FILES})
+GENERATE_SOURCE_GROUPS(${AUDIO_FILES})
 
-ADD_CXX_FLAGS("-wd4244" MSVC)
+ADD_COMPILER_FLAGS("-w44244" MSVC)
 
 IF (MINGW)
-  ADD_LIBRARY( audio ${AUDIO_SRC_FILES} )
+  ADD_LIBRARY( audio ${AUDIO_FILES})
 ELSE (MINGW)
-  ADD_LIBRARY( audio SHARED ${AUDIO_SRC_FILES} )
+  ADD_LIBRARY( audio SHARED ${AUDIO_FILES})
 ENDIF (MINGW)
 
Index: code/branches/buildsystem2/src/ceguilua/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/ceguilua/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/ceguilua/CMakeLists.txt	(revision 2621)
@@ -28,5 +28,5 @@
 ADD_CUSTOM_COMMAND(
   OUTPUT ${CEGUILUA_BINARY_DIR}/lua_CEGUI.cpp
-  COMMAND toluaexe_orxonox -n CEGUI
+  COMMAND tolua++gen_orxonox -n CEGUI
                              -w ${CEGUILUA_BINARY_DIR}
                              -o lua_CEGUI.cpp
@@ -35,14 +35,18 @@
                                 CEGUI.pkg
   DEPENDS              ${TOLUA_PARSER_DEPENDENCIES}
-  WORKING_DIRECTORY    ${ORXONOX_LIBRARY_BIN_DIR}
+  WORKING_DIRECTORY    ${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}
   COMMENT "Generating tolua bind files for package CEGUILua"
 )
 
-ADD_CXX_FLAGS("-w44996" MSVC)
+ADD_COMPILER_FLAGS("-w44996" MSVC)
 
-ADD_LIBRARY(ceguilua_orxonox SHARED ${CEGUILUA_FILES})
-SET_TARGET_PROPERTIES(ceguilua_orxonox PROPERTIES DEFINE_SYMBOL "CEGUILUA_EXPORTS")
-TARGET_LINK_LIBRARIES(ceguilua_orxonox
-  tolualib_orxonox
+SOURCE_GROUP("Source" FILES ${CEGUILUA_FILES})
+
+SET(CEGUILUA_LIBRARY ceguilua_orxonox)
+SET(CEGUILUA_LIBRARY ${CEGUILUA_LIBRARY} PARENT_SCOPE)
+ADD_LIBRARY(${CEGUILUA_LIBRARY} SHARED ${CEGUILUA_FILES})
+SET_TARGET_PROPERTIES(${CEGUILUA_LIBRARY} PROPERTIES DEFINE_SYMBOL "CEGUILUA_EXPORTS")
+TARGET_LINK_LIBRARIES(${CEGUILUA_LIBRARY}
+  tolua++_orxonox
   ${LUA_LIBRARIES}
   ${CEGUI_LIBRARY}
Index: code/branches/buildsystem2/src/core/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/core/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/core/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+SET_SOURCE_FILES(CORE_SRC_FILES
   Clock.cc
   ConfigFileManager.cc
@@ -42,12 +42,12 @@
   TclThreadManager.cc
 )
+ADD_SUBDIRECTORY(input)
+GET_ALL_HEADER_FILES(CORE_HDR_FILES)
+SET(CORE_FILES ${CORE_SRC_FILES} ${CORE_HDR_FILES})
 
-ADD_SOURCE_DIRECTORY(input)
+GENERATE_SOURCE_GROUPS(${CORE_FILES})
+GENERATE_TOLUA_BINDINGS(Core CORE_FILES INPUTFILES LuaBind.h CommandExecutor.h)
 
-WRITE_SOURCE_FILES(CORE_SRC_FILES)
-
-TOLUA(Core CORE_SRC_FILES INPUTFILES LuaBind.h CommandExecutor.h)
-
-ADD_LIBRARY(core SHARED ${CORE_SRC_FILES})
+ADD_LIBRARY(core SHARED ${CORE_FILES})
 
 SET_TARGET_PROPERTIES(core PROPERTIES DEFINE_SYMBOL "CORE_SHARED_BUILD")
@@ -59,6 +59,6 @@
   cpptcl_orxonox
   ois_orxonox
-  tinyxml_orxonox
-  tolualib_orxonox
+  tinyxml++_orxonox
+  tolua++_orxonox
   util
 )
Index: code/branches/buildsystem2/src/core/input/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/core/input/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/core/input/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(CORE_SRC_FILES
   Button.cc
   CalibratorCallback.cc
Index: code/branches/buildsystem2/src/cpptcl/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/cpptcl/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/cpptcl/CMakeLists.txt	(revision 2621)
@@ -1,6 +1,21 @@
+SET(CPPTCL_FILES
+  CppTcl.h
+  CppTcl.cc
+
+  details/callbacks.h
+  details/callbacks_v.h
+  details/constructors.h
+  details/conversions.h
+  details/dispatchers.h
+  details/metahelpers.h
+  details/methods.h
+  details/methods_v.h
+)
+GENERATE_SOURCE_GROUPS(${CPPTCL_FILES})
+
 IF(MSVC)
-  ADD_LIBRARY(cpptcl_orxonox STATIC cpptcl.cc)
+  ADD_LIBRARY(cpptcl_orxonox STATIC ${CPPTCL_FILES})
 ELSE(MSVC)
-  ADD_LIBRARY(cpptcl_orxonox SHARED cpptcl.cc)
+  ADD_LIBRARY(cpptcl_orxonox SHARED ${CPPTCL_FILES})
 ENDIF(MSVC)
 
Index: code/branches/buildsystem2/src/network/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/network/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/network/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+SET_SOURCE_FILES(NETWORK_SRC_FILES
   ChatListener.cc
   Client.cc
@@ -14,13 +14,14 @@
   Host.cc
 )
+ADD_SUBDIRECTORY(packet)
+GET_ALL_HEADER_FILES(NETWORK_HDR_FILES)
+SET(NETWORK_FILES ${NETWORK_SRC_FILES} ${NETWORK_HDR_FILES})
 
-ADD_SOURCE_DIRECTORY(packet)
-
-WRITE_SOURCE_FILES(NETWORK_SRC_FILES)
+GENERATE_SOURCE_GROUPS(${NETWORK_FILES})
 
 IF(MINGW)
-  ADD_LIBRARY( network ${NETWORK_SRC_FILES} )
+  ADD_LIBRARY(network ${NETWORK_FILES})
 ELSE(MINGW)
-  ADD_LIBRARY( network SHARED ${NETWORK_SRC_FILES} )
+  ADD_LIBRARY(network SHARED ${NETWORK_FILES})
 ENDIF(MINGW)
 
Index: code/branches/buildsystem2/src/network/packet/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/network/packet/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/network/packet/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(NETWORK_SRC_FILES
   Packet.cc
   Chat.cc
Index: code/branches/buildsystem2/src/ogreceguirenderer/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/ogreceguirenderer/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/ogreceguirenderer/CMakeLists.txt	(revision 2621)
@@ -1,10 +1,14 @@
-SET( SRC_FILES
+SET(OCR_FILES
+  OgreCEGUIRenderer.h
+  OgreCEGUIResourceProvider.h
+  OgreCEGUITexture.h
+
   OgreCEGUIRenderer.cpp
   OgreCEGUIResourceProvider.cpp
   OgreCEGUITexture.cpp
 )
+GENERATE_SOURCE_GROUPS(${OCR_FILES})
 
-ADD_LIBRARY(ogreceguirenderer_orxonox SHARED ${SRC_FILES})
-
+ADD_LIBRARY(ogreceguirenderer_orxonox SHARED ${OCR_FILES})
 SET_TARGET_PROPERTIES(ogreceguirenderer_orxonox PROPERTIES DEFINE_SYMBOL "OGRE_GUIRENDERER_EXPORTS")
 TARGET_LINK_LIBRARIES(ogreceguirenderer_orxonox
Index: code/branches/buildsystem2/src/ois/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/ois/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/ois/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,18 @@
-SET( OIS_SRC_FILES
+SET_SOURCE_FILES(OIS_FILES
+  OIS.h
+  OISConfig.h
+  OISEffect.h
+  OISEvents.h
+  OISException.h
+  OISFactoryCreator.h
+  OISForceFeedback.h
+  OISInputManager.h
+  OISInterface.h
+  OISJoyStick.h
+  OISKeyboard.h
+  OISMouse.h
+  OISObject.h
+  OISPrereqs.h
+
   OISEffect.cpp
   OISException.cpp
@@ -8,39 +23,22 @@
   OISObject.cpp
 )
-
 IF(WIN32)
-  SET( OIS_SRC_FILES ${OIS_SRC_FILES}
-    win32/Win32ForceFeedback.cpp
-    win32/Win32InputManager.cpp
-    win32/Win32JoyStick.cpp
-    win32/Win32KeyBoard.cpp
-    win32/Win32Mouse.cpp
-  )
-ELSEIF (APPLE)
-  SET( OIS_SRC_FILES ${OIS_SRC_FILES}
-    mac/MacHelpers.cpp
-    mac/MacHIDManager.cpp
-    mac/MacInputManager.cpp
-    mac/MacKeyboard.cpp
-    mac/MacMouse.cpp
-  )
-ELSEIF (UNIX)
-  SET( OIS_SRC_FILES ${OIS_SRC_FILES}
-    linux/EventHelpers.cpp
-    linux/LinuxForceFeedback.cpp
-    linux/LinuxInputManager.cpp
-    linux/LinuxJoyStickEvents.cpp
-    linux/LinuxKeyboard.cpp
-    linux/LinuxMouse.cpp
-  )
+  ADD_SUBDIRECTORY(win32)
+ELSEIF(APPLE)
+  ADD_SUBDIRECTORY(mac)
+ELSEIF(UNIX)
+  ADD_SUBDIRECTORY(linux)
 ENDIF (WIN32)
 
+GENERATE_SOURCE_GROUPS(${OIS_FILES})
+
+REMOVE_COMPILER_FLAGS("-DUNICODE -D_UNICODE" MSVC)
 INCLUDE_DIRECTORIES(.)
 
-ADD_LIBRARY( ois_orxonox SHARED ${OIS_SRC_FILES} )
+ADD_LIBRARY(ois_orxonox SHARED ${OIS_FILES} )
 SET_TARGET_PROPERTIES(ois_orxonox PROPERTIES DEFINE_SYMBOL "OIS_NONCLIENT_BUILD")
 
 IF(WIN32)
-  TARGET_LINK_LIBRARIES( ois_orxonox ${DirectX_LIBRARIES} )
+  TARGET_LINK_LIBRARIES( ois_orxonox ${DIRECTX_LIBRARIES} )
 ENDIF(WIN32)
 
Index: code/branches/buildsystem2/src/ois/linux/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/ois/linux/CMakeLists.txt	(revision 2621)
+++ code/branches/buildsystem2/src/ois/linux/CMakeLists.txt	(revision 2621)
@@ -0,0 +1,16 @@
+ADD_SOURCE_FILES(OIS_FILES
+  EventHelpers.h
+  LinuxForceFeedback.h
+  LinuxInputManager.h
+  LinuxJoyStickEvents.h
+  LinuxKeyboard.h
+  LinuxMouse.h
+  LinuxPrereqs.h
+
+  EventHelpers.cpp
+  LinuxForceFeedback.cpp
+  LinuxInputManager.cpp
+  LinuxJoyStickEvents.cpp
+  LinuxKeyboard.cpp
+  LinuxMouse.cpp
+)
Index: code/branches/buildsystem2/src/ois/mac/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/ois/mac/CMakeLists.txt	(revision 2621)
+++ code/branches/buildsystem2/src/ois/mac/CMakeLists.txt	(revision 2621)
@@ -0,0 +1,14 @@
+ADD_SOURCE_FILES(OIS_FILES
+  MacHelpers.h
+  MacHIDManager.h
+  MacInputManager.h
+  MacKeyboard.h
+  MacMouse.h
+  MacPrereqs.h
+
+  MacHelpers.cpp
+  MacHIDManager.cpp
+  MacInputManager.cpp
+  MacKeyboard.cpp
+  MacMouse.cpp
+)
Index: code/branches/buildsystem2/src/ois/win32/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/ois/win32/CMakeLists.txt	(revision 2621)
+++ code/branches/buildsystem2/src/ois/win32/CMakeLists.txt	(revision 2621)
@@ -0,0 +1,14 @@
+ADD_SOURCE_FILES(OIS_FILES
+  Win32ForceFeedback.h
+  Win32InputManager.h
+  Win32JoyStick.h
+  Win32KeyBoard.h
+  Win32Mouse.h
+  Win32Prereqs.h
+
+  Win32ForceFeedback.cpp
+  Win32InputManager.cpp
+  Win32JoyStick.cpp
+  Win32KeyBoard.cpp
+  Win32Mouse.cpp
+)
Index: code/branches/buildsystem2/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+SET_SOURCE_FILES(ORXONOX_SRC_FILES
   CameraManager.cc
   GraphicsEngine.cc
@@ -7,22 +7,19 @@
   Settings.cc
 )
+ADD_SUBDIRECTORY(gamestates)
+ADD_SUBDIRECTORY(gui)
+ADD_SUBDIRECTORY(objects)
+ADD_SUBDIRECTORY(overlays)
+ADD_SUBDIRECTORY(tools)
+GET_ALL_HEADER_FILES(ORXONOX_HDR_FILES)
+SET(ORXONOX_FILES ${ORXONOX_SRC_FILES} ${ORXONOX_HDR_FILES})
 
-ADD_SOURCE_DIRECTORY(gamestates)
-ADD_SOURCE_DIRECTORY(gui)
-ADD_SOURCE_DIRECTORY(objects)
-ADD_SOURCE_DIRECTORY(overlays)
-ADD_SOURCE_DIRECTORY(tools)
-
-WRITE_SOURCE_FILES(ORXONOX_SRC_FILES)
-
-TOLUA(Orxonox ORXONOX_SRC_FILES INPUTFILES gui/GUIManager.h)
+GENERATE_SOURCE_GROUPS(${ORXONOX_FILES})
+GENERATE_TOLUA_BINDINGS(Orxonox ORXONOX_FILES INPUTFILES gui/GUIManager.h)
 
 # Not using precompiled header files: Avoid dependencies
 INCLUDE_DIRECTORIES(pch/nopch)
 
-# Enlarge heap size for precompiled header files
-ADD_CXX_FLAGS("-Zm200" MSVC)
-
-ADD_EXECUTABLE(orxonox ${ORXONOX_SRC_FILES})
+ADD_EXECUTABLE(orxonox ${ORXONOX_FILES})
 GET_TARGET_PROPERTY(_exec_loc orxonox LOCATION)
 GET_FILENAME_COMPONENT(_exec_name ${_exec_loc} NAME)
@@ -44,9 +41,8 @@
   ${CEGUI_LIBRARY}
   ${LUA_LIBRARIES}
-  #${CEGUI_SCRIPT_LIBRARIES}
-  ceguilua_orxonox
+  ${CEGUILUA_LIBRARY}
   ogreceguirenderer_orxonox
-  tinyxml_orxonox
-  tolualib_orxonox
+  tinyxml++_orxonox
+  tolua++_orxonox
   util
   core
Index: code/branches/buildsystem2/src/orxonox/gamestates/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/gamestates/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/gamestates/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   GSDedicated.cc
   GSClient.cc
Index: code/branches/buildsystem2/src/orxonox/gui/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/gui/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/gui/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   GUIManager.cc
 )
Index: code/branches/buildsystem2/src/orxonox/gui/GUIManager.cc
===================================================================
--- code/branches/buildsystem2/src/orxonox/gui/GUIManager.cc	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/gui/GUIManager.cc	(revision 2621)
@@ -39,6 +39,10 @@
 #include <OgreRoot.h>
 #include <CEGUI.h>
-#include <ceguilua/CEGUILua.h>
 #include <ogreceguirenderer/OgreCEGUIRenderer.h>
+#ifdef CEGUILUA_USE_INTERNAL_LIBRARY
+#   include <ceguilua/CEGUILua.h>
+#else
+#   include <CEGUILua.h>
+#endif
 
 #include "util/Exception.h"
@@ -103,5 +107,5 @@
 	        //lua_pushnil(luaState_);
 	        //lua_setglobal(luaState_, "Core");
-            // TODO: deleting the script module fails an assertation.
+            // TODO: deleting the script module fails an assertion.
             // However there is not much we can do about it since it occurs too when
             // we don't open Core or Orxonox. Might be a CEGUI issue.
Index: code/branches/buildsystem2/src/orxonox/objects/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/objects/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   EventListener.cc
   EventDispatcher.cc
@@ -13,9 +13,9 @@
 )
 
-ADD_SOURCE_DIRECTORY(controllers)
-ADD_SOURCE_DIRECTORY(gametypes)
-ADD_SOURCE_DIRECTORY(infos)
-#ADD_SOURCE_DIRECTORY(pickup)
-ADD_SOURCE_DIRECTORY(quest)
-ADD_SOURCE_DIRECTORY(weaponSystem)
-ADD_SOURCE_DIRECTORY(worldentities)
+ADD_SUBDIRECTORY(controllers)
+ADD_SUBDIRECTORY(gametypes)
+ADD_SUBDIRECTORY(infos)
+#ADD_SUBDIRECTORY(pickup)
+ADD_SUBDIRECTORY(quest)
+ADD_SUBDIRECTORY(weaponSystem)
+ADD_SUBDIRECTORY(worldentities)
Index: code/branches/buildsystem2/src/orxonox/objects/controllers/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/controllers/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/objects/controllers/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   Controller.cc
   HumanController.cc
Index: code/branches/buildsystem2/src/orxonox/objects/gametypes/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/gametypes/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/objects/gametypes/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   Gametype.cc
 )
Index: code/branches/buildsystem2/src/orxonox/objects/infos/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/infos/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/objects/infos/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   Info.cc
   PlayerInfo.cc
Index: code/branches/buildsystem2/src/orxonox/objects/pickup/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/pickup/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/objects/pickup/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   ShipEquipmentClasses.cc
   ShipItem.cc
Index: code/branches/buildsystem2/src/orxonox/objects/quest/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/quest/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/objects/quest/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   AddQuest.cc
   AddQuestHint.cc
Index: code/branches/buildsystem2/src/orxonox/objects/weaponSystem/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/weaponSystem/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/objects/weaponSystem/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   Munition.cc
   Weapon.cc
@@ -7,5 +7,5 @@
 )
 
-#ADD_SOURCE_DIRECTORY(munitions)
-#ADD_SOURCE_DIRECTORY(projectiles)
-#ADD_SOURCE_DIRECTORY(weapons)
+#ADD_SUBDIRECTORY(munitions)
+#ADD_SUBDIRECTORY(projectiles)
+#ADD_SUBDIRECTORY(weapons)
Index: code/branches/buildsystem2/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   LaserGunMunition.cc
 )
Index: code/branches/buildsystem2/src/orxonox/objects/weaponSystem/projectiles/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/weaponSystem/projectiles/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/objects/weaponSystem/projectiles/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   BillboardProjectile.cc
   ParticleProjectile.cc
Index: code/branches/buildsystem2/src/orxonox/objects/weaponSystem/weapons/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/weaponSystem/weapons/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/objects/weaponSystem/weapons/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   LaserGun.cc
   Missile.cc
Index: code/branches/buildsystem2/src/orxonox/objects/worldentities/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/worldentities/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/objects/worldentities/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   WorldEntity.cc
   PositionableEntity.cc
@@ -16,4 +16,4 @@
 )
 
-ADD_SOURCE_DIRECTORY(pawns)
-ADD_SOURCE_DIRECTORY(triggers)
+ADD_SUBDIRECTORY(pawns)
+ADD_SUBDIRECTORY(triggers)
Index: code/branches/buildsystem2/src/orxonox/objects/worldentities/pawns/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/worldentities/pawns/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/objects/worldentities/pawns/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   Spectator.cc
   Pawn.cc
Index: code/branches/buildsystem2/src/orxonox/objects/worldentities/triggers/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/worldentities/triggers/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/objects/worldentities/triggers/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   Trigger.cc
   DistanceTrigger.cc
Index: code/branches/buildsystem2/src/orxonox/orxonox.vcproj.user
===================================================================
--- code/branches/buildsystem2/src/orxonox/orxonox.vcproj.user	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/orxonox.vcproj.user	(revision 2621)
@@ -11,5 +11,5 @@
 			<DebugSettings
 				WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
-				Environment="Path=${ORXONOX_LIBRARY_BIN_DIR}"
+				Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
 				EnvironmentMerge="true"
 			/>
@@ -20,5 +20,5 @@
 			<DebugSettings
 				WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
-				Environment="Path=${ORXONOX_LIBRARY_BIN_DIR}"
+				Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
 				EnvironmentMerge="true"
 			/>
@@ -29,5 +29,5 @@
 			<DebugSettings
 				WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
-				Environment="Path=${ORXONOX_LIBRARY_BIN_DIR}"
+				Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
 				EnvironmentMerge="true"
 			/>
@@ -38,5 +38,5 @@
 			<DebugSettings
 				WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
-				Environment="Path=${ORXONOX_LIBRARY_BIN_DIR}"
+				Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
 				EnvironmentMerge="true"
 			/>
Index: code/branches/buildsystem2/src/orxonox/overlays/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/overlays/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/overlays/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   OrxonoxOverlay.cc
   OverlayGroup.cc
@@ -5,5 +5,5 @@
 )
 
-ADD_SOURCE_DIRECTORY(console)
-ADD_SOURCE_DIRECTORY(debug)
-ADD_SOURCE_DIRECTORY(hud)
+ADD_SUBDIRECTORY(console)
+ADD_SUBDIRECTORY(debug)
+ADD_SUBDIRECTORY(hud)
Index: code/branches/buildsystem2/src/orxonox/overlays/console/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/overlays/console/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/overlays/console/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   InGameConsole.cc
 )
Index: code/branches/buildsystem2/src/orxonox/overlays/debug/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/overlays/debug/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/overlays/debug/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   DebugFPSText.cc
   DebugRTRText.cc
Index: code/branches/buildsystem2/src/orxonox/overlays/hud/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/overlays/hud/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/overlays/hud/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   HUDBar.cc
   HUDNavigation.cc
Index: code/branches/buildsystem2/src/orxonox/pch/nopch/OrxonoxStableHeaders.h
===================================================================
--- code/branches/buildsystem2/src/orxonox/pch/nopch/OrxonoxStableHeaders.h	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/pch/nopch/OrxonoxStableHeaders.h	(revision 2621)
@@ -35,5 +35,5 @@
 #define _OrxonoxStableHeaders_H__
 
-#include "util/OrxonoxPlatform.h"
+#include "OrxonoxConfig.h"
 
 #endif /* _OrxonoxStableHeaders_H__ */
Index: code/branches/buildsystem2/src/orxonox/tools/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/tools/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/orxonox/tools/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   BillboardSet.cc
   Mesh.cc
Index: code/branches/buildsystem2/src/tinyxml/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/tinyxml/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/tinyxml/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,8 @@
-SET( TINYXML_SRC_FILES
+SET(TINYXML++_FILES
+  ticpp.h
+  ticpprc.h
+  tinystr.h
+  tinyxml.h
+
   ticpp.cpp
   tinystr.cpp
@@ -6,12 +11,13 @@
   tinyxmlparser.cpp
 )
+GENERATE_SOURCE_GROUPS(${TINYXML++_FILES})
 
 IF(MSVC)
-  ADD_LIBRARY(tinyxml_orxonox STATIC ${TINYXML_SRC_FILES})
+  ADD_LIBRARY(tinyxml++_orxonox STATIC ${TINYXML++_FILES})
 ELSE(MSVC)
-  ADD_LIBRARY(tinyxml_orxonox SHARED ${TINYXML_SRC_FILES})
+  ADD_LIBRARY(tinyxml++_orxonox SHARED ${TINYXML++_FILES})
 ENDIF(MSVC)
 
 IF (NOT WIN32)
-  INSTALL(TARGETS tinyxml_orxonox LIBRARY DESTINATION lib)
+  INSTALL(TARGETS tinyxml++_orxonox LIBRARY DESTINATION lib)
 ENDIF (NOT WIN32)
Index: code/branches/buildsystem2/src/tolua/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/tolua/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/tolua/CMakeLists.txt	(revision 2621)
@@ -1,5 +1,8 @@
-ADD_C_FLAGS("-wd4996" MSVC)
+################### Tolua++ library ###################
 
-ADD_LIBRARY(tolualib_orxonox SHARED
+SET(TOLUA++_FILES
+  tolua_event.h
+  tolua++.h
+
   tolua_event.c
   tolua_is.c
@@ -8,6 +11,11 @@
   tolua_to.c
 )
-SET_TARGET_PROPERTIES(tolualib_orxonox PROPERTIES DEFINE_SYMBOL "TOLUA_SHARED_BUILD")
-TARGET_LINK_LIBRARIES(tolualib_orxonox ${LUA_LIBRARIES})
+GENERATE_SOURCE_GROUPS(${TOLUA++_FILES})
+
+ADD_COMPILER_FLAGS("-w44996" MSVC)
+
+ADD_LIBRARY(tolua++_orxonox SHARED ${TOLUA++_FILES})
+SET_TARGET_PROPERTIES(tolua++_orxonox PROPERTIES DEFINE_SYMBOL "TOLUA_SHARED_BUILD")
+TARGET_LINK_LIBRARIES(tolua++_orxonox ${LUA_LIBRARIES})
 
 IF (NOT WIN32)
@@ -15,25 +23,15 @@
 ENDIF (NOT WIN32)
 
-SET(TOLUAGEN_SRC_FILES
-  tolua.c
-)
 
-ADD_EXECUTABLE(toluaexe_orxonox ${TOLUAGEN_SRC_FILES})
-TARGET_LINK_LIBRARIES(toluaexe_orxonox tolualib_orxonox ${LUA_LIBRARIES})
+################## Tolua++ generator ##################
 
-#IF("${LUA_VERSION}" VERSION_LESS 5.1)
-IF("${LUA_VERSION}" MATCHES "^5.0")
-  SET(TOLUA_ALL_PACK all-5.0.lua)
-#ELSE("${LUA_VERSION}" VERSION_LESS 5.1)
-ELSE("${LUA_VERSION}" MATCHES "^5.0")
-  SET(TOLUA_ALL_PACK all-5.1.lua)
-#ENDIF("${LUA_VERSION}" VERSION_LESS 5.1)
-ENDIF("${LUA_VERSION}" MATCHES "^5.0")
+ADD_EXECUTABLE(tolua++app_orxonox tolua.c)
+TARGET_LINK_LIBRARIES(tolua++app_orxonox tolua++_orxonox ${LUA_LIBRARIES})
 
 # Set some variables to the cache in order to use them in the TOLUA macro
-SET(TOLUA_PARSER_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/${TOLUA_ALL_PACK}" CACHE INTERNAL "")
+SET(TOLUA_PARSER_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/all-${LUA_VERSION}.lua" CACHE INTERNAL "")
 SET(TOLUA_PARSER_DEPENDENCIES
-  toluaexe_orxonox
-  ${CMAKE_CURRENT_SOURCE_DIR}/${TOLUA_ALL_PACK}
+  tolua++app_orxonox
+  ${CMAKE_CURRENT_SOURCE_DIR}/all-${LUA_VERSION}.lua
   ${CMAKE_CURRENT_SOURCE_DIR}/lua/compat-5.1.lua
   ${CMAKE_CURRENT_SOURCE_DIR}/lua/compat.lua
Index: code/branches/buildsystem2/src/util/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/util/CMakeLists.txt	(revision 2620)
+++ code/branches/buildsystem2/src/util/CMakeLists.txt	(revision 2621)
@@ -1,3 +1,3 @@
-SET(UTIL_SRC_FILES
+SET_SOURCE_FILES(UTIL_SRC_FILES
   Clipboard.cc
   CRC32.cc
@@ -12,6 +12,12 @@
   SubString.cc
 )
+GET_ALL_HEADER_FILES(UTIL_HDR_FILES)
+SET(UTIL_FILES ${UTIL_SRC_FILES} ${UTIL_HDR_FILES})
+GENERATE_SOURCE_GROUPS(${UTIL_FILES})
+# Also add OrxonoxConfig.h to have it least somewhere in the IDE
+LIST(APPEND UTIL_FILES ${CMAKE_BINARY_DIR}/src/OrxonoxConfig.h)
+SOURCE_GROUP("" FILES ${CMAKE_BINARY_DIR}/src/OrxonoxConfig.h)
 
-ADD_LIBRARY(util SHARED ${UTIL_SRC_FILES})
+ADD_LIBRARY(util SHARED ${UTIL_FILES})
 SET_TARGET_PROPERTIES(util PROPERTIES DEFINE_SYMBOL "UTIL_SHARED_BUILD")
 TARGET_LINK_LIBRARIES(util ${OGRE_LIBRARY})
