Index: code/branches/buildsystem2/cmake/BuildConfig.cmake
===================================================================
--- code/branches/buildsystem2/cmake/BuildConfig.cmake	(revision 2618)
+++ 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)
