Index: code/branches/buildsystem3/src/tolua/CMakeLists.txt
===================================================================
--- code/branches/buildsystem3/src/tolua/CMakeLists.txt	(revision 2663)
+++ code/branches/buildsystem3/src/tolua/CMakeLists.txt	(revision 2664)
@@ -1,3 +1,27 @@
-SET (TOLUALIB_SRC_FILES
+ #
+ #             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.
+ #
+
+################### Tolua++ library ###################
+
+SET(TOLUA++_FILES
+  tolua_event.h
+  tolua++.h
+
   tolua_event.c
   tolua_is.c
@@ -6,68 +30,49 @@
   tolua_to.c
 )
+GENERATE_SOURCE_GROUPS(${TOLUA++_FILES})
 
-ADD_LIBRARY (tolualib_orxonox SHARED ${TOLUALIB_SRC_FILES})
+ADD_COMPILER_FLAGS("-w44996" MSVC)
 
-TARGET_LINK_LIBRARIES (tolualib_orxonox
-  lua_orxonox
-)
+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})
+
+ORXONOX_INSTALL(tolua++_orxonox)
 
 
-SET (TOLUAGEN_SRC_FILES
-  tolua.c
-  toluabind.c
+################## Tolua++ generator ##################
+
+ADD_EXECUTABLE(tolua++app_orxonox tolua.c)
+TARGET_LINK_LIBRARIES(tolua++app_orxonox tolua++_orxonox ${LUA_LIBRARIES})
+
+OPTION(TOLUA_PARSER_RELEASE "Disable all debug messages from tolua bind files for Release and MinSizeRel build types." FALSE)
+
+# Set some variables to the cache in order to use them in the TOLUA macro
+SET(TOLUA_PARSER_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/all-${LUA_VERSION}.lua" CACHE INTERNAL "")
+SET(TOLUA_PARSER_DEPENDENCIES
+  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
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/basic.lua
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/feature.lua
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/verbatim.lua
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/code.lua
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/typedef.lua
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/container.lua
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/package.lua
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/module.lua
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/namespace.lua
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/define.lua
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/enumerate.lua
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/declaration.lua
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/variable.lua
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/array.lua
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/function.lua
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/operator.lua
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/class.lua
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/clean.lua
+  ${CMAKE_CURRENT_SOURCE_DIR}/lua/doit.lua
+
+  CACHE INTERNAL ""
 )
-
-ADD_EXECUTABLE (toluagen_orxonox ${TOLUAGEN_SRC_FILES})
-
-TARGET_LINK_LIBRARIES (toluagen_orxonox
-  lua_orxonox
-  tolualib_orxonox
-  m
-)
-
-
-SET (TOLUA_PACKAGE "../../src/tolua/tolua-5.1.pkg")
-GET_TARGET_PROPERTY(TOLUAGEN_EXE toluagen_orxonox LOCATION)
-ADD_CUSTOM_COMMAND(
-  OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/toluabind_orxonox.c
-  COMMAND ${TOLUAGEN_EXE} -n tolua -o ../../src/tolua/toluabind_orxonox.c -H ../../src/tolua/toluabind_orxonox.h ${TOLUA_PACKAGE}
-  DEPENDS
-    toluagen_orxonox
-    tolua-5.1.pkg
-    lua/compat-5.1.lua
-    lua/compat.lua
-    lua/basic.lua
-    lua/feature.lua
-    lua/verbatim.lua
-    lua/code.lua
-    lua/typedef.lua
-    lua/container.lua
-    lua/package.lua
-    lua/module.lua
-    lua/namespace.lua
-    lua/define.lua
-    lua/enumerate.lua
-    lua/declaration.lua
-    lua/variable.lua
-    lua/array.lua
-    lua/function.lua
-    lua/operator.lua
-    lua/class.lua
-    lua/clean.lua
-    lua/doit.lua
-  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib
-)
-
-SET (TOLUAEXE_SRC_FILES
-  tolua.c
-  toluabind_orxonox.c
-)
-
-ADD_EXECUTABLE (tolua_orxonox ${TOLUAEXE_SRC_FILES})
-
-TARGET_LINK_LIBRARIES (tolua_orxonox
-  lua_orxonox
-  tolualib_orxonox
-  m
-)
