Index: code/branches/buildsystem2/cmake/AddSourceFiles.cmake
===================================================================
--- code/branches/buildsystem2/cmake/AddSourceFiles.cmake	(revision 2517)
+++ code/branches/buildsystem2/cmake/AddSourceFiles.cmake	(revision 2518)
@@ -16,24 +16,51 @@
 #    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
-MACRO(ADD_SOURCE_DIRECTORY _target_list _directory)
+# 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.
 
-  # Subfolder puts source files into CMake Cache variable _CACHED_SOURCE_FILES
+# 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
-  # and add it to the source list in the current directory
-  FOREACH(_source_file ${_CACHED_SOURCE_FILES})
-    LIST(APPEND ${_target_list} "${_directory}/${_source_file}")
+  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)
 
-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)
+  SET(${_variable_name} ${_source_files_internal_local})
 
-ENDMACRO(ADD_SOURCE_FILES)
+ENDMACRO(WRITE_SOURCE_FILES)
Index: code/branches/buildsystem2/src/core/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/core/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/core/CMakeLists.txt	(revision 2518)
@@ -1,3 +1,3 @@
-SET(CORE_SRC_FILES
+ADD_SOURCE_FILES(
   Clock.cc
   ConfigFileManager.cc
@@ -41,8 +41,9 @@
   TclBind.cc
   TclThreadManager.cc
-
 )
 
-ADD_SOURCE_DIRECTORY(CORE_SRC_FILES input)
+ADD_SOURCE_DIRECTORY(input)
+
+WRITE_SOURCE_FILES(CORE_SRC_FILES)
 
 INCLUDE(UseTolua)
Index: code/branches/buildsystem2/src/core/input/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/core/input/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/core/input/CMakeLists.txt	(revision 2518)
@@ -1,3 +1,3 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   Button.cc
   CalibratorCallback.cc
@@ -12,4 +12,2 @@
   SimpleInputState.cc
 )
-
-ADD_SOURCE_FILES(SRC_FILES)
Index: code/branches/buildsystem2/src/network/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/network/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/network/CMakeLists.txt	(revision 2518)
@@ -1,3 +1,3 @@
-SET( NETWORK_SRC_FILES
+ADD_SOURCE_FILES(
   ChatListener.cc
   Client.cc
@@ -15,6 +15,7 @@
 )
 
-ADD_SOURCE_DIRECTORY(NETWORK_SRC_FILES packet)
+ADD_SOURCE_DIRECTORY(packet)
 
+WRITE_SOURCE_FILES(NETWORK_SRC_FILES)
 IF(WIN32)
   ADD_LIBRARY( network ${NETWORK_SRC_FILES} )
Index: code/branches/buildsystem2/src/network/packet/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/network/packet/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/network/packet/CMakeLists.txt	(revision 2518)
@@ -1,3 +1,3 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   Packet.cc
   Chat.cc
@@ -8,4 +8,2 @@
   DeleteObjects.cc
 )
-
-ADD_SOURCE_FILES(SRC_FILES)
Index: code/branches/buildsystem2/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/CMakeLists.txt	(revision 2518)
@@ -1,3 +1,3 @@
-SET( ORXONOX_SRC_FILES
+ADD_SOURCE_FILES(
   CameraManager.cc
   GraphicsEngine.cc
@@ -8,15 +8,16 @@
 )
 
-ADD_SOURCE_DIRECTORY(ORXONOX_SRC_FILES gamestates)
-ADD_SOURCE_DIRECTORY(ORXONOX_SRC_FILES gui)
-ADD_SOURCE_DIRECTORY(ORXONOX_SRC_FILES objects)
-ADD_SOURCE_DIRECTORY(ORXONOX_SRC_FILES overlays)
-ADD_SOURCE_DIRECTORY(ORXONOX_SRC_FILES tools)
+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)
 
 INCLUDE(UseTolua)
 TOLUA(Orxonox ORXONOX_SRC_FILES INPUTFILES gui/GUIManager.h)
 
-
-ADD_EXECUTABLE( orxonox ${ORXONOX_SRC_FILES} )
+ADD_EXECUTABLE(orxonox ${ORXONOX_SRC_FILES})
 
 IF(NETWORKTRAFFIC_TESTING_ENABLED)
Index: code/branches/buildsystem2/src/orxonox/gamestates/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/gamestates/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/gamestates/CMakeLists.txt	(revision 2518)
@@ -1,3 +1,3 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   GSDedicated.cc
   GSClient.cc
@@ -10,4 +10,2 @@
   GSStandalone.cc
 )
-
-ADD_SOURCE_FILES(SRC_FILES)
Index: code/branches/buildsystem2/src/orxonox/gui/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/gui/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/gui/CMakeLists.txt	(revision 2518)
@@ -1,3 +1,3 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   GUIManager.cc
   OgreCEGUIRenderer.cpp
@@ -5,4 +5,2 @@
   OgreCEGUITexture.cpp
 )
-
-ADD_SOURCE_FILES(SRC_FILES)
Index: code/branches/buildsystem2/src/orxonox/objects/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/objects/CMakeLists.txt	(revision 2518)
@@ -1,3 +1,3 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   EventListener.cc
   EventDispatcher.cc
@@ -13,11 +13,9 @@
 )
 
-ADD_SOURCE_DIRECTORY(SRC_FILES controllers)
-ADD_SOURCE_DIRECTORY(SRC_FILES gametypes)
-ADD_SOURCE_DIRECTORY(SRC_FILES infos)
-#ADD_SOURCE_DIRECTORY(SRC_FILES pickup)
-ADD_SOURCE_DIRECTORY(SRC_FILES quest)
-ADD_SOURCE_DIRECTORY(SRC_FILES weaponSystem)
-ADD_SOURCE_DIRECTORY(SRC_FILES worldentities)
-
-ADD_SOURCE_FILES(SRC_FILES)
+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)
Index: code/branches/buildsystem2/src/orxonox/objects/controllers/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/controllers/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/objects/controllers/CMakeLists.txt	(revision 2518)
@@ -1,6 +1,4 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   Controller.cc
   HumanController.cc
 )
-
-ADD_SOURCE_FILES(SRC_FILES)
Index: code/branches/buildsystem2/src/orxonox/objects/gametypes/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/gametypes/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/objects/gametypes/CMakeLists.txt	(revision 2518)
@@ -1,5 +1,3 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   Gametype.cc
 )
-
-ADD_SOURCE_FILES(SRC_FILES)
Index: code/branches/buildsystem2/src/orxonox/objects/infos/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/infos/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/objects/infos/CMakeLists.txt	(revision 2518)
@@ -1,7 +1,5 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   Info.cc
   PlayerInfo.cc
   HumanPlayer.cc
 )
-
-ADD_SOURCE_FILES(SRC_FILES)
Index: code/branches/buildsystem2/src/orxonox/objects/pickup/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/pickup/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/objects/pickup/CMakeLists.txt	(revision 2518)
@@ -1,6 +1,4 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   ShipEquipmentClasses.cc
   ShipItem.cc
 )
-
-ADD_SOURCE_FILES(SRC_FILES)
Index: code/branches/buildsystem2/src/orxonox/objects/quest/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/quest/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/objects/quest/CMakeLists.txt	(revision 2518)
@@ -1,3 +1,3 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   AddQuest.cc
   AddQuestHint.cc
@@ -17,4 +17,2 @@
   Rewardable.cc
 )
-
-ADD_SOURCE_FILES(SRC_FILES)
Index: code/branches/buildsystem2/src/orxonox/objects/weaponSystem/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/weaponSystem/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/objects/weaponSystem/CMakeLists.txt	(revision 2518)
@@ -1,3 +1,3 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   Munition.cc
   Weapon.cc
@@ -7,7 +7,5 @@
 )
 
-#ADD_SOURCE_DIRECTORY(SRC_FILES munitions)
-#ADD_SOURCE_DIRECTORY(SRC_FILES projectiles)
-#ADD_SOURCE_DIRECTORY(SRC_FILES weapons)
-
-ADD_SOURCE_FILES(SRC_FILES)
+#ADD_SOURCE_DIRECTORY(munitions)
+#ADD_SOURCE_DIRECTORY(projectiles)
+#ADD_SOURCE_DIRECTORY(weapons)
Index: code/branches/buildsystem2/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt	(revision 2518)
@@ -1,5 +1,3 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   LaserGunMunition.cc
 )
-
-ADD_SOURCE_FILES(SRC_FILES)
Index: code/branches/buildsystem2/src/orxonox/objects/weaponSystem/projectiles/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/weaponSystem/projectiles/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/objects/weaponSystem/projectiles/CMakeLists.txt	(revision 2518)
@@ -1,7 +1,5 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   BillboardProjectile.cc
   ParticleProjectile.cc
   Projectile.cc
 )
-
-ADD_SOURCE_FILES(SRC_FILES)
Index: code/branches/buildsystem2/src/orxonox/objects/weaponSystem/weapons/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/weaponSystem/weapons/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/objects/weaponSystem/weapons/CMakeLists.txt	(revision 2518)
@@ -1,6 +1,4 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   LaserGun.cc
   Missile.cc
 )
-
-ADD_SOURCE_FILES(SRC_FILES)
Index: code/branches/buildsystem2/src/orxonox/objects/worldentities/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/worldentities/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/objects/worldentities/CMakeLists.txt	(revision 2518)
@@ -1,3 +1,3 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   WorldEntity.cc
   PositionableEntity.cc
@@ -16,6 +16,4 @@
 )
 
-ADD_SOURCE_DIRECTORY(SRC_FILES pawns)
-ADD_SOURCE_DIRECTORY(SRC_FILES triggers)
-
-ADD_SOURCE_FILES(SRC_FILES)
+ADD_SOURCE_DIRECTORY(pawns)
+ADD_SOURCE_DIRECTORY(triggers)
Index: code/branches/buildsystem2/src/orxonox/objects/worldentities/pawns/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/worldentities/pawns/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/objects/worldentities/pawns/CMakeLists.txt	(revision 2518)
@@ -1,7 +1,5 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   Spectator.cc
   Pawn.cc
   SpaceShip.cc
 )
-
-ADD_SOURCE_FILES(SRC_FILES)
Index: code/branches/buildsystem2/src/orxonox/objects/worldentities/triggers/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/objects/worldentities/triggers/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/objects/worldentities/triggers/CMakeLists.txt	(revision 2518)
@@ -1,3 +1,3 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   Trigger.cc
   DistanceTrigger.cc
@@ -5,4 +5,2 @@
   PlayerTrigger.cc
 )
-
-ADD_SOURCE_FILES(SRC_FILES)
Index: code/branches/buildsystem2/src/orxonox/overlays/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/overlays/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/overlays/CMakeLists.txt	(revision 2518)
@@ -1,3 +1,3 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   OrxonoxOverlay.cc
   OverlayGroup.cc
@@ -5,7 +5,5 @@
 )
 
-ADD_SOURCE_DIRECTORY(SRC_FILES console)
-ADD_SOURCE_DIRECTORY(SRC_FILES debug)
-ADD_SOURCE_DIRECTORY(SRC_FILES hud)
-
-ADD_SOURCE_FILES(SRC_FILES)
+ADD_SOURCE_DIRECTORY(console)
+ADD_SOURCE_DIRECTORY(debug)
+ADD_SOURCE_DIRECTORY(hud)
Index: code/branches/buildsystem2/src/orxonox/overlays/console/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/overlays/console/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/overlays/console/CMakeLists.txt	(revision 2518)
@@ -1,5 +1,3 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   InGameConsole.cc
 )
-
-ADD_SOURCE_FILES(SRC_FILES)
Index: code/branches/buildsystem2/src/orxonox/overlays/debug/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/overlays/debug/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/overlays/debug/CMakeLists.txt	(revision 2518)
@@ -1,6 +1,4 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   DebugFPSText.cc
   DebugRTRText.cc
 )
-
-ADD_SOURCE_FILES(SRC_FILES)
Index: code/branches/buildsystem2/src/orxonox/overlays/hud/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/overlays/hud/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/overlays/hud/CMakeLists.txt	(revision 2518)
@@ -1,3 +1,3 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   HUDBar.cc
   HUDNavigation.cc
@@ -6,4 +6,2 @@
   ChatOverlay.cc
 )
-
-ADD_SOURCE_FILES(SRC_FILES)
Index: code/branches/buildsystem2/src/orxonox/tools/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/tools/CMakeLists.txt	(revision 2517)
+++ code/branches/buildsystem2/src/orxonox/tools/CMakeLists.txt	(revision 2518)
@@ -1,3 +1,3 @@
-SET( SRC_FILES
+ADD_SOURCE_FILES(
   BillboardSet.cc
   Mesh.cc
@@ -7,4 +7,2 @@
   WindowEventListener.cc
 )
-
-ADD_SOURCE_FILES(SRC_FILES)
