Index: code/branches/buildsystem2/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/CMakeLists.txt	(revision 2587)
+++ code/branches/buildsystem2/CMakeLists.txt	(revision 2588)
@@ -45,4 +45,10 @@
 SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0 CACHE STRING "")
 FIND_PACKAGE(Boost 1.34 REQUIRED thread filesystem)
+# With MSVC, automatic linking is performed for boost. So wee need to tell
+# the linker where to find them. Also note that when running FindBoost for the
+# first time, it will set ${Boost_LIBRARIES} to "" but afterwards to the libs.
+IF (MSVC)
+  LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
+ENDIF (MSVC)
 FIND_PACKAGE(OGRE REQUIRED)
 FIND_PACKAGE(CEGUI REQUIRED)
Index: code/branches/buildsystem2/cmake/ConfigMSVC.cmake
===================================================================
--- code/branches/buildsystem2/cmake/ConfigMSVC.cmake	(revision 2587)
+++ code/branches/buildsystem2/cmake/ConfigMSVC.cmake	(revision 2588)
@@ -26,11 +26,13 @@
  #
  
-############## MSVC config ################
-# Set the library directory when using precompiled tarballs for
-# the dependencies under windows (MSVC)
-###########################################
+###################### MSVC config ########################
+# Set the library directories and special options when
+# using Visual Studio.
+###########################################################
 
 IF (MSVC)
   MESSAGE(STATUS "Running on MSVC. Using customized paths and options.")
+
+  ###################### Libraries ########################
 
   # Determine library directory
@@ -54,5 +56,5 @@
   SET(ENV{OPENALDIR}         ${MSVC_LIBRARY_DIR}/openal-1.1)
   SET(ENV{LUA_DIR}           ${MSVC_LIBRARY_DIR}/lua-5.1.3)
-  SET(ENV{OGRE_HOME}        "${MSVC_LIBRARY_DIR}/ogre-1.4.9;${ORXONOX_LIBRARY_BIN_DIR}")
+  SET(ENV{OGRE_HOME}        "${MSVC_LIBRARY_DIR}/ogre-1.4.9;${MSVC_LIBRARY_DIR}/bin")
   SET(TCL_INCLUDE_PATH       ${MSVC_LIBRARY_DIR}/tcl-8.5.2/include)
   SET(TCL_LIBRARY            ${MSVC_LIBRARY_DIR}/tcl-8.5.2/lib/tcl85t.lib)
@@ -66,23 +68,58 @@
   SET(ZLIB_FOUND TRUE)
 
+  #################### Compiler Flags #####################
 
-  # Set standard compiler flags
-  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")
+  # /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}")
 
-  # Linker flags
-  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")
+  # 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")
+
+  ##################### Linker Flags ######################
+
+  SET(MSVC_LINKER_FLAGS                        "")
+  SET(CMAKE_EXE_LINKER_FLAGS                   "${MSVC_LINKER_FLAGS}")
+  SET(CMAKE_SHARED_LINKER_FLAGS                "${MSVC_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}")
 
   ######################### Misc ##########################
Index: code/branches/buildsystem2/cmake/ConfigPlatforms.cmake
===================================================================
--- code/branches/buildsystem2/cmake/ConfigPlatforms.cmake	(revision 2587)
+++ code/branches/buildsystem2/cmake/ConfigPlatforms.cmake	(revision 2588)
@@ -70,4 +70,17 @@
 SET(CMAKE_MODULE_LINKER_FLAGS " --no-undefined")
 
+# 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)
+
 ########## Plaform Specific Config ##############
 
Index: code/branches/buildsystem2/src/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/CMakeLists.txt	(revision 2587)
+++ code/branches/buildsystem2/src/CMakeLists.txt	(revision 2588)
@@ -37,5 +37,6 @@
 
 # Set special macro symbols across all libraries
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTIXML_USE_TICPP")
+ADD_CXX_FLAGS("-DTIXML_USE_TICPP" TRUE)
+ADD_C_FLAGS("-DTIXML_USE_TICPP" TRUE)
 
 # Include macros
Index: code/branches/buildsystem2/src/audio/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/audio/CMakeLists.txt	(revision 2587)
+++ code/branches/buildsystem2/src/audio/CMakeLists.txt	(revision 2588)
@@ -6,10 +6,13 @@
 )
 
-IF (WIN32)
+ADD_CXX_FLAGS("-wd4244" MSVC)
+
+IF (MINGW)
   ADD_LIBRARY( audio ${AUDIO_SRC_FILES} )
-ELSE (WIN32)
+ELSE (MINGW)
   ADD_LIBRARY( audio SHARED ${AUDIO_SRC_FILES} )
-ENDIF (WIN32)
+ENDIF (MINGW)
 
+SET_TARGET_PROPERTIES(audio PROPERTIES DEFINE_SYMBOL "AUDIO_SHARED_BUILD")
 TARGET_LINK_LIBRARIES( audio
   ${OPENAL_LIBRARY}
Index: code/branches/buildsystem2/src/ceguilua-0.5.0/ceguilua/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/ceguilua-0.5.0/ceguilua/CMakeLists.txt	(revision 2587)
+++ code/branches/buildsystem2/src/ceguilua-0.5.0/ceguilua/CMakeLists.txt	(revision 2588)
@@ -6,6 +6,9 @@
 )
 
+ADD_CXX_FLAGS("-wd4996" MSVC)
+
 ADD_LIBRARY( ceguilua_orxonox SHARED ${CEGUILUA_SRC_FILES} )
 
+SET_TARGET_PROPERTIES(ceguilua_orxonox PROPERTIES DEFINE_SYMBOL "CEGUILUA_EXPORTS")
 TARGET_LINK_LIBRARIES(ceguilua_orxonox
   tolualib_orxonox
Index: code/branches/buildsystem2/src/ceguilua-0.6.1/ceguilua/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/ceguilua-0.6.1/ceguilua/CMakeLists.txt	(revision 2587)
+++ code/branches/buildsystem2/src/ceguilua-0.6.1/ceguilua/CMakeLists.txt	(revision 2588)
@@ -6,6 +6,9 @@
 )
 
+ADD_CXX_FLAGS("-wd4996" MSVC)
+
 ADD_LIBRARY( ceguilua_orxonox SHARED ${CEGUILUA_SRC_FILES} )
 
+SET_TARGET_PROPERTIES(ceguilua_orxonox PROPERTIES DEFINE_SYMBOL "CEGUILUA_EXPORTS")
 TARGET_LINK_LIBRARIES(ceguilua_orxonox
   tolualib_orxonox
Index: code/branches/buildsystem2/src/core/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/core/CMakeLists.txt	(revision 2587)
+++ code/branches/buildsystem2/src/core/CMakeLists.txt	(revision 2588)
@@ -51,4 +51,5 @@
 ADD_LIBRARY(core SHARED ${CORE_SRC_FILES})
 
+SET_TARGET_PROPERTIES(core PROPERTIES DEFINE_SYMBOL "CORE_SHARED_BUILD")
 TARGET_LINK_LIBRARIES(core
   ${OGRE_LIBRARY}
Index: code/branches/buildsystem2/src/cpptcl/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/cpptcl/CMakeLists.txt	(revision 2587)
+++ code/branches/buildsystem2/src/cpptcl/CMakeLists.txt	(revision 2588)
@@ -1,3 +1,7 @@
-ADD_LIBRARY(cpptcl_orxonox SHARED CppTcl.cc)
+IF(MSVC)
+  ADD_LIBRARY(cpptcl_orxonox STATIC CppTcl.cc)
+ELSE(MSVC)
+  ADD_LIBRARY(cpptcl_orxonox SHARED CppTcl.cc)
+ENDIF(MSVC)
 
 TARGET_LINK_LIBRARIES(cpptcl_orxonox
Index: code/branches/buildsystem2/src/network/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/network/CMakeLists.txt	(revision 2587)
+++ code/branches/buildsystem2/src/network/CMakeLists.txt	(revision 2588)
@@ -18,11 +18,13 @@
 
 WRITE_SOURCE_FILES(NETWORK_SRC_FILES)
-IF(WIN32)
+
+IF(MINGW)
   ADD_LIBRARY( network ${NETWORK_SRC_FILES} )
-ELSE(WIN32)
+ELSE(MINGW)
   ADD_LIBRARY( network SHARED ${NETWORK_SRC_FILES} )
-ENDIF(WIN32)
+ENDIF(MINGW)
 
-TARGET_LINK_LIBRARIES( network
+SET_TARGET_PROPERTIES(network PROPERTIES DEFINE_SYMBOL "NETWORK_SHARED_BUILD")
+TARGET_LINK_LIBRARIES(network
   ${ZLIB_LIBRARY}
   ${ENET_LIBRARY}
Index: code/branches/buildsystem2/src/ogreceguirenderer/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/ogreceguirenderer/CMakeLists.txt	(revision 2587)
+++ code/branches/buildsystem2/src/ogreceguirenderer/CMakeLists.txt	(revision 2588)
@@ -7,4 +7,5 @@
 ADD_LIBRARY(ogreceguirenderer_orxonox SHARED ${SRC_FILES})
 
+SET_TARGET_PROPERTIES(ogreceguirenderer_orxonox PROPERTIES DEFINE_SYMBOL "OGRE_GUIRENDERER_EXPORTS")
 TARGET_LINK_LIBRARIES(ogreceguirenderer_orxonox
   ${OGRE_LIBRARY}
Index: code/branches/buildsystem2/src/ois/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/ois/CMakeLists.txt	(revision 2587)
+++ code/branches/buildsystem2/src/ois/CMakeLists.txt	(revision 2588)
@@ -39,4 +39,5 @@
 
 ADD_LIBRARY( ois_orxonox SHARED ${OIS_SRC_FILES} )
+SET_TARGET_PROPERTIES(ois_orxonox PROPERTIES DEFINE_SYMBOL "OIS_NONCLIENT_BUILD")
 
 IF(WIN32)
Index: code/branches/buildsystem2/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/CMakeLists.txt	(revision 2587)
+++ code/branches/buildsystem2/src/orxonox/CMakeLists.txt	(revision 2588)
@@ -20,4 +20,7 @@
 # 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})
Index: code/branches/buildsystem2/src/tinyxml/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/tinyxml/CMakeLists.txt	(revision 2587)
+++ code/branches/buildsystem2/src/tinyxml/CMakeLists.txt	(revision 2588)
@@ -7,5 +7,9 @@
 )
 
-ADD_LIBRARY(tinyxml_orxonox SHARED ${TINYXML_SRC_FILES})
+IF(MSVC)
+  ADD_LIBRARY(tinyxml_orxonox STATIC ${TINYXML_SRC_FILES})
+ELSE(MSVC)
+  ADD_LIBRARY(tinyxml_orxonox SHARED ${TINYXML_SRC_FILES})
+ENDIF(MSVC)
 
 IF (NOT WIN32)
Index: code/branches/buildsystem2/src/tolua/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/tolua/CMakeLists.txt	(revision 2587)
+++ code/branches/buildsystem2/src/tolua/CMakeLists.txt	(revision 2588)
@@ -1,2 +1,4 @@
+ADD_C_FLAGS("-wd4996" MSVC)
+
 ADD_LIBRARY(tolualib_orxonox SHARED
   tolua_event.c
@@ -6,4 +8,5 @@
   tolua_to.c
 )
+SET_TARGET_PROPERTIES(tolualib_orxonox PROPERTIES DEFINE_SYMBOL "TOLUA_SHARED_BUILD")
 TARGET_LINK_LIBRARIES(tolualib_orxonox ${LUA_LIBRARY})
 
Index: code/branches/buildsystem2/src/util/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/util/CMakeLists.txt	(revision 2587)
+++ code/branches/buildsystem2/src/util/CMakeLists.txt	(revision 2588)
@@ -14,4 +14,5 @@
 
 ADD_LIBRARY(util SHARED ${UTIL_SRC_FILES})
+SET_TARGET_PROPERTIES(util PROPERTIES DEFINE_SYMBOL "UTIL_SHARED_BUILD")
 TARGET_LINK_LIBRARIES(util ${OGRE_LIBRARY})
 
