Index: /code/branches/buildsystem2/cmake/FindOGRE.cmake
===================================================================
--- /code/branches/buildsystem2/cmake/FindOGRE.cmake	(revision 2585)
+++ /code/branches/buildsystem2/cmake/FindOGRE.cmake	(revision 2586)
@@ -51,9 +51,12 @@
     SET(CMAKE_FIND_LIBRARY_SUFFIXES .dll)
 ENDIF(WIN32)
+SET(CMAKE_FIND_LIBRARY_PREFIXES_STORED ${CMAKE_FIND_LIBRARY_PREFIXES})
+SET(CMAKE_FIND_LIBRARY_PREFIXES "")
+
 SET(OGRE_RENDER_SYSTEM_FOUND FALSE)
 FOREACH(_plugin ${OGRE_PLUGINS})
     FIND_LIBRARY(OGRE_PLUGIN_${_plugin}_OPTIMIZED
         NAMES ${_plugin}
-        PATHS $ENV{OGRE_HOME}
+        PATHS $ENV{OGRE_HOME} /usr/local /usr
         PATH_SUFFIXES lib lib/OGRE bin bin/Release bin/release Release release
     )
@@ -65,40 +68,39 @@
     # We only need at least one render system. Check at the end
     IF(NOT ${_plugin} MATCHES "RenderSystem")
-      SET(OGRE_PLUGIN_${_plugin}_FIND_REQUIRED TRUE)
-    ELSE(NOT ${_plugin} MATCHES "RenderSystem")
-      SET(OGRE_PLUGIN_${_plugin}_FIND_REQUIRED FALSE)
+        IF(NOT OGRE_PLUGIN_${_plugin}_OPTIMIZED)
+            MESSAGE(FATAL_ERROR "Could not find OGRE plugin named ${_plugin}")
+        ENDIF(NOT OGRE_PLUGIN_${_plugin}_OPTIMIZED)
+    ELSEIF(OGRE_PLUGIN_${_plugin}_OPTIMIZED)
       SET(OGRE_RENDER_SYSTEM_FOUND TRUE)
     ENDIF(NOT ${_plugin} MATCHES "RenderSystem")
-    FIND_PACKAGE_HANDLE_STANDARD_ARGS(OGRE_PLUGIN_${_plugin}
-        "Could not find OGRE plugin named ${_plugin}"
-        OGRE_PLUGIN_${_plugin}_OPTIMIZED
-    )
 
-    # If debug version is not available, release will do as well
-    IF(NOT OGRE_PLUGIN_${_plugin}_DEBUG)
-        SET(OGRE_PLUGIN_${_plugin}_DEBUG ${OGRE_PLUGIN_${_plugin}_OPTIMIZED} CACHE STRING "")
-    ENDIF(NOT OGRE_PLUGIN_${_plugin}_DEBUG)
-    MARK_AS_ADVANCED(OGRE_PLUGIN_${_plugin}_OPTIMIZED OGRE_PLUGIN_${_plugin}_DEBUG)
+    IF(OGRE_PLUGIN_${_plugin}_OPTIMIZED)
+        # If debug version is not available, release will do as well
+        IF(NOT OGRE_PLUGIN_${_plugin}_DEBUG)
+            SET(OGRE_PLUGIN_${_plugin}_DEBUG ${OGRE_PLUGIN_${_plugin}_OPTIMIZED} CACHE STRING "")
+        ENDIF(NOT OGRE_PLUGIN_${_plugin}_DEBUG)
+        MARK_AS_ADVANCED(OGRE_PLUGIN_${_plugin}_OPTIMIZED OGRE_PLUGIN_${_plugin}_DEBUG)
 
-    ### Set variables to configure orxonox.ini correctly afterwards in bin/ ###
-    # Check and set the folders
-    GET_FILENAME_COMPONENT(_release_folder ${OGRE_PLUGIN_${_plugin}_OPTIMIZED} PATH)
-    IF(OGRE_PLUGINS_FOLDER_RELEASE AND NOT OGRE_PLUGINS_FOLDER_RELEASE STREQUAL _release_folder)
-        MESSAGE(FATAL_ERROR "Ogre release plugins have to be in the same folder!")
-    ENDIF(OGRE_PLUGINS_FOLDER_RELEASE AND NOT OGRE_PLUGINS_FOLDER_RELEASE STREQUAL _release_folder)
-    SET(OGRE_PLUGINS_FOLDER_RELEASE ${_release_folder})
-    GET_FILENAME_COMPONENT(_debug_folder ${OGRE_PLUGIN_${_plugin}_DEBUG} PATH)
-    IF(OGRE_PLUGINS_FOLDER_DEBUG AND NOT OGRE_PLUGINS_FOLDER_DEBUG STREQUAL _debug_folder)
-        MESSAGE(FATAL_ERROR "Ogre debug plugins have to be in the same folder!")
-    ENDIF(OGRE_PLUGINS_FOLDER_DEBUG AND NOT OGRE_PLUGINS_FOLDER_DEBUG STREQUAL _debug_folder)
-    SET(OGRE_PLUGINS_FOLDER_DEBUG ${_debug_folder})
+        ### Set variables to configure orxonox.ini correctly afterwards in bin/ ###
+        # Check and set the folders
+        GET_FILENAME_COMPONENT(_release_folder ${OGRE_PLUGIN_${_plugin}_OPTIMIZED} PATH)
+        IF(OGRE_PLUGINS_FOLDER_RELEASE AND NOT OGRE_PLUGINS_FOLDER_RELEASE STREQUAL _release_folder)
+            MESSAGE(FATAL_ERROR "Ogre release plugins have to be in the same folder!")
+        ENDIF(OGRE_PLUGINS_FOLDER_RELEASE AND NOT OGRE_PLUGINS_FOLDER_RELEASE STREQUAL _release_folder)
+        SET(OGRE_PLUGINS_FOLDER_RELEASE ${_release_folder})
+        GET_FILENAME_COMPONENT(_debug_folder ${OGRE_PLUGIN_${_plugin}_DEBUG} PATH)
+        IF(OGRE_PLUGINS_FOLDER_DEBUG AND NOT OGRE_PLUGINS_FOLDER_DEBUG STREQUAL _debug_folder)
+            MESSAGE(FATAL_ERROR "Ogre debug plugins have to be in the same folder!")
+        ENDIF(OGRE_PLUGINS_FOLDER_DEBUG AND NOT OGRE_PLUGINS_FOLDER_DEBUG STREQUAL _debug_folder)
+        SET(OGRE_PLUGINS_FOLDER_DEBUG ${_debug_folder})
 
-    # Create a list with the plugins for relase and debug configurations
-    LIST(APPEND OGRE_PLUGINS_RELEASE ${_plugin})
-    IF(OGRE_PLUGIN_${_plugin}_DEBUG)
-        LIST(APPEND OGRE_PLUGINS_DEBUG ${_plugin}${LIBRARY_DEBUG_POSTFIX})
-    ELSE(OGRE_PLUGIN_${_plugin}_DEBUG)
-        LIST(APPEND OGRE_PLUGINS_DEBUG ${_plugin})
-    ENDIF(OGRE_PLUGIN_${_plugin}_DEBUG)
+        # Create a list with the plugins for relase and debug configurations
+        LIST(APPEND OGRE_PLUGINS_RELEASE ${_plugin})
+        IF(OGRE_PLUGIN_${_plugin}_DEBUG)
+            LIST(APPEND OGRE_PLUGINS_DEBUG ${_plugin}${LIBRARY_DEBUG_POSTFIX})
+        ELSE(OGRE_PLUGIN_${_plugin}_DEBUG)
+            LIST(APPEND OGRE_PLUGINS_DEBUG ${_plugin})
+        ENDIF(OGRE_PLUGIN_${_plugin}_DEBUG)
+    ENDIF(OGRE_PLUGIN_${_plugin}_OPTIMIZED)
 ENDFOREACH(_plugin)
 IF(NOT OGRE_RENDER_SYSTEM_FOUND)
@@ -109,4 +111,5 @@
     SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_STORED})
 ENDIF(WIN32)
+SET(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES_STORED})
 
 # List has to be comma separated for orxonox.ini
