Index: code/trunk/cmake/BundleConfig.cmake
===================================================================
--- code/trunk/cmake/BundleConfig.cmake	(revision 8351)
+++ code/trunk/cmake/BundleConfig.cmake	(revision 8351)
@@ -0,0 +1,65 @@
+#
+#             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.
+#
+#
+#  Author:
+#    Kevin Young
+#  Description:
+#    Sets all necessary variables for CPack package generation
+#
+
+# Common properties across all generators
+
+#SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY FALSE)
+SET(CPACK_INSTALL_CMAKE_PROJECTS ${CMAKE_BINARY_DIR};${PROJECT_NAME};ALL;/)
+SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README")
+SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_NAME}")
+SET(CPACK_PACKAGE_EXECUTABLES ${ORXONOX_EXECUTABLE_NAME};${PROJECT_NAME})
+SET(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}")
+SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME} ${ORXONOX_VERSION_NAME}")
+SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${PROJECT_NAME} ${ORXONOX_VERSION}")
+# Defaults to PROJECT_NAME anyway
+#SET(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
+SET(CPACK_PACKAGE_VENDOR "www.orxonox.net")
+SET(CPACK_PACKAGE_VERSION_MAJOR ${ORXONOX_VERSION_MAJOR})
+SET(CPACK_PACKAGE_VERSION_MINOR ${ORXONOX_VERSION_MINOR})
+SET(CPACK_PACKAGE_VERSION_PATCH ${ORXONOX_VERSION_PATCH})
+#SET(CPACK_PROJECT_CONFIG_FILE ${CMAKE_BINARY_DIR}/CPackOptions.cmake)
+SET(CPACK_SOURCE_GENERATOR TGZ;ZIP)
+# Unsure what pattern to set here
+#SET(CPACK_SOURCE_IGNORE_FILES /CVS/;/\\.svn/;\\.swp$;\\.#;/#;.*~;cscope.*)
+SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${ORXONOX_VERSION}")
+#SET(CPACK_SOURCE_STRIP_FILES FALSE)
+# Defaults to CMAKE_SYSTEM_NAME anyway
+#SET(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}")
+
+# Advanced settings
+SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENCE")
+  
+# Apple specific settings
+IF(APPLE)
+  SET(CPACK_GENERATOR "Bundle")
+
+  SET(CPACK_BUNDLE_NAME "${CPACK_PACKAGE_FILE_NAME}")
+  SET(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/${DEFAULT_DATA_PATH}/mac/Icon.icns")
+  SET(CPACK_BUNDLE_PLIST "${CMAKE_SOURCE_DIR}/${DEFAULT_DATA_PATH}/mac/Orxonox-Info.plist")
+  SET(CPACK_BUNDLE_STARTUP_COMMAND "${CMAKE_SOURCE_DIR}/${DEFAULT_RUNTIME_PATH}/mac/OrxonoxMac")
+ENDIF(APPLE)
+
+# Fire up CPack
+INCLUDE(CPack)
Index: code/trunk/cmake/CompilerConfig.cmake
===================================================================
--- code/trunk/cmake/CompilerConfig.cmake	(revision 8264)
+++ code/trunk/cmake/CompilerConfig.cmake	(revision 8351)
@@ -34,11 +34,2 @@
   MESSAGE(STATUS "Warning: Your compiler is not officially supported.")
 ENDIF()
-
-SET(COMPILER_CONFIG_USER_SCRIPT "" CACHE FILEPATH
-    "Specify a CMake script if you wish to write your own compiler config.
-     See CompilerConfigGCC.cmake or CompilerConfigMSVC.cmake for examples.")
-IF(COMPILER_CONFIG_USER_SCRIPT)
-  IF(EXISTS ${CMAKE_MODULE_PATH}/${COMPILER_CONFIG_USER_SCRIPT})
-    INCLUDE(${CMAKE_MODULE_PATH}/${COMPILER_CONFIG_USER_SCRIPT})
-  ENDIF()
-ENDIF(COMPILER_CONFIG_USER_SCRIPT)
Index: code/trunk/cmake/CompilerConfigGCC.cmake
===================================================================
--- code/trunk/cmake/CompilerConfigGCC.cmake	(revision 8264)
+++ code/trunk/cmake/CompilerConfigGCC.cmake	(revision 8351)
@@ -26,4 +26,5 @@
 INCLUDE(FlagUtilities)
 INCLUDE(CompareVersionStrings)
+INCLUDE(CheckCXXCompilerFlag)
 
 # Shortcut for CMAKE_COMPILER_IS_GNUCXX and ..._GNUC
@@ -36,20 +37,4 @@
   OUTPUT_VARIABLE GCC_VERSION
 )
-
-# Complain about incompatibilities
-COMPARE_VERSION_STRINGS("${GCC_VERSION}" "4.4.0" _compare_result)
-IF(NOT _compare_result LESS 0)
-  IF(${Boost_VERSION} LESS 103700)
-    MESSAGE(STATUS "Warning: Boost versions earlier than 1.37 may not compile with GCC 4.4 or later!")
-  ENDIF()
-ENDIF()
-
-# GCC may not support #pragma GCC system_header correctly when using
-# templates. According to Bugzilla, it was fixed March 07 but tests
-# have confirmed that GCC 4.0.0 does not pose a problem for our cases.
-COMPARE_VERSION_STRINGS("${GCC_VERSION}" "4.0.0" _compare_result)
-IF(_compare_result LESS 0)
-  SET(GCC_NO_SYSTEM_HEADER_SUPPORT TRUE)
-ENDIF()
 
 # GCC only supports PCH in versions 3.4 and above
@@ -72,14 +57,32 @@
 
 # CMake doesn't seem to set the PIC flags right on certain 64 bit systems
-IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
+IF(NOT MINGW AND ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
   ADD_COMPILER_FLAGS("-fPIC" CACHE)
+ENDIF()
+
+# Enable non standard floating point optimisations
+ADD_COMPILER_FLAGS("-ffast-math" CACHE)
+
+# Use SSE if possible
+# Commented because this might not work for cross compiling
+#CHECK_CXX_COMPILER_FLAG(-msse _gcc_have_sse)
+#IF(_gcc_have_sse)
+#  ADD_COMPILER_FLAGS("-msse" CACHE)
+#ENDIF()
+
+IF(NOT MINGW)
+  # Have GCC visibility?
+  CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" _gcc_have_visibility)
+  IF(_gcc_have_visibility)
+    # Note: There is a possible bug with the flag in gcc < 4.2 and Debug versions
+    COMPARE_VERSION_STRINGS("${GCC_VERSION}" "4.2.0" _compare_result)
+    IF(NOT CMAKE_BUILD_TYPE STREQUAL "Debug" OR _compare_result GREATER -1)
+      ADD_COMPILER_FLAGS("-DORXONOX_GCC_VISIBILITY -fvisibility=default -fvisibility-inlines-hidden" CACHE)
+    ENDIF()
+  ENDIF(_gcc_have_visibility)
 ENDIF()
 
 # We have some unconformant code, disable an optimisation feature
 ADD_COMPILER_FLAGS("-fno-strict-aliasing" CACHE)
-
-# For GCC older than version 4, do not display sign compare warnings
-# because of boost::filesystem (which creates about a hundred per include)
-ADD_COMPILER_FLAGS("-Wno-sign-compare" GCC_NO_SYSTEM_HEADER_SUPPORT CACHE)
 
 # For newer GCC (4.3 and above), don't display hundreds of annoying deprecated
@@ -98,6 +101,9 @@
 ENDIF()
 
-# General linker flags
-SET_LINKER_FLAGS("--no-undefined" CACHE)
+# Linker flags
+IF(LINUX)
+  # Don't allow undefined symbols in a shared library
+  SET_LINKER_FLAGS("-Wl,--no-undefined" CACHE)
+ENDIF()
 
 # Add compiler and linker flags for MinGW
Index: code/trunk/cmake/CompilerConfigMSVC.cmake
===================================================================
--- code/trunk/cmake/CompilerConfigMSVC.cmake	(revision 8264)
+++ code/trunk/cmake/CompilerConfigMSVC.cmake	(revision 8351)
@@ -60,9 +60,11 @@
 
 # Overwrite CMake default flags here for the individual configurations
-SET_COMPILER_FLAGS("-MDd -Od -Zi -D_DEBUG -RTC1" Debug          CACHE)
-SET_COMPILER_FLAGS("-MD  -O2     -DNDEBUG"       Release        CACHE)
-SET_COMPILER_FLAGS("-MD  -O2 -Zi -DNDEBUG"       RelWithDebInfo CACHE)
-SET_COMPILER_FLAGS("-MD  -O1     -DNDEBUG"       MinSizeRel     CACHE)
-ADD_COMPILER_FLAGS("-D_SECURE_SCL=0"       MSVC9 ReleaseAll     CACHE)
+SET_COMPILER_FLAGS("-MDd -Od -Oi -Zi -D_DEBUG -RTC1" Debug          CACHE)
+SET_COMPILER_FLAGS("-MD  -O2         -DNDEBUG"       Release        CACHE)
+SET_COMPILER_FLAGS("-MD  -O2     -Zi -DNDEBUG"       RelWithDebInfo CACHE)
+SET_COMPILER_FLAGS("-MD  -O1         -DNDEBUG"       MinSizeRel     CACHE)
+
+# Enable non standard floating point optimisations
+ADD_COMPILER_FLAGS("-fp:fast" CACHE)
 
 # Use Link time code generation for Release config if ORXONOX_RELEASE is defined
Index: code/trunk/cmake/InstallCheck.cmake
===================================================================
--- code/trunk/cmake/InstallCheck.cmake	(revision 8351)
+++ code/trunk/cmake/InstallCheck.cmake	(revision 8351)
@@ -0,0 +1,30 @@
+ #
+ #             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.
+ #
+ #
+ #  Author:
+ #    Reto Grieder
+ #  Description:
+ #    Prevents user from installing debug builds.
+ #  Note:
+ #    This script is executed at install time, not CMake time!
+ #
+
+IF("${CMAKE_INSTALL_CONFIG_NAME}" STREQUAL "Debug")
+  MESSAGE(FATAL_ERROR "Installing debug builds is not supported!")
+ENDIF()
Index: code/trunk/cmake/InstallConfig.cmake
===================================================================
--- code/trunk/cmake/InstallConfig.cmake	(revision 8264)
+++ code/trunk/cmake/InstallConfig.cmake	(revision 8351)
@@ -39,23 +39,27 @@
 ENDIF()
 
-# Default installation paths
-SET(RUNTIME_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${DEFAULT_RUNTIME_PATH})
-SET(LIBRARY_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${DEFAULT_LIBRARY_PATH})
-SET(ARCHIVE_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${DEFAULT_ARCHIVE_PATH})
-SET(MODULE_INSTALL_DIRECTORY  ${CMAKE_INSTALL_PREFIX}/${DEFAULT_MODULE_PATH})
-SET(DOC_INSTALL_DIRECTORY     ${CMAKE_INSTALL_PREFIX}/${DEFAULT_DOC_PATH})
-SET(DATA_INSTALL_DIRECTORY    ${CMAKE_INSTALL_PREFIX}/${DEFAULT_DATA_PATH})
-SET(CONFIG_INSTALL_DIRECTORY  ${CMAKE_INSTALL_PREFIX}/${DEFAULT_CONFIG_PATH})
-SET(LOG_INSTALL_DIRECTORY     ${CMAKE_INSTALL_PREFIX}/${DEFAULT_LOG_PATH})
+# Default relative installation paths
+SET(RUNTIME_INSTALL_DIRECTORY ${DEFAULT_RUNTIME_PATH})
+SET(LIBRARY_INSTALL_DIRECTORY ${DEFAULT_LIBRARY_PATH})
+SET(ARCHIVE_INSTALL_DIRECTORY ${DEFAULT_ARCHIVE_PATH})
+SET(MODULE_INSTALL_DIRECTORY  ${DEFAULT_MODULE_PATH})
+SET(DOC_INSTALL_DIRECTORY     ${DEFAULT_DOC_PATH})
+SET(DATA_INSTALL_DIRECTORY    ${DEFAULT_DATA_PATH})
+SET(CONFIG_INSTALL_DIRECTORY  ${DEFAULT_CONFIG_PATH})
+SET(LOG_INSTALL_DIRECTORY     ${DEFAULT_LOG_PATH})
 
 IF(NOT INSTALL_COPYABLE)
-  IF(UNIX) # Apple too?
+  IF(LINUX)
     # Using absolute paths
-    SET(RUNTIME_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/games)
-    SET(LIBRARY_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib/games/orxonox)
-    SET(ARCHIVE_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib/games/orxonox/static)
-    SET(MODULE_INSTALL_DIRECTORY  ${CMAKE_INSTALL_PREFIX}/lib/games/orxonox/modules)
-    SET(DOC_INSTALL_DIRECTORY     ${CMAKE_INSTALL_PREFIX}/share/doc/orxonox)
-    SET(DATA_INSTALL_DIRECTORY    ${CMAKE_INSTALL_PREFIX}/share/games/orxonox)
+    SET(RUNTIME_INSTALL_DIRECTORY games)
+    SET(LIBRARY_INSTALL_DIRECTORY lib/games/orxonox)
+    SET(ARCHIVE_INSTALL_DIRECTORY lib/games/orxonox/static)
+    SET(MODULE_INSTALL_DIRECTORY  lib/games/orxonox/modules)
+    SET(DOC_INSTALL_DIRECTORY     share/doc/orxonox)
+    SET(DATA_INSTALL_DIRECTORY    share/games/orxonox)
+  ELSEIF(WIN32)
+    # Leave on default (installs to only one location anyway)
+  ELSEIF(APPLE)
+    # TODO: Figure out what's the best way to install the application
   ENDIF()
 
@@ -67,4 +71,7 @@
 ################## Unix rpath ###################
 
+# Use, i.e. don't skip the full RPATH for the build tree
+SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
+
 # When building, don't use the install RPATH already
 # (but later on when installing)
@@ -73,7 +80,16 @@
 # The RPATH to be used when installing
 IF(INSTALL_COPYABLE)
-  SET(CMAKE_INSTALL_RPATH ${DEFAULT_LIBRARY_PATH})
+  # Get relative paths from run to lib and from module to lib directory.
+  FILE(RELATIVE_PATH _runtime_rpath "/${RUNTIME_INSTALL_DIRECTORY}" "/${LIBRARY_INSTALL_DIRECTORY}")
+  FILE(RELATIVE_PATH _module_rpath  "/${MODULE_INSTALL_DIRECTORY}" "/${LIBRARY_INSTALL_DIRECTORY}")
+  # $ORIGIN (with $ escaped) refers to the actual location of the library
+  # The UNIX loader recognises this special variable
+  SET(RUNTIME_RPATH "\$ORIGIN/${_runtime_rpath}")
+  SET(LIBRARY_RPATH "\$ORIGIN")
+  SET(MODULE_RPATH  "\$ORIGIN:\$ORIGIN/${_module_rpath}")
 ELSE()
-  SET(CMAKE_INSTALL_RPATH ${LIBRARY_INSTALL_DIRECTORY})
+  SET(RUNTIME_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIRECTORY}")
+  SET(LIBRARY_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIRECTORY}")
+  SET(MODULE_RPATH  "${LIBRARY_RPATH}:${CMAKE_INSTALL_PREFIX}/${MODULE_INSTALL_DIRECTORY}")
 ENDIF()
 
Index: code/trunk/cmake/LibraryConfig.cmake
===================================================================
--- code/trunk/cmake/LibraryConfig.cmake	(revision 8264)
+++ code/trunk/cmake/LibraryConfig.cmake	(revision 8351)
@@ -40,15 +40,34 @@
 # On Windows using a package causes way less problems
 SET(_option_msg "Set this to true to use precompiled dependecy archives")
-IF(WIN32)
+IF(WIN32 OR APPLE)
   OPTION(DEPENDENCY_PACKAGE_ENABLE "${_option_msg}" ON)
-ELSE(WIN32)
+ELSE()
   OPTION(DEPENDENCY_PACKAGE_ENABLE "${_option_msg}" FALSE)
-ENDIF(WIN32)
+ENDIF()
 
 # Scripts for specific library and CMake config
 INCLUDE(LibraryConfigTardis)
-INCLUDE(LibraryConfigApple)
 
 IF(DEPENDENCY_PACKAGE_ENABLE)
+  IF(APPLE AND NOT EXISTS ${CMAKE_SOURCE_DIR}/dependencies)
+    # Let CMake automatically download and extract the dependency package on Mac OS X
+    # TODO: Handle download errors and always select newest package
+    SET(_dep_package_current "OrxonoxDeps_110428_2.0_OSX.tar.bz2")
+    SET(_dep_package_url "http://svn.orxonox.net/ogre/apple/precompiled_dependencies")
+    MESSAGE(STATUS "Downloading Mac OS X dependency package.")
+    FILE(DOWNLOAD
+      ${_dep_package_url}/${_dep_package_current}
+      ${CMAKE_SOURCE_DIR}/${_dep_package_current}
+    )
+    MESSAGE(STATUS "Extracting Mac OS X dependency package.")
+    EXECUTE_PROCESS(
+      COMMAND ${CMAKE_COMMAND} -E tar -jxf ${_dep_package_current}
+      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+      OUTPUT_FILE ${CMAKE_BINARY_DIR}/dep_pack_extract_log.keep_me
+    )
+    # Delete the dependency archive once we no longer need it
+    FILE(REMOVE ${CMAKE_SOURCE_DIR}/${_dep_package_current})
+  ENDIF()
+
   GET_FILENAME_COMPONENT(_dep_dir_1 ${CMAKE_SOURCE_DIR}/../dependencies ABSOLUTE)
   GET_FILENAME_COMPONENT(_dep_dir_2 ${CMAKE_SOURCE_DIR}/../lib_dist ABSOLUTE)
@@ -59,4 +78,6 @@
   ELSEIF(MSVC90)
     SET(_compiler_prefix msvc9)
+  ELSEIF(MSVC10)
+    SET(_compiler_prefix msvc10)
   ENDIF()
   FIND_PATH(DEPENDENCY_PACKAGE_DIR
@@ -73,7 +94,11 @@
                    "Disable LIBRARY_USE_PACKAGE if you have none intalled.")
   ELSE()
-    INCLUDE(PackageConfigMinGW)
-    INCLUDE(PackageConfigMSVC)
-    INCLUDE(PackageConfig) # For both msvc and mingw
+    IF(WIN32)
+      INCLUDE(PackageConfigMinGW)
+      INCLUDE(PackageConfigMSVC)
+      INCLUDE(PackageConfig) # For both msvc and mingw
+    ELSEIF(APPLE)
+      INCLUDE(PackageConfigOSX)
+    ENDIF(WIN32)
   ENDIF()
 ENDIF(DEPENDENCY_PACKAGE_ENABLE)
@@ -93,15 +118,12 @@
 # Performs the search and sets the variables    #
 
-FIND_PACKAGE(OGRE  1.4       REQUIRED)
-#FIND_PACKAGE(ENet  1.1       REQUIRED)
+#FIND_PACKAGE(ENet     1.2    REQUIRED)
+FIND_PACKAGE(CEGUI    0.6    REQUIRED)
+FIND_PACKAGE(Lua5.1          REQUIRED)
 FIND_PACKAGE(Ogg             REQUIRED)
 FIND_PACKAGE(Vorbis          REQUIRED)
 FIND_PACKAGE(ALUT            REQUIRED)
 FIND_PACKAGE(ZLIB            REQUIRED)
-IF(POCO_REQUIRED)
-  FIND_PACKAGE(POCO          REQUIRED)
-  # Always link against POCO too because of threading
-  SET(OGRE_LIBRARY ${OGRE_LIBRARY} ${POCO_LIBRARY})
-ENDIF()
+
 IF(WIN32)
   FIND_PACKAGE(DbgHelp)
@@ -109,33 +131,4 @@
 ENDIF()
 
-##### CEGUI #####
-# We make use of the CEGUI script module called CEGUILua.
-# However there is a small issue with that: We use Tolua, a C++ binding
-# generator ourselves. And we also have to use our bindings in the same
-# lua state is CEGUILua's. Unfortunately this implies that both lua runtime
-# version are equal or else you get segmentation faults.
-# In order to match the Lua versions we decided to ship CEGUILua in our
-# repository, mainly because there is no way to determine which version of
-# Lua CEGUILua was linked against (you'd have to specify yourself) and secondly
-# because we can then choose the Lua version. Future plans might involve only
-# accepting Lua 5.1.
-
-# Insert all internally supported CEGUILua versions here
-SET(CEGUILUA_INTERNAL_SUPPORT 0.5.0 0.6.0 0.6.1 0.6.2)
-OPTION(CEGUILUA_USE_EXTERNAL_LIBRARY "Force the use of external CEGUILua library" OFF)
-FIND_PACKAGE(CEGUI 0.5 REQUIRED)
-
-##### Lua #####
-IF(CEGUILUA_USE_EXTERNAL_LIBRARY)
-  COMPARE_VERSION_STRINGS(${CEGUI_VERSION} "0.6" _version_comparison)
-  IF(version_comparison LESS 0)
-    SET(LUA_VERSION_REQUEST 5.0)
-  ELSE()
-    SET(LUA_VERSION_REQUEST 5.1)
-  ENDIF()
-ELSE()
-  SET(LUA_VERSION_REQUEST 5)
-ENDIF()
-FIND_PACKAGE(Lua ${LUA_VERSION_REQUEST} EXACT REQUIRED)
 
 ##### OpenAL #####
@@ -161,12 +154,25 @@
 
 ##### 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 1.40 1.40.0
-                              1.41 1.41.0 1.42 1.42.0 1.43 1.43.0 1.44 1.44.0)
-IF( NOT TARDIS )
-  FIND_PACKAGE(Boost 1.35 REQUIRED thread filesystem system date_time)
+# Expand the next statement if newer boost versions are released
+SET(Boost_ADDITIONAL_VERSIONS 1.40 1.40.0 1.41 1.41.0 1.42 1.42.0 1.43 1.43.0
+                              1.44 1.44.0 1.45 1.45.0 1.46 1.46.0 1.46.1)
+IF(NOT TARDIS)
+  FIND_PACKAGE(Boost 1.40 REQUIRED thread filesystem system date_time)
 ENDIF()
 # No auto linking, so this option is useless anyway
 MARK_AS_ADVANCED(Boost_LIB_DIAGNOSTIC_DEFINITIONS)
+
+##### OGRE #####
+FIND_PACKAGE(OGRE 1.6 REQUIRED)
+# For Ogre >= 1.7, we might need a threading library
+# Variables are either defined by dependency package config or by FindOGRE
+IF(OGRE_NEEDS_POCO)
+  FIND_PACKAGE(POCO REQUIRED)
+  # Always link against POCO too because of threading
+  SET(OGRE_LIBRARY ${OGRE_LIBRARY} ${POCO_LIBRARY})
+ELSEIF(OGRE_NEEDS_BOOST)
+  # Always link against boost too because of threading
+  SET(OGRE_LIBRARY ${OGRE_LIBRARY} ${Boost_THREAD_LIBRARY})
+ENDIF()
 
 
@@ -177,16 +183,11 @@
 # Note: Default option in the libraries vary, but our default option is dynamic
 IF(WIN32)
-  OPTION(LINK_BOOST_DYNAMIC "Link Boost dynamically on Windows" TRUE)
-  OPTION(LINK_CEGUI_DYNAMIC "Link CEGUI dynamicylly on Windows" TRUE)
-  #OPTION(LINK_ENET_DYNAMIC  "Link ENet dynamically on Windows" TRUE)
-  OPTION(LINK_OGRE_DYNAMIC  "Link OGRE dynamically on Windows" TRUE)
-  OPTION(LINK_TCL_DYNAMIC   "Link TCL dynamically on Windows" TRUE)
-  OPTION(LINK_ZLIB_DYNAMIC  "Link ZLib dynamically on Windows" TRUE)
-  COMPARE_VERSION_STRINGS("${LUA_VERSION}" "5.1" _version_comparison)
-  IF(_version_comparison LESS 0)
-    OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" FALSE)
-  ELSE(_version_comparison LESS 0)
-    OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" TRUE)
-  ENDIF(_version_comparison LESS 0)
+  OPTION(LINK_BOOST_DYNAMIC  "Link Boost dynamically on Windows" TRUE)
+  OPTION(LINK_CEGUI_DYNAMIC  "Link CEGUI dynamicylly on Windows" TRUE)
+  #OPTION(LINK_ENET_DYNAMIC   "Link ENet dynamically on Windows" TRUE)
+  OPTION(LINK_OGRE_DYNAMIC   "Link OGRE dynamically on Windows" TRUE)
+  OPTION(LINK_TCL_DYNAMIC    "Link TCL dynamically on Windows" TRUE)
+  OPTION(LINK_ZLIB_DYNAMIC   "Link ZLib dynamically on Windows" TRUE)
+  OPTION(LINK_LUA5.1_DYNAMIC "Link Lua dynamically on Windows" TRUE)
 
   IF(DEPENDENCY_PACKAGE_ENABLE)
@@ -194,5 +195,5 @@
       LINK_BOOST_DYNAMIC LINK_CEGUI_DYNAMIC #LINK_ENET_DYNAMIC
       LINK_OGRE_DYNAMIC  LINK_TCL_DYNAMIC   LINK_ZLIB_DYNAMIC
-      LINK_LUA_DYNAMIC
+      LINK_LUA5.1_DYNAMIC
     )
   ENDIF()
Index: code/trunk/cmake/LibraryConfigApple.cmake
===================================================================
--- code/trunk/cmake/LibraryConfigApple.cmake	(revision 8264)
+++ 	(revision )
@@ -1,43 +1,0 @@
- #
- #             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.
- #
- #
- #  Author:
- #    Yuning Chai
- #  Description:
- #    Sets necessary library options and paths on Mac.
- #
-
-IF(APPLE)
-  MESSAGE(STATUS "Running on Apple. Using customized paths and options.")
-
-  SET(ENV{OGRE_HOME} "/Developer/SDKs/OgreSDK/Dependencies")
-  SET(ENV{CEGUIDIR} "/Developer/SDKs/OgreSDK/Dependencies")
-
-  #MESSAGE(STATUS $ENV{OGRE_HOME})
-
-  SET(CMAKE_FIND_FRAMEWORK "FIRST")
-
-#  SET(OGRE_LIBRARY_OPTIMIZED "/Developer/SDKs/OgreSDK/Dependencies/Ogre.framework/Ogre")
-
-#  SET(CEGUI_LIBRARY_OPTIMIZED "/Developer/SDKs/OgreSDK/Dependencies/CEGUI.framework/CEGUI")
-
-#  SET(OGRE_LIBRARY_OPTIMIZED  "/Developer/SDKs/OgreSDK/Dependencies/Ogre.framework" CACHE STRING "Ogre lib for OSX")
-#  SET(CEGUI_LIBRARY_OPTIMIZED  "/Developer/SDKs/OgreSDK/Dependencies/CEGUI.framework" CACHE STRING "CEGUI lib for OSX")
-
-ENDIF(APPLE)
Index: code/trunk/cmake/LibraryConfigTardis.cmake
===================================================================
--- code/trunk/cmake/LibraryConfigTardis.cmake	(revision 8264)
+++ code/trunk/cmake/LibraryConfigTardis.cmake	(revision 8351)
@@ -25,10 +25,8 @@
  #
 
-IF(UNIX AND NOT APPLE)
-  IF(EXISTS /etc/hostname)
-    FILE(STRINGS /etc/hostname HOSTNAME LIMIT_COUNT 1)
-    IF(${HOSTNAME} MATCHES "^tardis-[a-z][0-9][0-9]$")
-      SET (TARDIS ON)
-    ENDIF()
+IF(LINUX AND EXISTS /etc/hostname)
+  FILE(STRINGS /etc/hostname HOSTNAME LIMIT_COUNT 1)
+  IF(${HOSTNAME} MATCHES "^tardis-[a-z][0-9][0-9]$")
+    SET (TARDIS ON)
   ENDIF()
 ENDIF()
@@ -77,5 +75,5 @@
   #SET(ENV{OGGDIR}      "/usr/pack/oggvorbis-1.0-ds;/usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0")
   #SET(ENV{VORBISDIR}   "/usr/pack/oggvorbis-1.0-ds;/usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0")
-  #SET(ENV{LUA_DIR}     "/usr/pack/lua-5.1.4-sd;/usr/pack/lua-5.1.4-sd/i686-debian-linux4.0")
+  #SET(ENV{LUA5.1_DIR}  "/usr/pack/lua-5.1.4-sd;/usr/pack/lua-5.1.4-sd/i686-debian-linux4.0")
   #SET(ENV{OGRE_HOME}   "/usr/pack/ogre-1.4.9-sd;/usr/pack/ogre-1.4.9-sd/i686-debian-linux4.0")
   #SET(ENV{OPENALDIR}   "/usr/pack/openal-0.0.8-cl;/usr/pack/openal-0.0.8-cl/i686-debian-linux3.1")
Index: code/trunk/cmake/PackageConfig.cmake
===================================================================
--- code/trunk/cmake/PackageConfig.cmake	(revision 8264)
+++ code/trunk/cmake/PackageConfig.cmake	(revision 8351)
@@ -25,45 +25,4 @@
  #
 
-# Check package version info
-# 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 5.0)
-
-IF(NOT EXISTS ${DEPENDENCY_PACKAGE_DIR}/version.txt)
-  SET(DEPENDENCY_VERSION 1.0)
-ELSE()
-  # Get version from file
-  FILE(READ ${DEPENDENCY_PACKAGE_DIR}/version.txt _file_content)
-  SET(_match)
-  STRING(REGEX MATCH "([0-9]+.[0-9]+)" _match ${_file_content})
-  IF(_match)
-    SET(DEPENDENCY_VERSION ${_match})
-  ELSE()
-    MESSAGE(FATAL_ERROR "The version.txt file in the dependency file has corrupt version information.")
-  ENDIF()
-ENDIF()
-
-INCLUDE(CompareVersionStrings)
-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"
-          "Possible required versions: ${ALLOWED_MINIMUM_VERSIONS}\n"
-          "You can get a new version from www.orxonox.net")
-ENDIF()
-
 IF(NOT _INTERNAL_PACKAGE_MESSAGE)
   MESSAGE(STATUS "Using library package for the dependencies.")
@@ -73,6 +32,6 @@
 # Ogre versions >= 1.7 require the POCO library on Windows with MSVC for threading
 COMPARE_VERSION_STRINGS(${DEPENDENCY_VERSION} 5 _result TRUE)
-IF(NOT _result EQUAL -1 AND NOT MINGW)
-    SET(POCO_REQUIRED TRUE)
+IF(NOT _result EQUAL -1 AND NOT APPLE)
+  SET(OGRE_NEEDS_POCO TRUE)
 ENDIF()
 
@@ -84,5 +43,5 @@
 SET(ENV{DXSDK_DIR}             ${DEP_INCLUDE_DIR}/directx)
 #SET(ENV{ENETDIR}               ${DEP_INCLUDE_DIR}/enet)
-SET(ENV{LUA_DIR}               ${DEP_INCLUDE_DIR}/lua)
+SET(ENV{LUA5.1_DIR}            ${DEP_INCLUDE_DIR}/lua)
 SET(ENV{OGGDIR}                ${DEP_INCLUDE_DIR}/libogg)
 SET(ENV{VORBISDIR}             ${DEP_INCLUDE_DIR}/libvorbis)
@@ -116,11 +75,22 @@
 
   ## RELEASE
-  # Try to filter out all the debug libraries. If the regex doesn't do the
-  # job anymore, simply adjust it.
-  INSTALL(
-    DIRECTORY ${DEP_BINARY_DIR}/
-    DESTINATION bin
-    CONFIGURATIONS Release RelWithDebInfo MinSizeRel
-    REGEX "_[Dd]\\.[a-zA-Z0-9+-]+$|-mt-gd-|^.*\\.pdb$" EXCLUDE
-  )
+  IF(EXISTS ${DEP_BINARY_DIR}/install_manifest.txt)
+    FILE(STRINGS ${DEP_BINARY_DIR}/install_manifest.txt _files)
+    FOREACH(_file ${_files})
+      INSTALL(
+        FILES ${DEP_BINARY_DIR}/${_file}
+        DESTINATION bin
+        CONFIGURATIONS Release RelWithDebInfo MinSizeRel
+      )
+    ENDFOREACH(_file)
+  ELSE()
+    # Try to filter out all the debug libraries. If the regex doesn't do the
+    # job anymore, simply adjust it.
+    INSTALL(
+      DIRECTORY ${DEP_BINARY_DIR}/
+      DESTINATION bin
+      CONFIGURATIONS Release RelWithDebInfo MinSizeRel
+      REGEX "_[Dd]\\.[a-zA-Z0-9+-]+$|-mt-gd-|^.*\\.pdb$" EXCLUDE
+    )
+  ENDIF()
 ENDIF()
Index: code/trunk/cmake/PackageConfigMSVC.cmake
===================================================================
--- code/trunk/cmake/PackageConfigMSVC.cmake	(revision 8264)
+++ code/trunk/cmake/PackageConfigMSVC.cmake	(revision 8351)
@@ -28,4 +28,7 @@
 IF(MSVC)
 
+  INCLUDE(CheckPackageVersion)
+  CHECK_PACKAGE_VERSION(4.3 6.0)
+
   # 64 bit system?
   IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
@@ -36,5 +39,5 @@
 
   # Choose right MSVC version
-  STRING(REGEX REPLACE "^Visual Studio ([0-9][0-9]?) .*$" "\\1"
+  STRING(REGEX REPLACE "^Visual Studio ([0-9][0-9]?).*$" "\\1"
          _msvc_version "${CMAKE_GENERATOR}")
 
@@ -54,6 +57,21 @@
   # Certain find scripts don't behave as ecpected to we have
   # to specify the libraries ourselves.
-  SET(TCL_LIBRARY  ${DEP_LIBRARY_DIR}/tcl85.lib CACHE FILEPATH "")
-  SET(ZLIB_LIBRARY ${DEP_LIBRARY_DIR}/zdll.lib  CACHE FILEPATH "")
+  IF(MSVC10)
+    SET(TCL_LIBRARY
+      optimized ${DEP_LIBRARY_DIR}/tcl85t.lib
+      debug     ${DEP_LIBRARY_DIR}/tcl85tg.lib
+      CACHE FILEPATH ""
+    )
+    SET(ZLIB_LIBRARY
+      optimized ${DEP_LIBRARY_DIR}/zlib-vc100.lib
+      debug     ${DEP_LIBRARY_DIR}/zlib-vc100_d.lib
+      CACHE FILEPATH ""
+    )
+  ELSE()
+    SET(TCL_LIBRARY  ${DEP_LIBRARY_DIR}/tcl85.lib CACHE FILEPATH "")
+    SET(ZLIB_LIBRARY ${DEP_LIBRARY_DIR}/zdll.lib  CACHE FILEPATH "")
+  ENDIF()
+  # Part of Platform SDK and usually gets linked automatically
+  SET(WMI_LIBRARY  wbemuuid.lib)
 
 ENDIF(MSVC)
Index: code/trunk/cmake/PackageConfigMinGW.cmake
===================================================================
--- code/trunk/cmake/PackageConfigMinGW.cmake	(revision 8264)
+++ code/trunk/cmake/PackageConfigMinGW.cmake	(revision 8351)
@@ -28,4 +28,7 @@
 IF(MINGW)
 
+  INCLUDE(CheckPackageVersion)
+  CHECK_PACKAGE_VERSION(6.0)
+
   # 64 bit system?
   IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
@@ -48,5 +51,9 @@
   # to specify the libraries ourselves.
   SET(TCL_LIBRARY  ${DEP_BINARY_DIR}/tcl85.dll CACHE FILEPATH "")
-  SET(ZLIB_LIBRARY ${DEP_BINARY_DIR}/zlib1.dll CACHE FILEPATH "")
+  SET(ZLIB_LIBRARY ${DEP_BINARY_DIR}/libzlib.dll CACHE FILEPATH "")
+
+  # Not included in MinGW, so we need to supply it for OIS
+  SET(WMI_INCLUDE_DIR ${DEP_INCLUDE_DIR}/wmi/include)
+  SET(WMI_LIBRARY     ${DEP_LIBRARY_DIR}/wbemuuid.lib)
 
 ENDIF(MINGW)
Index: code/trunk/cmake/PackageConfigOSX.cmake
===================================================================
--- code/trunk/cmake/PackageConfigOSX.cmake	(revision 8351)
+++ code/trunk/cmake/PackageConfigOSX.cmake	(revision 8351)
@@ -0,0 +1,103 @@
+ #
+ #             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.
+ #
+ #
+ #  Author:
+ #    Reto Grieder
+ #  Description:
+ #    OS X package configuration
+ #
+
+INCLUDE(CheckPackageVersion)
+
+CHECK_PACKAGE_VERSION(2.0)
+
+IF(NOT _INTERNAL_PACKAGE_MESSAGE)
+  MESSAGE(STATUS "Using library package for the dependencies.")
+  
+  # The following shell script sets the appropriate install_names for our libraries
+  # and therefore it must be run before anything else is set, dep-package-wise.
+  IF(NOT EXISTS ${CMAKE_BINARY_DIR}/dep_pack_install_log.keep_me)
+    MESSAGE(STATUS "Installing Mac OS X dependency package to current dir.")
+    EXECUTE_PROCESS(
+      COMMAND ${DEPENDENCY_PACKAGE_DIR}/install_dependencies.sh
+      WORKING_DIRECTORY ${DEPENDENCY_PACKAGE_DIR}
+      OUTPUT_FILE ${CMAKE_BINARY_DIR}/dep_pack_install_log.keep_me 
+    )
+  ENDIF()
+  SET(_INTERNAL_PACKAGE_MESSAGE 1 CACHE INTERNAL "Do not edit!" FORCE)
+ENDIF()
+
+SET(DEP_INCLUDE_DIR   ${DEPENDENCY_PACKAGE_DIR}/include)
+SET(DEP_LIBRARY_DIR   ${DEPENDENCY_PACKAGE_DIR}/lib)
+SET(DEP_BINARY_DIR    ${DEPENDENCY_PACKAGE_DIR}/bin)
+SET(DEP_FRAMEWORK_DIR ${DEPENDENCY_PACKAGE_DIR}/Library/Frameworks)
+
+# Sets the library and framwork paths for the FIND_LIBRARY commands
+SET(CMAKE_LIBRARY_PATH   ${DEP_LIBRARY_DIR})
+SET(CMAKE_FRAMEWORK_PATH ${DEP_FRAMEWORK_DIR})
+
+# Include paths and other special treatments
+SET(ENV{BOOST_ROOT}      ${DEPENDENCY_PACKAGE_DIR})
+SET(ENV{OGGDIR}          ${DEP_INCLUDE_DIR})
+SET(ENV{VORBISDIR}       ${DEP_INCLUDE_DIR})
+SET(ENV{OGRE_PLUGIN_DIR} ${DEP_BINARY_DIR})
+
+# Linking to OGRE requires linking to the boost threading library
+SET(OGRE_NEEDS_BOOST TRUE)
+
+# For OS X 10.5 we have to ship modified headers to make it compile
+# on gcc >= 4.2 (binaries stay the same)
+# Sets the library path for the FIND_LIBRARY
+IF(CMAKE_SYSTEM_VERSION STREQUAL "10.5")
+  SET(ENV{OPENALDIR} ${DEP_INCLUDE_DIR}/openal)
+ENDIF()
+
+### INSTALL ###
+
+# Tcl script library
+# TODO: How does this work on OS X?
+# Concerning all OS X install procedures: use CPACK
+#INSTALL(
+#  DIRECTORY ${DEP_LIBRARY_DIR}/tcl/
+#  DESTINATION lib/tcl
+#)
+
+# TODO: Install on OSX
+IF(FALSE)
+  ## DEBUG
+  # When installing a debug version, we really can't know which libraries
+  # are used in released mode because there might be deps of deps.
+  # --> Copy all of them, except the debug databases
+  INSTALL(
+    DIRECTORY ${DEP_BINARY_DIR}/
+    DESTINATION bin
+    CONFIGURATIONS Debug
+    REGEX "^.*\\.pdb$" EXCLUDE
+  )
+
+  ## RELEASE
+  # Try to filter out all the debug libraries. If the regex doesn't do the
+  # job anymore, simply adjust it.
+  INSTALL(
+    DIRECTORY ${DEP_BINARY_DIR}/
+    DESTINATION bin
+    CONFIGURATIONS Release RelWithDebInfo MinSizeRel
+    REGEX "_[Dd]\\.[a-zA-Z0-9+-]+$|-mt-gd-|^.*\\.pdb$" EXCLUDE
+  )
+ENDIF()
Index: code/trunk/cmake/PrepareDevBundle.cmake
===================================================================
--- code/trunk/cmake/PrepareDevBundle.cmake	(revision 8351)
+++ code/trunk/cmake/PrepareDevBundle.cmake	(revision 8351)
@@ -0,0 +1,59 @@
+ #
+ #             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.
+ #
+ #
+ #  Author:
+ #    Kevin Young
+ #  Description:
+ #    Creates the file structure for the development application bundle
+ #
+
+IF(NOT CMAKE_CONFIGURATION_TYPES)
+  SET(_subdirs .)
+  SET(_default_subdir .)
+ELSE()
+  SET(_subdirs ${CMAKE_CONFIGURATION_TYPES})
+  SET(_default_subdir) # No default subdir
+ENDIF()
+
+FOREACH(_subdir ${_subdirs})
+  GET_FILENAME_COMPONENT(CURRENT_RUNTIME_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_subdir} ABSOLUTE)
+
+  # Convenience variables
+  # Note that this is just an empty bundle! The executable itself will
+  # be added at build time
+  SET(DEVBUNDLE_CURRENT_DIR "${CURRENT_RUNTIME_DIR}/${PROJECT_NAME}.app/Contents")
+  SET(DEVBUNDLE_CURRENT_BIN "${DEVBUNDLE_CURRENT_DIR}/MacOS")
+  SET(DEVBUNDLE_CURRENT_RESOURCES "${DEVBUNDLE_CURRENT_DIR}/Resources")
+  SET(DEVBUNDLE_DEFAULT_LANGFILE "English.lproj")
+  SET(DEVBUNDLE_NIB_FILE "MainMenu.nib")
+
+  # Create bundle folder structure
+  FILE(MAKE_DIRECTORY "${DEVBUNDLE_CURRENT_DIR}")
+  FILE(MAKE_DIRECTORY "${DEVBUNDLE_CURRENT_BIN}")
+  FILE(MAKE_DIRECTORY "${DEVBUNDLE_CURRENT_RESOURCES}")
+  FILE(MAKE_DIRECTORY "${DEVBUNDLE_CURRENT_RESOURCES}/${DEVBUNDLE_DEFAULT_LANGFILE}/${DEVBUNDLE_NIB_FILE}")
+  
+  # Populate with Info.plist, NIB-file and the Icon.icns
+  CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/${DEFAULT_DATA_PATH}/mac/Orxonox-Info.plist" "${DEVBUNDLE_CURRENT_DIR}/Info.plist")
+  CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/${DEFAULT_DATA_PATH}/mac/Icon.icns" "${DEVBUNDLE_CURRENT_RESOURCES}/Icon.icns" COPYONLY)
+  CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/${DEFAULT_DATA_PATH}/mac/${DEVBUNDLE_DEFAULT_LANGFILE}/${DEVBUNDLE_NIB_FILE}/designable.nib" "${DEVBUNDLE_CURRENT_RESOURCES}/${DEVBUNDLE_DEFAULT_LANGFILE}/${DEVBUNDLE_NIB_FILE}/designable.nib" COPYONLY)
+  CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/${DEFAULT_DATA_PATH}/mac/${DEVBUNDLE_DEFAULT_LANGFILE}/${DEVBUNDLE_NIB_FILE}/keyedobjects.nib" "${DEVBUNDLE_CURRENT_RESOURCES}/${DEVBUNDLE_DEFAULT_LANGFILE}/${DEVBUNDLE_NIB_FILE}/keyedobjects.nib" COPYONLY)
+  CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/${DEFAULT_DATA_PATH}/mac/${DEVBUNDLE_DEFAULT_LANGFILE}/InfoPlist.strings" "${DEVBUNDLE_CURRENT_RESOURCES}/${DEVBUNDLE_DEFAULT_LANGFILE}/InfoPlist.strings")
+
+ENDFOREACH(_subdir)
Index: code/trunk/cmake/tools/CheckOGREPlugins.cmake
===================================================================
--- code/trunk/cmake/tools/CheckOGREPlugins.cmake	(revision 8264)
+++ code/trunk/cmake/tools/CheckOGREPlugins.cmake	(revision 8351)
@@ -52,10 +52,10 @@
       NAMES ${_plugin}
       PATHS $ENV{OGRE_HOME} $ENV{OGRE_PLUGIN_DIR}
-      PATH_SUFFIXES bin/Release bin/release Release release lib lib/OGRE bin
+      PATH_SUFFIXES bin/Release bin/release Release release lib lib/OGRE bin Ogre.framework/Resources
     )
     FIND_LIBRARY(OGRE_PLUGIN_${_plugin}_DEBUG
       NAMES ${_plugin}d ${_plugin}_d ${_plugin}
       PATHS $ENV{OGRE_HOME} $ENV{OGRE_PLUGIN_DIR}
-      PATH_SUFFIXES bin/Debug bin/debug Debug debug lib lib/OGRE bin
+      PATH_SUFFIXES bin/Debug bin/debug Debug debug lib lib/OGRE bin Ogre.framework/Resources
     )
     # We only need at least one render system. Check at the end.
Index: code/trunk/cmake/tools/CheckPackageVersion.cmake
===================================================================
--- code/trunk/cmake/tools/CheckPackageVersion.cmake	(revision 8351)
+++ code/trunk/cmake/tools/CheckPackageVersion.cmake	(revision 8351)
@@ -0,0 +1,66 @@
+ #
+ #             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.
+ #
+ #
+ #  Author:
+ #    Reto Grieder
+ #  Description:
+ #    Check package version info
+ #    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).
+
+MACRO(CHECK_PACKAGE_VERSION)
+  SET(_allowed_minimum_versions ${ARGN})
+
+  IF(NOT EXISTS ${DEPENDENCY_PACKAGE_DIR}/version.txt)
+    SET(DEPENDENCY_VERSION 1.0)
+  ELSE()
+    # Get version from file
+    FILE(READ ${DEPENDENCY_PACKAGE_DIR}/version.txt _file_content)
+    SET(_match)
+    STRING(REGEX MATCH "([0-9]+.[0-9]+)" _match ${_file_content})
+    IF(_match)
+      SET(DEPENDENCY_VERSION ${_match})
+    ELSE()
+      MESSAGE(FATAL_ERROR "The version.txt file in the dependency file has corrupt version information.")
+    ENDIF()
+  ENDIF()
+  
+  INCLUDE(CompareVersionStrings)
+  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"
+            "Possible required versions: ${_allowed_minimum_versions}\n"
+            "You can get a new version from www.orxonox.net")
+  ENDIF()
+  
+ENDMACRO(CHECK_PACKAGE_VERSION)
Index: code/trunk/cmake/tools/FindALUT.cmake
===================================================================
--- code/trunk/cmake/tools/FindALUT.cmake	(revision 8264)
+++ code/trunk/cmake/tools/FindALUT.cmake	(revision 8351)
@@ -1,72 +1,52 @@
-# - Locate FreeAlut
-# This module defines
-#  ALUT_LIBRARY
-#  ALUT_FOUND, if false, do not try to link against Alut
-#  ALUT_INCLUDE_DIR, where to find the headers
-#
-# $ALUTDIR is an environment variable that would
-# correspond to the ./configure --prefix=$ALUTDIR
-# used in building Alut.
-#
-# Created by Eric Wing. This was influenced by the FindSDL.cmake module.
-# On OSX, this will prefer the Framework version (if found) over others.
-# People will have to manually change the cache values of
-# ALUT_LIBRARY to override this selection.
-# Tiger will include OpenAL as part of the System.
-# But for now, we have to look around.
-# Other (Unix) systems should be able to utilize the non-framework paths.
-#
-# Several changes and additions by Fabian 'x3n' Landau
-# Some simplifications by Adrian Friedli and Reto Grieder
-#                 > www.orxonox.net <
+ #
+ #             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.
+ #
+ #
+ #  Author:
+ #    Kevin Young
+ #  Description:
+ #    Variables defined:
+ #      ALUT_FOUND
+ #      ALUT_INCLUDE_DIR
+ #      ALUT_LIBRARY
+ #
 
 INCLUDE(FindPackageHandleStandardArgs)
 INCLUDE(HandleLibraryTypes)
 
-FIND_PATH(ALUT_INCLUDE_DIR AL/alut.h
-  PATHS
-  $ENV{ALUTDIR}
-  ~/Library/Frameworks/OpenAL.framework
-  /Library/Frameworks/OpenAL.framework
-  /System/Library/Frameworks/OpenAL.framework # Tiger
-  PATH_SUFFIXES include include/OpenAL include/AL Headers
+FIND_PATH(ALUT_INCLUDE_DIR alut.h
+  PATHS $ENV{ALUTDIR}
+  PATH_SUFFIXES include include/AL
 )
-
-# I'm not sure if I should do a special casing for Apple. It is
-# unlikely that other Unix systems will find the framework path.
-# But if they do ([Next|Open|GNU]Step?),
-# do they want the -framework option also?
-IF(${ALUT_INCLUDE_DIR} MATCHES ".framework")
-
-  STRING(REGEX REPLACE "(.*)/.*\\.framework/.*" "\\1" ALUT_FRAMEWORK_PATH_TMP ${ALUT_INCLUDE_DIR})
-  IF("${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
-      OR "${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
-      )
-    # String is in default search path, don't need to use -F
-    SET (ALUT_LIBRARY_OPTIMIZED "-framework OpenAL" CACHE STRING "OpenAL framework for OSX")
-  ELSE()
-    # String is not /Library/Frameworks, need to use -F
-    SET(ALUT_LIBRARY_OPTIMIZED "-F${ALUT_FRAMEWORK_PATH_TMP} -framework OpenAL" CACHE STRING "OpenAL framework for OSX")
-  ENDIF()
-  # Clear the temp variable so nobody can see it
-  SET(ALUT_FRAMEWORK_PATH_TMP "" CACHE INTERNAL "")
-
-ELSE()
-  FIND_LIBRARY(ALUT_LIBRARY_OPTIMIZED
-    NAMES alut
-    PATHS $ENV{ALUTDIR}
-    PATH_SUFFIXES lib libs
-  )
-  FIND_LIBRARY(ALUT_LIBRARY_DEBUG
-    NAMES alutd alut_d alutD alut_D
-    PATHS $ENV{ALUTDIR}
-    PATH_SUFFIXES lib libs
-  )
-ENDIF()
+FIND_LIBRARY(ALUT_LIBRARY_OPTIMIZED
+  NAMES alut ALUT
+  PATHS $ENV{ALUTDIR}
+  PATH_SUFFIXES lib bin/Release bin/release Release release ALUT
+)
+FIND_LIBRARY(ALUT_LIBRARY_DEBUG
+  NAMES alutd alut_d alutD alut_D ALUTd ALUT_d ALUTD ALUT_D
+  PATHS $ENV{ALUTDIR}
+  PATH_SUFFIXES lib bin/Debug bin/debug Debug debug ALUT
+)
 
 # Handle the REQUIRED argument and set ALUT_FOUND
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(ALUT DEFAULT_MSG
-    ALUT_LIBRARY_OPTIMIZED
-    ALUT_INCLUDE_DIR
+  ALUT_LIBRARY_OPTIMIZED
+  ALUT_INCLUDE_DIR
 )
 
@@ -75,6 +55,6 @@
 
 MARK_AS_ADVANCED(
-    ALUT_INCLUDE_DIR
-    ALUT_LIBRARY_OPTIMIZED
-    ALUT_LIBRARY_DEBUG
+  ALUT_INCLUDE_DIR
+  ALUT_LIBRARY_OPTIMIZED
+  ALUT_LIBRARY_DEBUG
 )
Index: code/trunk/cmake/tools/FindCEGUI.cmake
===================================================================
--- code/trunk/cmake/tools/FindCEGUI.cmake	(revision 8264)
+++ code/trunk/cmake/tools/FindCEGUI.cmake	(revision 8351)
@@ -4,14 +4,11 @@
 #  CEGUI_INCLUDE_DIR
 #  CEGUI_LIBRARY, the library to link against to use CEGUI.
+#  CEGUILUA_LIBRARY, the library to link against to use the CEGUI script module.
+#  CEGUI_TOLUA_LIBRARY, the library to link against to use Tolua++.
 #  CEGUI_FOUND, If false, do not try to use CEGUI
 #  CEGUI_VERSION, the version as string "x.y.z"
-#  CEGUILUA_LIBRARY, Script module library
-#  CEGUILUA_USE_INTERNAL_LIBRARY, True if CEGUILUA_LIBRARY was not defined here
 #
 # Input:
 #  ENV{CEGUIDIR}, CEGUI path, optional
-#  FIND CEGUILUA_INTERNAL_SUPPORT, List of all CEGUILua version supported
-#                                  in the source repository
-#  CEGUILUA_USE_EXTERNAL_LIBRARY, Force finding of CEGUILua
 #
 # Created by Matt Williams to find OGRE libraries
@@ -29,12 +26,19 @@
 #                 > www.orxonox.net <
 
+INCLUDE(CompareVersionStrings)
 INCLUDE(DetermineVersion)
 INCLUDE(FindPackageHandleAdvancedArgs)
 INCLUDE(HandleLibraryTypes)
 
+# Find CEGUI headers
 FIND_PATH(CEGUI_INCLUDE_DIR CEGUI.h
   PATHS $ENV{CEGUIDIR}
-  PATH_SUFFIXES include include/CEGUI CEGUI.framework/Headers
+  PATH_SUFFIXES include include/CEGUI
 )
+
+# Inspect CEGUIVersion.h for the version number
+DETERMINE_VERSION(CEGUI ${CEGUI_INCLUDE_DIR}/CEGUIVersion.h)
+
+# Find CEGUI library
 FIND_LIBRARY(CEGUI_LIBRARY_OPTIMIZED
   NAMES CEGUIBase CEGUI
@@ -50,16 +54,98 @@
 )
 
-# Inspect CEGUIVersion.h for the version number
-DETERMINE_VERSION(CEGUI ${CEGUI_INCLUDE_DIR}/CEGUIVersion.h)
+# Find CEGUILua headers
+FIND_PATH(CEGUILUA_INCLUDE_DIR CEGUILua.h
+  PATHS
+    $ENV{CEGUIDIR}
+    $ENV{CEGUILUADIR}
+    ${CEGUI_INCLUDE_DIR}/ScriptingModules/LuaScriptModule
+  PATH_SUFFIXES include include/CEGUI
+)
+# Find CEGUILua libraries
+FIND_LIBRARY(CEGUILUA_LIBRARY_OPTIMIZED
+  NAMES CEGUILua CEGUILuaScriptModule
+  PATHS $ENV{CEGUIDIR} $ENV{CEGUILUADIR}
+  PATH_SUFFIXES lib bin
+)
+FIND_LIBRARY(CEGUILUA_LIBRARY_DEBUG
+  NAMES CEGUILuad CEGUILua_d CEGUILuaScriptModuled CEGUILuaScriptModule_d
+  PATHS $ENV{CEGUIDIR} $ENV{CEGUILUADIR}
+  PATH_SUFFIXES lib bin
+)
+
+# Find CEGUI Tolua++ include file
+# We only need to add this path since we use tolua++ like a normal
+# dependency but it is shipped with CEGUILua.
+FIND_PATH(CEGUI_TOLUA_INCLUDE_DIR tolua++.h
+  PATHS
+    ${CEGUILUA_INCLUDE_DIR}
+    # For newer CEGUI versions >= 0.7
+    ${CEGUILUA_INCLUDE_DIR}/support/tolua++
+    # For Mac OS X, tolua++ is a separate framework in the dependency package
+    ${DEP_FRAMEWORK_DIR}
+  NO_DEFAULT_PATH # Don't attempt to find tolua++ installed on the system
+)
+# Find CEGUI Tolua++ libraries
+FIND_LIBRARY(CEGUI_TOLUA_LIBRARY_OPTIMIZED
+  NAMES CEGUItoluapp tolua++ ceguitolua++
+  PATHS $ENV{CEGUIDIR} ${CEGUITOLUADIR}
+  PATH_SUFFIXES lib bin
+)
+FIND_LIBRARY(CEGUI_TOLUA_LIBRARY_DEBUG
+  NAMES CEGUItoluappd CEGUItoluapp_d tolua++d tolua++_d
+  PATHS $ENV{CEGUIDIR} ${CEGUITOLUADIR}
+  PATH_SUFFIXES lib bin
+)
+
+# Newer versions of CEGUI have the renderer for OGRE shipped with them
+COMPARE_VERSION_STRINGS("${CEGUI_VERSION}" "0.7" _version_compare TRUE)
+IF(_version_compare GREATER -1)
+  # Find CEGUI OGRE Renderer headers
+  FIND_PATH(CEGUI_OGRE_RENDERER_INCLUDE_DIR CEGUIOgreRenderer.h
+    PATHS
+      $ENV{CEGUIDIR}
+      $ENV{CEGUIOGRERENDERERDIR}
+      ${CEGUI_INCLUDE_DIR}/RendererModules/Ogre
+    PATH_SUFFIXES include include/CEGUI
+  )
+  # Find CEGUI OGRE Renderer libraries
+  FIND_LIBRARY(CEGUI_OGRE_RENDERER_LIBRARY_OPTIMIZED
+    NAMES CEGUIOgreRenderer
+    PATHS $ENV{CEGUIDIR} $ENV{CEGUIOGRERENDERERDIR}
+    PATH_SUFFIXES lib bin
+  )
+  FIND_LIBRARY(CEGUI_OGRE_RENDERER_LIBRARY_DEBUG
+    NAMES CEGUIOgreRendererd CEGUIOgreRenderer_d
+    PATHS $ENV{CEGUIDIR} $ENV{CEGUIOGRERENDERERDIR}
+    PATH_SUFFIXES lib bin
+  )
+  SET(CEGUI_OGRE_RENDERER_REQUIRED_VARIABLES
+    CEGUI_OGRE_RENDERER_INCLUDE_DIR
+    CEGUI_OGRE_RENDERER_LIBRARY_OPTIMIZED
+  )
+ELSE()
+  SET(CEGUI_OLD_VERSION TRUE)
+  SET(CEGUI_OGRE_RENDERER_BUILD_REQUIRED TRUE)
+ENDIF()
 
 # Handle the REQUIRED argument and set CEGUI_FOUND
 # Also checks the version requirements if given
 FIND_PACKAGE_HANDLE_ADVANCED_ARGS(CEGUI DEFAULT_MSG "${CEGUI_VERSION}"
+  CEGUI_INCLUDE_DIR
   CEGUI_LIBRARY_OPTIMIZED
-  CEGUI_INCLUDE_DIR
+  CEGUILUA_INCLUDE_DIR
+  CEGUILUA_LIBRARY_OPTIMIZED
+  CEGUI_TOLUA_INCLUDE_DIR
+  CEGUI_TOLUA_LIBRARY_OPTIMIZED
+  ${CEGUI_OGRE_RENDERER_REQUIRED_VARIABLES}
 )
 
 # Collect optimized and debug libraries
 HANDLE_LIBRARY_TYPES(CEGUI)
+HANDLE_LIBRARY_TYPES(CEGUILUA)
+HANDLE_LIBRARY_TYPES(CEGUI_TOLUA)
+IF(NOT CEGUI_OGRE_RENDERER_BUILD_REQUIRED)
+  HANDLE_LIBRARY_TYPES(CEGUI_OGRE_RENDERER)
+ENDIF()
 
 MARK_AS_ADVANCED(
@@ -67,37 +153,12 @@
   CEGUI_LIBRARY_OPTIMIZED
   CEGUI_LIBRARY_DEBUG
+  CEGUILUA_INCLUDE_DIR
+  CEGUILUA_LIBRARY_OPTIMIZED
+  CEGUILUA_LIBRARY_DEBUG
+  CEGUI_TOLUA_INCLUDE_DIR
+  CEGUI_TOLUA_LIBRARY_OPTIMIZED
+  CEGUI_TOLUA_LIBRARY_DEBUG
+  CEGUI_OGRE_RENDERER_INCLUDE_DIR
+  CEGUI_OGRE_RENDERER_LIBRARY_OPTIMIZED
+  CEGUI_OGRE_RENDERER_LIBRARY_DEBUG
 )
-
-LIST(FIND CEGUILUA_INTERNAL_SUPPORT "${CEGUI_VERSION}" _find_result)
-IF(CEGUILUA_USE_EXTERNAL_LIBRARY OR _find_result EQUAL -1)
-  # Also try to find the CEGUILua libraries.
-  # There would already be libraries in src/ for versions 0.5 and 0.6
-  FIND_LIBRARY(CEGUILUA_LIBRARY_OPTIMIZED
-    NAMES CEGUILua
-    PATHS $ENV{CEGUIDIR}
-    PATH_SUFFIXES lib bin
-  )
-  FIND_LIBRARY(CEGUILUA_LIBRARY_DEBUG
-    NAMES CEGUILuad CEGUILua_d
-    PATHS $ENV{CEGUIDIR}
-    PATH_SUFFIXES lib bin
-  )
-
-  SET(CEGUILua_FIND_REQUIRED ${CEGUI_FIND_REQUIRED})
-  # Handle the REQUIRED argument and set CEGUILUA_FOUND
-  FIND_PACKAGE_HANDLE_STANDARD_ARGS(CEGUILua DEFAULT_MSG
-    CEGUILUA_LIBRARY_OPTIMIZED
-  )
-
-  # Collect optimized and debug libraries
-  HANDLE_LIBRARY_TYPES(CEGUILUA)
-
-  MARK_AS_ADVANCED(
-    CEGUILUA_LIBRARY_OPTIMIZED
-    CEGUILUA_LIBRARY_DEBUG
-  )
-
-ELSE(CEGUILUA_USE_EXTERNAL_LIBRARY OR _find_result EQUAL -1)
-  SET(CEGUILUA_USE_INTERNAL_LIBRARY TRUE)
-ENDIF(CEGUILUA_USE_EXTERNAL_LIBRARY OR _find_result EQUAL -1)
-
Index: code/trunk/cmake/tools/FindLua.cmake
===================================================================
--- code/trunk/cmake/tools/FindLua.cmake	(revision 8264)
+++ 	(revision )
@@ -1,184 +1,0 @@
- #
- #             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.
- #
- #
- #  Author:
- #    Reto Grieder
- #  Description:
- #    Finds either Lua 5.0 or Lua 5.1 on the system. The script regards the
- #    VERSION, EXACT, REQUIRED and QUIET arguments. A note about the EXACT
- #    argument: EXACT 5 will match all Lua 5 versions.
- #    When the search was successful, the following variables are set:
- #    LUA_INCLUDE_DIR, LUA_LIBRARIES, LUA_VERSION, LUA_FOUND
- #
-
-INCLUDE(CompareVersionStrings)
-INCLUDE(FindPackageHandleAdvancedArgs)
-INCLUDE(HandleLibraryTypes)
-
-# Macro that determines Lua version. Should work for versions 2.2 and above (current release: 5.1.4)
-FUNCTION(DETERMINE_LUA_VERSION _file _varname)
-  IF(EXISTS ${_file})
-    FILE(STRINGS ${_file} _file_content REGEX "LUA_VERSION|LUA_RELEASE")
-  ELSE()
-    SET(${_varname} "0" PARENT_SCOPE)
-    RETURN()
-  ENDIF()
-  STRING(REGEX REPLACE "^.*LUA_RELEASE[ \t]+\"Lua[ \t]+([.0-9]+)\".*$" "\\1" ${_varname} "${_file_content}")
-  IF(${_varname} STREQUAL "${_file_content}")
-    # At most version 5.1.0
-    STRING(REGEX REPLACE "^.*LUA_VERSION[ \t]+\"Lua[ \t]+([.0-9]+)\".*$" "\\1" ${_varname} "${_file_content}")
-    IF(${_varname} STREQUAL "${_file_content}")
-      MESSAGE(FATAL_ERROR "Could not determine Lua version which means this script has a bug")
-    ENDIF()
-    IF(${_varname} MATCHES "^[0-9]+\\.[0-9]+$")
-      SET(${_varname} "${${_varname}}.0") # E.g. "3.2" is "3.2.0" actually
-    ENDIF()
-  ENDIF()
-  SET(${_varname} "${${_varname}}" PARENT_SCOPE)
-ENDFUNCTION(DETERMINE_LUA_VERSION)
-
-
-# Find Lua 5.1
-FIND_PATH(LUA_5.1_INCLUDE_DIR lua.h
-  PATHS $ENV{LUA_DIR}
-  PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include
-)
-IF(LUA_5.1_INCLUDE_DIR)
-  DETERMINE_LUA_VERSION(${LUA_5.1_INCLUDE_DIR}/lua.h LUA_5.1_VERSION)
-  COMPARE_VERSION_STRINGS("${LUA_5.1_VERSION}" "5.1" _version_compare TRUE)
-  IF(NOT _version_compare EQUAL 0)
-    # Incorrect version found, abort search
-    SET(LUA_5.1_INCLUDE_DIR "LUA_5.1_INCLUDE_DIR-NOTFOUND" CACHE PATH "" FORCE)
-  ELSE()
-    FIND_LIBRARY(LUA_5.1_LIBRARY_OPTIMIZED
-      NAMES lua51 lua5.1 lua
-      PATHS $ENV{LUA_DIR}
-      PATH_SUFFIXES lib64 lib
-    )
-    FIND_LIBRARY(LUA_5.1_LIBRARY_DEBUG
-      NAMES lua51d lua51_d lua5.1d lua5.1_d luad lua_d
-            lua51D lua51_D lua5.1D lua5.1_D luad lua_D
-      PATHS $ENV{LUA_DIR}
-      PATH_SUFFIXES lib64 lib
-    )
-    HANDLE_LIBRARY_TYPES(LUA_5.1)
-    SET(LUA_5.1_LIBRARIES ${LUA_5.1_LIBRARY})
-    IF(LUA_5.1_LIBRARIES)
-      SET(LUA_5.1_FOUND TRUE)
-    ENDIF()
-  ENDIF(NOT _version_compare EQUAL 0)
-ENDIF(LUA_5.1_INCLUDE_DIR)
-
-
-# Find Lua 5.0
-FIND_PATH(LUA_5.0_INCLUDE_DIR lua.h
-  PATHS $ENV{LUA_DIR}
-  PATH_SUFFIXES include/lua50 include/lua5.0 include/lua5 include/lua include
-)
-IF(LUA_5.0_INCLUDE_DIR)
-  DETERMINE_LUA_VERSION(${LUA_5.0_INCLUDE_DIR}/lua.h LUA_5.0_VERSION)
-  COMPARE_VERSION_STRINGS("${LUA_5.0_VERSION}" "5.0" _version_compare TRUE)
-  IF(NOT _version_compare EQUAL 0)
-    # Incorrect version found, abourt search
-    SET(LUA_5.0_INCLUDE_DIR "LUA_5.0_INCLUDE_DIR-NOTFOUND" CACHE PATH "" FORCE)
-  ELSE()
-    FIND_LIBRARY(LUA_5.0_LUA_LIBRARY_OPTIMIZED
-      NAMES lua50 lua5.0 lua5 lua
-      PATHS $ENV{LUA_DIR}
-      PATH_SUFFIXES lib64 lib
-    )
-    FIND_LIBRARY(LUA_5.0_LUA_LIBRARY_DEBUG
-      NAMES lua50d lua50_d lua5.0d lua5.0_d lua5d lua5_d luad lua_d
-            lua50D lua50_D lua5.0D lua5.0_D lua5d lua5_D luaD lua_D
-      PATHS $ENV{LUA_DIR}
-      PATH_SUFFIXES lib64 lib
-    )
-    HANDLE_LIBRARY_TYPES(LUA_5.0_LUA)
-
-    # In an OS X framework, lualib is usually included as part of the framework
-    # (like GLU in OpenGL.framework)
-    IF(${LUA_5.0_LUA_LIBRARY} MATCHES "framework")
-      SET(LUA_5.0_LIBRARIES ${LUA_5.0_LUA_LIBRARY})
-    ELSE()
-      FIND_LIBRARY(LUA_5.0_LUALIB_LIBRARY_OPTIMIZED
-        NAMES lualib50 lualib5.0 lualib5 lualib
-        PATHS $ENV{LUALIB_DIR} $ENV{LUA_DIR}
-        PATH_SUFFIXES lib64 lib
-      )
-      FIND_LIBRARY(LUA_5.0_LUALIB_LIBRARY_DEBUG
-        NAMES lualib50d lualib50_d lualib5.0d lualib5.0_d
-              lualib5d lualib5_d lualibd lualib_d
-              lualib50D lualib50_D lualib5.0D lualib5.0_D
-              lualib5D lualib5_D lualibD lualib_D
-        PATHS $ENV{LUALIB_DIR} $ENV{LUA_DIR}
-        PATH_SUFFIXES lib64 lib
-      )
-      HANDLE_LIBRARY_TYPES(LUA_5.0_LUALIB)
-      # Both libraries are required for Lua 5.0 to be found
-      IF(LUA_5.0_LUA_LIBRARY AND LUA_5.0_LUALIB_LIBRARY)
-        SET(LUA_5.0_LIBRARIES ${LUA_5.0_LUA_LIBRARY} ${LUA_5.0_LUALIB_LIBRARY})
-      ENDIF()
-    ENDIF(${LUA_5.0_LUA_LIBRARY} MATCHES "framework")
-
-    IF(LUA_5.0_LIBRARIES)
-      SET(LUA_5.0_FOUND TRUE)
-    ENDIF()
-  ENDIF(NOT _version_compare EQUAL 0)
-ENDIF(LUA_5.0_INCLUDE_DIR)
-
-# Pick the right version
-IF(Lua_FIND_VERSION_EXACT AND NOT Lua_FIND_VERSION MATCHES "^[0-9]*$")
-  STRING(REGEX REPLACE "^([0-9]+\\.[0-9]+)(\\..*)?$" "\\1" LUA_VERSION_SELECTION ${Lua_FIND_VERSION})
-ELSE()
-  IF(LUA_5.1_FOUND) # Prefer version 5.1 if found
-    SET(LUA_VERSION_SELECTION "5.1")
-  ELSEIF(LUA_5.0_FOUND)
-    SET(LUA_VERSION_SELECTION "5.0")
-  ENDIF()
-ENDIF()
-
-SET(LUA_INCLUDE_DIR "${LUA_${LUA_VERSION_SELECTION}_INCLUDE_DIR}")
-SET(LUA_LIBRARIES "${LUA_${LUA_VERSION_SELECTION}_LIBRARIES}")
-SET(LUA_VERSION_LONG "${LUA_${LUA_VERSION_SELECTION}_VERSION}")
-SET(LUA_VERSION "${LUA_VERSION_SELECTION}")
-
-FIND_PACKAGE_HANDLE_ADVANCED_ARGS(Lua DEFAULT_MSG "${LUA_VERSION_LONG}"
-  LUA_LIBRARIES
-  LUA_INCLUDE_DIR
-)
-
-# Include the math library for Unix only
-IF(LUA_FOUND)
-  IF(UNIX AND NOT APPLE)
-    FIND_LIBRARY(UNIX_MATH_LIBRARY m)
-    SET(LUA_LIBRARIES ${LUA_LIBRARIES} ${UNIX_MATH_LIBRARY})
-  ENDIF()
-ENDIF(LUA_FOUND)
-
-MARK_AS_ADVANCED(
-  LUA_5.0_INCLUDE_DIR
-  LUA_5.0_LUA_LIBRARY_OPTIMIZED
-  LUA_5.0_LUA_LIBRARY_DEBUG
-  LUA_5.0_LUALIB_LIBRARY_OPTIMIZED
-  LUA_5.0_LUALIB_LIBRARY_DEBUG
-  LUA_5.1_INCLUDE_DIR
-  LUA_5.1_LIBRARY_OPTIMIZED
-  LUA_5.1_LIBRARY_DEBUG
-  UNIX_MATH_LIBRARY
-)
Index: code/trunk/cmake/tools/FindLua5.1.cmake
===================================================================
--- code/trunk/cmake/tools/FindLua5.1.cmake	(revision 8351)
+++ code/trunk/cmake/tools/FindLua5.1.cmake	(revision 8351)
@@ -0,0 +1,100 @@
+ #
+ #             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.
+ #
+ #
+ #  Author:
+ #    Reto Grieder
+ #  Description:
+ #    Finds Lua 5.1 on the system.
+ #    Handles REQUIRED and QUIET arguments.
+ #    When the search was successful, the following variables are set:
+ #    LUA5.1_INCLUDE_DIR, LUA5.1_LIBRARY, LUA5.1_VERSION, LUA5.1_FOUND
+ #
+
+INCLUDE(CompareVersionStrings)
+INCLUDE(FindPackageHandleAdvancedArgs)
+INCLUDE(HandleLibraryTypes)
+
+# Macro that determines Lua version. Should work for versions 2.2 and above (current release: 5.1.4)
+FUNCTION(DETERMINE_LUA_VERSION _file _varname)
+  IF(EXISTS ${_file})
+    FILE(STRINGS ${_file} _file_content REGEX "LUA_VERSION|LUA_RELEASE")
+  ELSE()
+    SET(${_varname} "0" PARENT_SCOPE)
+    RETURN()
+  ENDIF()
+  STRING(REGEX REPLACE "^.*LUA_RELEASE[ \t]+\"Lua[ \t]+([.0-9]+)\".*$" "\\1" ${_varname} "${_file_content}")
+  IF(${_varname} STREQUAL "${_file_content}")
+    # At most version 5.1.0
+    STRING(REGEX REPLACE "^.*LUA_VERSION[ \t]+\"Lua[ \t]+([.0-9]+)\".*$" "\\1" ${_varname} "${_file_content}")
+    IF(${_varname} STREQUAL "${_file_content}")
+      MESSAGE(FATAL_ERROR "Could not determine Lua version which means this script has a bug")
+    ENDIF()
+    IF(${_varname} MATCHES "^[0-9]+\\.[0-9]+$")
+      SET(${_varname} "${${_varname}}.0") # E.g. "3.2" is "3.2.0" actually
+    ENDIF()
+  ENDIF()
+  SET(${_varname} "${${_varname}}" PARENT_SCOPE)
+ENDFUNCTION(DETERMINE_LUA_VERSION)
+
+
+# Find include path
+FIND_PATH(LUA5.1_INCLUDE_DIR lua.h
+  PATHS $ENV{LUA5.1_DIR} $ENV{LUA_DIR}
+  PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include
+)
+
+# Check whether we really found Lua version 5.1
+IF(LUA5.1_INCLUDE_DIR)
+  DETERMINE_LUA_VERSION(${LUA5.1_INCLUDE_DIR}/lua.h LUA5.1_VERSION)
+  COMPARE_VERSION_STRINGS("${LUA5.1_VERSION}" "5.1" _version_compare TRUE)
+  IF(NOT _version_compare EQUAL 0)
+    # Wrong version
+    MESSAGE(SEND_ERROR "Version of Lua header found is not 5.1")
+    SET(LUA5.1_INCLUDE_DIR "LUA5.1_INCLUDE_DIR-NOTFOUND" CACHE PATH "" FORCE)
+  ENDIF(NOT _version_compare EQUAL 0)
+ENDIF(LUA5.1_INCLUDE_DIR)
+
+# Find library
+FIND_LIBRARY(LUA5.1_LIBRARY_OPTIMIZED
+  NAMES lua51 lua5.1 lua
+  PATHS $ENV{LUA5.1_DIR} $ENV{LUA_DIR}
+  PATH_SUFFIXES lib64 lib
+)
+FIND_LIBRARY(LUA5.1_LIBRARY_DEBUG
+  NAMES lua51d lua51_d lua5.1d lua5.1_d
+        lua51D lua51_D lua5.1D lua5.1_D
+        luad lua_d luad lua_D
+  PATHS $ENV{LUA5.1_DIR} $ENV{LUA_DIR}
+  PATH_SUFFIXES lib64 lib
+)
+
+# Handle the REQUIRED argument and set LUA5.1_FOUND
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua5.1 DEFAULT_MSG
+  LUA5.1_LIBRARY_OPTIMIZED
+  LUA5.1_INCLUDE_DIR
+)
+
+# Collect optimized and debug libraries
+HANDLE_LIBRARY_TYPES(LUA5.1)
+
+MARK_AS_ADVANCED(
+  LUA5.1_INCLUDE_DIR
+  LUA5.1_LIBRARY_OPTIMIZED
+  LUA5.1_LIBRARY_DEBUG
+)
Index: code/trunk/cmake/tools/FindOGRE.cmake
===================================================================
--- code/trunk/cmake/tools/FindOGRE.cmake	(revision 8264)
+++ code/trunk/cmake/tools/FindOGRE.cmake	(revision 8351)
@@ -23,5 +23,5 @@
 FIND_PATH(OGRE_INCLUDE_DIR Ogre.h
   PATHS $ENV{OGRE_HOME}
-  PATH_SUFFIXES include include/OGRE Ogre.framework/Headers
+  PATH_SUFFIXES include include/OGRE
 )
 FIND_LIBRARY(OGRE_LIBRARY_OPTIMIZED
@@ -33,5 +33,5 @@
   NAMES OgreMaind OgreMain_d OgreMainD OgreMain_D Ogred Ogre_d OgreD Ogre_d
   PATHS $ENV{OGRE_HOME}
-  PATH_SUFFIXES lib bin/Debug bin/debug Debug debug Versions/A
+  PATH_SUFFIXES lib bin/Debug bin/debug Debug debug
 )
 
Index: code/trunk/cmake/tools/FindOgg.cmake
===================================================================
--- code/trunk/cmake/tools/FindOgg.cmake	(revision 8264)
+++ code/trunk/cmake/tools/FindOgg.cmake	(revision 8351)
@@ -22,10 +22,10 @@
 )
 FIND_LIBRARY(OGG_LIBRARY_OPTIMIZED
-  NAMES ogg
+  NAMES ogg ogg-0 libogg
   PATHS $ENV{OGGDIR}
   PATH_SUFFIXES lib
 )
 FIND_LIBRARY(OGG_LIBRARY_DEBUG
-  NAMES oggd ogg_d oggD ogg_D
+  NAMES oggd ogg_d oggD ogg_D libogg_d
   PATHS $ENV{OGGDIR}
   PATH_SUFFIXES lib
Index: code/trunk/cmake/tools/FindPOCO.cmake
===================================================================
--- code/trunk/cmake/tools/FindPOCO.cmake	(revision 8264)
+++ code/trunk/cmake/tools/FindPOCO.cmake	(revision 8351)
@@ -29,5 +29,5 @@
 FIND_PATH(POCO_INCLUDE_DIR Poco/Poco.h
   PATHS $ENV{POCODIR}
-  PATH_SUFFIXES include
+  PATH_SUFFIXES include Foundation/include
 )
 FIND_LIBRARY(POCO_LIBRARY_OPTIMIZED
Index: code/trunk/cmake/tools/FindVorbis.cmake
===================================================================
--- code/trunk/cmake/tools/FindVorbis.cmake	(revision 8264)
+++ code/trunk/cmake/tools/FindVorbis.cmake	(revision 8351)
@@ -22,20 +22,20 @@
 )
 FIND_LIBRARY(VORBIS_LIBRARY_OPTIMIZED
-  NAMES vorbis
+  NAMES vorbis vorbis-0 libvorbis
   PATHS $ENV{VORBISDIR}
   PATH_SUFFIXES lib
 )
 FIND_LIBRARY(VORBIS_LIBRARY_DEBUG
-  NAMES vorbisd vorbis_d vorbisD vorbis_D
+  NAMES vorbisd vorbis_d vorbisD vorbis_D libvorbis_d
   PATHS $ENV{VORBISDIR}
   PATH_SUFFIXES lib
 )
 FIND_LIBRARY(VORBISFILE_LIBRARY_OPTIMIZED
-  NAMES vorbisfile
+  NAMES vorbisfile vorbisfile-3 libvorbisfile
   PATHS $ENV{VORBISDIR}
   PATH_SUFFIXES lib
 )
 FIND_LIBRARY(VORBISFILE_LIBRARY_DEBUG
-  NAMES vorbisfiled vorbisfile_d vorbisfileD vorbisfile_D
+  NAMES vorbisfiled vorbisfile_d vorbisfileD vorbisfile_D libvorbisfile_d
   PATHS $ENV{VORBISDIR}
   PATH_SUFFIXES lib
Index: code/trunk/cmake/tools/GenerateToluaBindings.cmake
===================================================================
--- code/trunk/cmake/tools/GenerateToluaBindings.cmake	(revision 8264)
+++ code/trunk/cmake/tools/GenerateToluaBindings.cmake	(revision 8351)
@@ -32,4 +32,14 @@
  #    RUNTIME_LIBRARY_DIRECTORY - Working directory
  #
+
+# Workaround for XCode: The folder where the bind files are written to has
+# to be present beforehand.
+# We have to do this here because the header files are all stored in a single
+# location per configuration.
+IF(CMAKE_CONFIGURATION_TYPES)
+  FOREACH(_dir ${CMAKE_CONFIGURATION_TYPES})
+    FILE(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/src/toluabind/${_dir}")
+  ENDFOREACH(_dir)
+ENDIF()
 
 FUNCTION(GENERATE_TOLUA_BINDINGS _tolua_package _target_source_files)
Index: code/trunk/cmake/tools/TargetUtilities.cmake
===================================================================
--- code/trunk/cmake/tools/TargetUtilities.cmake	(revision 8264)
+++ code/trunk/cmake/tools/TargetUtilities.cmake	(revision 8351)
@@ -43,4 +43,8 @@
  #    Lists:
  #      LINK_LIBRARIES:    Redirects to TARGET_LINK_LIBRARIES
+ #      LINK_LIBS_LINUX:   Redirects to TARGET_LINK_LIBRARIES only on Linux
+ #      LINK_LIBS_WIN32:   Redirects to TARGET_LINK_LIBRARIES only on Windows
+ #      LINK_LIBS_APPLE:   Redirects to TARGET_LINK_LIBRARIES only on Apple
+ #      LINK_LIBS_UNIX:    Redirects to TARGET_LINK_LIBRARIES only on UNIX
  #      VERSION:           Set version to the binary
  #      SOURCE_FILES:      Source files for the target
@@ -53,5 +57,5 @@
  #    This function also installs the target!
  #  Prerequisistes:
- #    ORXONOX_DEFAULT_LINK, ORXONOX_CONFIG_FILES
+ #    ORXONOX_DEFAULT_LINK
  #  Parameters:
  #    _target_name, ARGN for the macro arguments
@@ -86,5 +90,6 @@
   SET(_list_names LINK_LIBRARIES     VERSION           SOURCE_FILES
                   DEFINE_SYMBOL      TOLUA_FILES       PCH_FILE
-                  PCH_EXCLUDE        OUTPUT_NAME)
+                  PCH_EXCLUDE        OUTPUT_NAME       LINK_LIBS_LINUX
+                  LINK_LIBS_WIN32    LINK_LIBS_APPLE   LINK_LIBS_UNIX)
 
   PARSE_MACRO_ARGUMENTS("${_switches}" "${_list_names}" ${ARGN})
@@ -104,8 +109,8 @@
         MESSAGE(FATAL_ERROR "No name provided for source file compilation")
       ENDIF()
-      IF(NOT _compilation_include_string)
-        MESSAGE(STATUS "Warning: Empty source file compilation!")
-      ENDIF()
       IF(NOT DISABLE_COMPILATIONS)
+        IF(NOT _compilation_include_string)
+          MESSAGE(STATUS "Warning: Empty source file compilation!")
+        ENDIF()
         IF(EXISTS ${_compilation_file})
           FILE(READ ${_compilation_file} _include_string_file)
@@ -169,4 +174,11 @@
     GENERATE_TOLUA_BINDINGS(${_target_name_capitalised} _${_target_name}_files
                             INPUTFILES ${_arg_TOLUA_FILES})
+    # Workaround for XCode: The folder where the bind files are written to has
+    # to be present beforehand.
+    IF(CMAKE_CONFIGURATION_TYPES)
+      FOREACH(_dir ${CMAKE_CONFIGURATION_TYPES})
+        FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_dir})
+      ENDFOREACH(_dir)
+    ENDIF()
   ENDIF()
 
@@ -192,11 +204,11 @@
 
     IF(NOT _arg_ORXONOX_EXTERNAL)
-      # Move the prereqs.h file to the config section
+      # Move the ...Prereqs.h and the PCH files to the 'Config' section
       IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_target_name_capitalised}Prereqs.h)
         SOURCE_GROUP("Config" FILES ${_target_name_capitalised}Prereqs.h)
       ENDIF()
-      # Add config files to the config section
-      LIST(APPEND _${_target_name}_files ${ORXONOX_CONFIG_FILES})
-      SOURCE_GROUP("Config" FILES ${ORXONOX_CONFIG_FILES})
+      IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_arg_PCH_FILE})
+        SOURCE_GROUP("Config" FILES ${CMAKE_CURRENT_SOURCE_DIR}/${_arg_PCH_FILE})
+      ENDIF()
     ENDIF()
   ENDIF()
@@ -217,10 +229,11 @@
   IF(_arg_ORXONOX_EXTERNAL)
     REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC)
-    ADD_COMPILER_FLAGS("-w")
+    ADD_COMPILER_FLAGS("-w" NOT MSVC)
+    ADD_COMPILER_FLAGS("-W0" MSVC)
   ENDIF()
 
   # Don't compile header files
   FOREACH(_file ${_${_target_name}_files})
-    IF(NOT _file MATCHES "\\.(c|cc|cpp|cxx)$")
+    IF(NOT _file MATCHES "\\.(c|cc|cpp|cxx|mm)$")
       SET_SOURCE_FILES_PROPERTIES(${_file} PROPERTIES HEADER_FILE_ONLY TRUE)
     ENDIF()
@@ -278,4 +291,28 @@
     TARGET_LINK_LIBRARIES(${_target_name} ${_arg_LINK_LIBRARIES})
   ENDIF()
+  IF(_arg_LINK_LIBS_LINUX AND LINUX)
+    TARGET_LINK_LIBRARIES(${_target_name} ${_arg_LINK_LIBS_LINUX})
+  ENDIF()
+  IF(_arg_LINK_LIBS_WIN32 AND WIN32)
+    TARGET_LINK_LIBRARIES(${_target_name} ${_arg_LINK_LIBS_WIN32})
+  ENDIF()
+  IF(_arg_LINK_LIBS_APPLE AND APPLE)
+    TARGET_LINK_LIBRARIES(${_target_name} ${_arg_LINK_LIBS_APPLE})
+  ENDIF()
+  IF(_arg_LINK_LIBS_UNIX AND UNIX)
+    TARGET_LINK_LIBRARIES(${_target_name} ${_arg_LINK_LIBS_UNIX})
+  ENDIF()
+
+  # RPATH settings for the installation
+  IF("${_target_type}" STREQUAL "LIBRARY")
+    IF(_arg_MODULE)
+      SET(_rpath "${MODULE_RPATH}")
+    ELSE()
+      SET(_rpath "${LIBRARY_RPATH}")
+    ENDIF()
+  ELSE()
+    SET(_rpath "${RUNTIME_RPATH}")
+  ENDIF()
+  SET_TARGET_PROPERTIES(${_target_name} PROPERTIES INSTALL_RPATH "${_rpath}")
 
   # DEFINE_SYMBOL
