Index: sandbox/cmake/CompilerConfigMSVC.cmake
===================================================================
--- sandbox/cmake/CompilerConfigMSVC.cmake	(revision 5782)
+++ sandbox/cmake/CompilerConfigMSVC.cmake	(revision 6038)
@@ -70,8 +70,8 @@
 
 # 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 -MP2"      RelWithDebInfo CACHE)
-SET_COMPILER_FLAGS("-MD  -O1     -DNDEBUG -MP2"      MinSizeRel     CACHE)
+SET_COMPILER_FLAGS("-MDd -Od -Zi -D_DEBUG -MP2 -RTC1" Debug          CACHE)
+SET_COMPILER_FLAGS("-MD  -O2     -DNDEBUG -MP2"       Release        CACHE)
+SET_COMPILER_FLAGS("-MD  -O2 -Zi -DNDEBUG -MP2"       RelWithDebInfo CACHE)
+SET_COMPILER_FLAGS("-MD  -O1     -DNDEBUG -MP2"       MinSizeRel     CACHE)
 
 # Use Link time code generation for Release config if ORXONOX_RELEASE is defined
Index: sandbox/cmake/LibraryConfig.cmake
===================================================================
--- sandbox/cmake/LibraryConfig.cmake	(revision 5782)
+++ sandbox/cmake/LibraryConfig.cmake	(revision 6038)
@@ -89,5 +89,5 @@
 ##### Boost #####
 # Expand the next statement if newer boost versions than 1.36.1 are released
-SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0 1.38 1.38.0 1.39 1.39.0)
+SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0 1.38 1.38.0 1.39 1.39.0 1.40 1.40.0)
 FIND_PACKAGE(Boost 1.35 REQUIRED thread filesystem system date_time)
 # No auto linking, so this option is useless anyway
Index: sandbox/cmake/PackageConfig.cmake
===================================================================
--- sandbox/cmake/PackageConfig.cmake	(revision 5782)
+++ sandbox/cmake/PackageConfig.cmake	(revision 6038)
@@ -26,7 +26,11 @@
 
 # Check package version info
-# MAJOR: Interface breaking change somewhere (library version changed, etc.)
-# MINOR: Bug fix or small conformant changes
-SET(DEPENDENCY_VERSION_REQUIRED 3)
+# MAJOR: Breaking change
+# MINOR: No breaking changes by the dependency package
+#        For example any code running on 3.0 should still run on 3.1
+#        But you can specify that the code only runs on 3.1 and higher
+#        or 4.0 and higher (so both 3.1 and 4.0 will work).
+SET(ALLOWED_MINIMUM_VERSIONS 3.1 4.0)
+
 IF(NOT EXISTS ${DEPENDENCY_PACKAGE_DIR}/version.txt)
   SET(DEPENDENCY_VERSION 1.0)
@@ -44,9 +48,20 @@
 
 INCLUDE(CompareVersionStrings)
-COMPARE_VERSION_STRINGS(${DEPENDENCY_VERSION} ${DEPENDENCY_VERSION_REQUIRED} _result TRUE)
-IF(NOT _result EQUAL 0)
+SET(_version_match FALSE)
+FOREACH(_version ${ALLOWED_MINIMUM_VERSIONS})
+  # Get major version
+  STRING(REGEX REPLACE "^([0-9]+)\\..*$" "\\1" _major_version "${_version}")
+  COMPARE_VERSION_STRINGS(${DEPENDENCY_VERSION} ${_major_version} _result TRUE)
+  IF(_result EQUAL 0)
+    COMPARE_VERSION_STRINGS(${DEPENDENCY_VERSION} ${_version} _result FALSE)
+    IF(NOT _result LESS 0)
+      SET(_version_match TRUE)
+    ENDIF()
+  ENDIF()
+ENDFOREACH(_version)
+IF(NOT _version_match)
   MESSAGE(FATAL_ERROR "Your dependency package version is ${DEPENDENCY_VERSION}\n"
-          "Required version: ${DEPENDENCY_VERSION_REQUIRED}\n"
-	  "You can get a new version from www.orxonox.net")
+          "Possible required versions: ${ALLOWED_MINIMUM_VERSIONS}\n"
+          "You can get a new version from www.orxonox.net")
 ENDIF()
 
Index: sandbox/cmake/ParseMacroArguments.cmake
===================================================================
--- sandbox/cmake/ParseMacroArguments.cmake	(revision 5782)
+++ sandbox/cmake/ParseMacroArguments.cmake	(revision 6038)
@@ -39,4 +39,9 @@
   # Using LIST(FIND ...) speeds up the process
   SET(_keywords ${_switches} ${_list_names})
+
+  # Reset all arguments
+  FOREACH(_arg ${_switches} ${_list_names})
+    SET(_arg_${_arg})
+  ENDFOREACH(_arg)
 
   # Parse all the arguments and set the corresponding variable
Index: sandbox/cmake/PrecompiledHeaderFiles.cmake
===================================================================
--- sandbox/cmake/PrecompiledHeaderFiles.cmake	(revision 5782)
+++ sandbox/cmake/PrecompiledHeaderFiles.cmake	(revision 6038)
@@ -110,5 +110,5 @@
     GET_GCC_COMPILER_FLAGS(${_target_name} _pch_gcc_flags)
     # Make sure we recompile the pch file even if only the flags change
-    IF(NOT "${_pch_gcc_flags}" STREQUAL "${_INTERNAL_${_target_name}_PCH_GCC_FLAGS}")
+    IF(NOT "${_pch_gcc_flags}" STREQUAL "${_INTERNAL_${_target_name}_PCH_GCC_FLAGS}" OR NOT EXISTS "${_pch_dep_helper_file}")
       SET(_INTERNAL_${_target_name}_PCH_GCC_FLAGS "${_pch_gcc_flags}" CACHE INTERNAL "")
       FILE(WRITE ${_pch_dep_helper_file} "/* ${_pch_gcc_flags} */")
Index: sandbox/cmake/SourceFileUtilities.cmake
===================================================================
--- sandbox/cmake/SourceFileUtilities.cmake	(revision 5782)
+++ sandbox/cmake/SourceFileUtilities.cmake	(revision 6038)
@@ -24,16 +24,66 @@
  #    [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.
+ #                             Also compiles multiple source files into a single
+ #                             one by including them
+ #                             Use COMPILATION_[BEGIN|END] in
+ #                             [ADD|SET]_SOURCE_FILES and specify the name of
+ #                             the new source file after COMPILATION_BEGIN
+ #    GET_ALL_HEADER_FILES   - Finds all header files recursively.
  #    GENERATE_SOURCE_GROUPS - Set Visual Studio source groups.
  #
 
+FUNCTION(PREPARE_SOURCE_FILES)
+  SET(_fullpath_sources)
+  FOREACH(_file ${ARGN})
+    IF(_file STREQUAL "COMPILATION_BEGIN")
+      SET(_compile TRUE)
+      # Next file is the name of the compilation
+      SET(_get_name TRUE)
+    ELSEIF(_get_name)
+      SET(_get_name FALSE)
+      SET(_compilation_name ${_file})
+    ELSEIF(_file STREQUAL "COMPILATION_END")
+      IF(NOT _compilation_name)
+        MESSAGE(FATAL_ERROR "No name provided for source file compilation")
+      ENDIF()
+      IF(NOT DISABLE_COMPILATIONS)
+        SET(_compilation_file ${CMAKE_CURRENT_BINARY_DIR}/${_compilation_name})
+        SET(_include_string)
+        FOREACH(_file2 ${_compilation})
+          SET(_include_string "${_include_string}#include \"${_file2}\"\n")
+        ENDFOREACH(_file2)
+        IF(EXISTS )
+          FILE(READ ${_compilation_file} _include_string_file)
+        ENDIF()
+        IF(NOT _include_string STREQUAL "${_include_string_file}")
+          FILE(WRITE ${_compilation_file} "${_include_string}")
+        ENDIF()
+        LIST(APPEND _fullpath_sources ${_compilation_file})
+        # MSVC hack that excludes the compilations from the intellisense database
+        # (There is a bug with the "-" instead of "/". Only works for "Zm#" argument)
+        IF(MSVC)
+          SET_SOURCE_FILES_PROPERTIES(${_compilation_file} PROPERTIES COMPILE_FLAGS "-Zm1000")
+        ENDIF()
+      ENDIF()
+      SET(_compilation_name)
+      SET(_compilation)
+      SET(_compile FALSE)
+    ELSE()
+      # Prefix the full path
+      GET_SOURCE_FILE_PROPERTY(_filepath ${_file} LOCATION)
+      LIST(APPEND _fullpath_sources ${_filepath})
+      IF(_compile AND NOT DISABLE_COMPILATIONS)
+        LIST(APPEND _compilation ${_filepath})
+	LIST(APPEND _fullpath_sources "H")
+      ENDIF()
+    ENDIF()
+  ENDFOREACH(_file)
+  SET(_fullpath_sources ${_fullpath_sources} PARENT_SCOPE)
+ENDFUNCTION(PREPARE_SOURCE_FILES)
+
+
 # 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)
+  PREPARE_SOURCE_FILES(${ARGN})
   # Write into the cache to avoid variable scoping in subdirs
   SET(${_varname} ${${_varname}} ${_fullpath_sources} CACHE INTERNAL "Do not edit")
@@ -43,10 +93,5 @@
 # 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)
+  PREPARE_SOURCE_FILES(${ARGN})
   # Write into the cache to avoid variable scoping in subdirs
   SET(${_varname} ${_fullpath_sources} CACHE INTERNAL "Do not edit")
@@ -66,7 +111,12 @@
     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})
+    IF(NOT _relative_path MATCHES "^\\.\\.")
+      GET_FILENAME_COMPONENT(_relative_path ${_relative_path} PATH)
+      STRING(REPLACE "/" "\\\\" _group_path "${_relative_path}")
+      SOURCE_GROUP("Source\\${_group_path}" FILES ${_file})
+    ELSE()
+      # Has to be a compilation
+      SOURCE_GROUP("Compilations" FILES ${_file})
+    ENDIF()
   ENDFOREACH(_file)
 
Index: sandbox/cmake/TargetUtilities.cmake
===================================================================
--- sandbox/cmake/TargetUtilities.cmake	(revision 5782)
+++ sandbox/cmake/TargetUtilities.cmake	(revision 6038)
@@ -67,14 +67,14 @@
 ENDIF()
 
-FUNCTION(ORXONOX_ADD_LIBRARY _target_name)
+MACRO(ORXONOX_ADD_LIBRARY _target_name)
   TU_ADD_TARGET(${_target_name} LIBRARY "STATIC;SHARED" ${ARGN})
-ENDFUNCTION(ORXONOX_ADD_LIBRARY)
-
-FUNCTION(ORXONOX_ADD_EXECUTABLE _target_name)
+ENDMACRO(ORXONOX_ADD_LIBRARY)
+
+MACRO(ORXONOX_ADD_EXECUTABLE _target_name)
   TU_ADD_TARGET(${_target_name} EXECUTABLE "WIN32" ${ARGN})
-ENDFUNCTION(ORXONOX_ADD_EXECUTABLE)
-
-
-FUNCTION(TU_ADD_TARGET _target_name _target_type _additional_switches)
+ENDMACRO(ORXONOX_ADD_EXECUTABLE)
+
+
+MACRO(TU_ADD_TARGET _target_name _target_type _additional_switches)
   CAPITALISE_NAME(${_target_name} _target_name_capitalised)
 
@@ -88,11 +88,22 @@
 
 
-  # GET_HEADER_FILES
+  # Workaround: Source file properties get lost when leaving a subdirectory
+  # Therefore an "H" after a file means we have to set it as HEADER_FILE_ONLY
+  FOREACH(_file ${_arg_SOURCE_FILES})
+    IF(_file STREQUAL "H")
+      SET_SOURCE_FILES_PROPERTIES(${_last_file} PROPERTIES HEADER_FILE_ONLY TRUE)
+    ELSE()
+      SET(_last_file ${_file})
+      LIST(APPEND _${_target_name}_source_files ${_file})
+    ENDIF()
+  ENDFOREACH(_file)
+
+  # Assemble all header files of the library
   IF(_arg_FIND_HEADER_FILES)
-    GET_ALL_HEADER_FILES(_${target_name}_header_files)
+    GET_ALL_HEADER_FILES(_${_target_name}_header_files)
   ENDIF()
 
   # Remove potential duplicates
-  SET(_${_target_name}_files ${_${target_name}_header_files} ${_arg_SOURCE_FILES})
+  SET(_${_target_name}_files ${_${_target_name}_header_files} ${_${_target_name}_source_files})
   LIST(REMOVE_DUPLICATES _${_target_name}_files)
 
@@ -141,4 +152,10 @@
   ENDIF()
 
+  # No warnings needed from third party libraries
+  IF(_arg_ORXONOX_EXTERNAL)
+    REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC)
+    ADD_COMPILER_FLAGS("-w")
+  ENDIF()
+
   # Set default linking if required
   IF(NOT _arg_SHARED AND NOT _arg_STATIC)
@@ -156,4 +173,13 @@
     SET(_arg_STATIC)
   ENDIF()
+
+  # Don't compile header files
+  FOREACH(_file ${_${_target_name}_files})
+    IF(NOT _file MATCHES "\\.(c|cc|cpp)")
+      SET_SOURCE_FILES_PROPERTIES(${_file} PROPERTIES HEADER_FILE_ONLY TRUE)
+    ENDIF()
+  ENDFOREACH(_file)
+
+
 
   # Add the library/executable
@@ -164,4 +190,20 @@
     ADD_EXECUTABLE(${_target_name} ${_arg_WIN32} ${_arg_EXCLUDE_FROM_ALL}
                    ${_${_target_name}_files})
+  ENDIF()
+
+
+
+  # Change library prefix to "lib"
+  IF(MSVC AND ${_target_type} STREQUAL "LIBRARY")
+    SET_TARGET_PROPERTIES(${_target_name} PROPERTIES
+      PREFIX "lib"
+    )
+  ENDIF()
+
+  # MSVC hack to exclude external library sources from the intellisense database
+  # (IntelliSense stops working when adding "-Zm1000" as compile flag. "/Zm1000"
+  # would not work because of the slash)
+  IF(_arg_ORXONOX_EXTERNAL AND MSVC)
+    SET_TARGET_PROPERTIES(${_target_name} PROPERTIES COMPILE_FLAGS "-Zm1000")
   ENDIF()
 
@@ -216,5 +258,5 @@
   ENDIF()
 
-ENDFUNCTION(TU_ADD_TARGET)
+ENDMACRO(TU_ADD_TARGET)
 
 
