| [2626] | 1 | # | 
|---|
|  | 2 | #             ORXONOX - the hottest 3D action shooter ever to exist | 
|---|
|  | 3 | #                             > www.orxonox.net < | 
|---|
|  | 4 | # | 
|---|
|  | 5 | #        This program is free software; you can redistribute it and/or | 
|---|
|  | 6 | #         modify it under the terms of the GNU General Public License | 
|---|
|  | 7 | #        as published by the Free Software Foundation; either version 2 | 
|---|
|  | 8 | #            of the License, or (at your option) any later version. | 
|---|
|  | 9 | # | 
|---|
|  | 10 | #       This program is distributed in the hope that it will be useful, | 
|---|
|  | 11 | #        but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
|  | 12 | #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
|  | 13 | #                 GNU General Public License for more details. | 
|---|
|  | 14 | # | 
|---|
|  | 15 | #   You should have received a copy of the GNU General Public License along | 
|---|
|  | 16 | #      with this program; if not, write to the Free Software Foundation, | 
|---|
|  | 17 | #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. | 
|---|
|  | 18 | # | 
|---|
|  | 19 | # | 
|---|
|  | 20 | #  Author: | 
|---|
|  | 21 | #    Reto Grieder | 
|---|
|  | 22 | #  Description: | 
|---|
| [8264] | 23 | #    Finds OGRE plugins and their folder, which has to be unique each set | 
|---|
|  | 24 | #    of plugins (Debug, Release). | 
|---|
|  | 25 | #    Specify arguments as strings: mandatory and optional plugins. | 
|---|
|  | 26 | #    Input: | 
|---|
|  | 27 | #      _mandatory_plugins Have to be found, error issued otherwise | 
|---|
|  | 28 | #      _optional_plugins  Added as well if found | 
|---|
| [2626] | 29 | #    Output: | 
|---|
| [8264] | 30 | #      OGRE_PLUGINS_FOLDER_DEBUG   Folder with the debug plugins | 
|---|
|  | 31 | #      OGRE_PLUGINS_FOLDER_RELEASE Folder with the release plugins | 
|---|
|  | 32 | #      OGRE_PLUGINS_DEBUG          Names of the debug plugins without extension | 
|---|
|  | 33 | #      OGRE_PLUGINS_RELEASE        Names of the release plugins without ext. | 
|---|
| [2673] | 34 | #  Note: | 
|---|
| [5695] | 35 | #    You must not specify render systems as input. That will be taken care of | 
|---|
|  | 36 | #    automatically. | 
|---|
| [2626] | 37 | # | 
|---|
| [2618] | 38 |  | 
|---|
| [8264] | 39 | FUNCTION(CHECK_OGRE_PLUGINS _mandatory_plugins _optional_plugins) | 
|---|
| [2618] | 40 |  | 
|---|
|  | 41 | IF(WIN32) | 
|---|
| [2585] | 42 | # On Windows we need only *.dll, not *.lib. Especially the MSVC generator doesn't look for *.dll | 
|---|
|  | 43 | SET(CMAKE_FIND_LIBRARY_SUFFIXES .dll) | 
|---|
| [2618] | 44 | ENDIF(WIN32) | 
|---|
|  | 45 | # Do not prefix "lib" on any platform | 
|---|
|  | 46 | SET(CMAKE_FIND_LIBRARY_PREFIXES "") | 
|---|
| [2586] | 47 |  | 
|---|
| [2673] | 48 | SET(OGRE_RENDER_SYSTEMS RenderSystem_GL RenderSystem_Direct3D9) | 
|---|
| [2618] | 49 | SET(OGRE_RENDER_SYSTEM_FOUND FALSE) | 
|---|
| [8264] | 50 | FOREACH(_plugin ${_mandatory_plugins} ${_optional_plugins} ${OGRE_RENDER_SYSTEMS}) | 
|---|
| [2585] | 51 | FIND_LIBRARY(OGRE_PLUGIN_${_plugin}_OPTIMIZED | 
|---|
| [2618] | 52 | NAMES ${_plugin} | 
|---|
|  | 53 | PATHS $ENV{OGRE_HOME} $ENV{OGRE_PLUGIN_DIR} | 
|---|
| [9165] | 54 | PATH_SUFFIXES bin/Release bin/release Release release lib lib/OGRE bin Ogre.framework/Resources OGRE-${OGRE_VERSION} | 
|---|
| [2585] | 55 | ) | 
|---|
|  | 56 | FIND_LIBRARY(OGRE_PLUGIN_${_plugin}_DEBUG | 
|---|
| [2628] | 57 | NAMES ${_plugin}d ${_plugin}_d ${_plugin} | 
|---|
| [2618] | 58 | PATHS $ENV{OGRE_HOME} $ENV{OGRE_PLUGIN_DIR} | 
|---|
| [9165] | 59 | PATH_SUFFIXES bin/Debug bin/debug Debug debug lib lib/OGRE bin Ogre.framework/Resources OGRE-${OGRE_VERSION} | 
|---|
| [2585] | 60 | ) | 
|---|
| [2618] | 61 | # We only need at least one render system. Check at the end. | 
|---|
| [2585] | 62 | IF(NOT ${_plugin} MATCHES "RenderSystem") | 
|---|
| [8264] | 63 | IF(${_plugin} MATCHES "${_mandatory_plugins}" AND NOT OGRE_PLUGIN_${_plugin}_OPTIMIZED) | 
|---|
| [2618] | 64 | MESSAGE(FATAL_ERROR "Could not find OGRE plugin named ${_plugin}") | 
|---|
| [2624] | 65 | ENDIF() | 
|---|
| [2586] | 66 | ELSEIF(OGRE_PLUGIN_${_plugin}_OPTIMIZED) | 
|---|
| [2585] | 67 | SET(OGRE_RENDER_SYSTEM_FOUND TRUE) | 
|---|
| [2624] | 68 | ENDIF() | 
|---|
| [2585] | 69 |  | 
|---|
| [2586] | 70 | IF(OGRE_PLUGIN_${_plugin}_OPTIMIZED) | 
|---|
| [2618] | 71 | # If debug version is not available, release will do as well | 
|---|
| [2628] | 72 | IF(OGRE_PLUGIN_${_plugin}_DEBUG STREQUAL OGRE_PLUGIN_${_plugin}_OPTIMIZED) | 
|---|
|  | 73 | # In this case the library finder didn't find real debug versions | 
|---|
|  | 74 | SET(OGRE_PLUGIN_${_plugin}_DEBUG "OGRE_PLUGIN_${_plugin}_DEBUG-NOTFOUND" CACHE STRING "" FORCE) | 
|---|
| [2624] | 75 | ENDIF() | 
|---|
| [2618] | 76 | MARK_AS_ADVANCED(OGRE_PLUGIN_${_plugin}_OPTIMIZED OGRE_PLUGIN_${_plugin}_DEBUG) | 
|---|
| [2585] | 77 |  | 
|---|
| [2618] | 78 | ### Set variables to configure orxonox.ini correctly afterwards in bin/ ### | 
|---|
|  | 79 | # Check and set the folders | 
|---|
| [2628] | 80 | GET_FILENAME_COMPONENT(_plugins_folder ${OGRE_PLUGIN_${_plugin}_OPTIMIZED} PATH) | 
|---|
|  | 81 | IF(OGRE_PLUGINS_FOLDER_RELEASE AND NOT OGRE_PLUGINS_FOLDER_RELEASE STREQUAL _plugins_folder) | 
|---|
| [2618] | 82 | MESSAGE(FATAL_ERROR "Ogre release plugins have to be in the same folder!") | 
|---|
| [2624] | 83 | ENDIF() | 
|---|
| [2628] | 84 | SET(OGRE_PLUGINS_FOLDER_RELEASE ${_plugins_folder}) | 
|---|
|  | 85 | IF(OGRE_PLUGIN_${_plugin}_DEBUG) | 
|---|
|  | 86 | GET_FILENAME_COMPONENT(_plugins_folder ${OGRE_PLUGIN_${_plugin}_DEBUG} PATH) | 
|---|
|  | 87 | ENDIF() | 
|---|
|  | 88 | IF(OGRE_PLUGINS_FOLDER_DEBUG AND NOT OGRE_PLUGINS_FOLDER_DEBUG STREQUAL _plugins_folder) | 
|---|
| [2618] | 89 | MESSAGE(FATAL_ERROR "Ogre debug plugins have to be in the same folder!") | 
|---|
| [2624] | 90 | ENDIF() | 
|---|
| [2628] | 91 | SET(OGRE_PLUGINS_FOLDER_DEBUG ${_plugins_folder}) | 
|---|
| [2585] | 92 |  | 
|---|
| [2628] | 93 | # Create a list with the plugins for release and debug configurations | 
|---|
| [2618] | 94 | LIST(APPEND OGRE_PLUGINS_RELEASE ${_plugin}) | 
|---|
| [2628] | 95 | # Determine debug postfix ("d" or "_d" or none) | 
|---|
|  | 96 | IF(OGRE_PLUGIN_${_plugin}_DEBUG MATCHES "_d\\.|_d$") | 
|---|
|  | 97 | LIST(APPEND OGRE_PLUGINS_DEBUG "${_plugin}_d") | 
|---|
|  | 98 | ELSEIF(OGRE_PLUGIN_${_plugin}_DEBUG MATCHES "d\\.|d$") | 
|---|
|  | 99 | LIST(APPEND OGRE_PLUGINS_DEBUG "${_plugin}d") | 
|---|
| [2624] | 100 | ELSE() | 
|---|
| [2628] | 101 | LIST(APPEND OGRE_PLUGINS_DEBUG "${_plugin}") | 
|---|
| [2624] | 102 | ENDIF() | 
|---|
| [2586] | 103 | ENDIF(OGRE_PLUGIN_${_plugin}_OPTIMIZED) | 
|---|
| [2618] | 104 | ENDFOREACH(_plugin) | 
|---|
|  | 105 | IF(NOT OGRE_RENDER_SYSTEM_FOUND) | 
|---|
|  | 106 | MESSAGE(FATAL_ERROR "Could not find an OGRE render system plugin") | 
|---|
| [2624] | 107 | ENDIF() | 
|---|
| [2585] | 108 |  | 
|---|
| [2618] | 109 | # List has to be comma separated for orxonox.ini | 
|---|
|  | 110 | STRING(REPLACE ";" ", " OGRE_PLUGINS_RELEASE "${OGRE_PLUGINS_RELEASE}") | 
|---|
|  | 111 | STRING(REPLACE ";" ", " OGRE_PLUGINS_DEBUG   "${OGRE_PLUGINS_DEBUG}") | 
|---|
|  | 112 |  | 
|---|
|  | 113 | # Set variables outside function scope | 
|---|
|  | 114 | SET(OGRE_PLUGINS_FOLDER_DEBUG ${OGRE_PLUGINS_FOLDER_DEBUG} PARENT_SCOPE) | 
|---|
|  | 115 | SET(OGRE_PLUGINS_FOLDER_RELEASE ${OGRE_PLUGINS_FOLDER_RELEASE} PARENT_SCOPE) | 
|---|
|  | 116 | SET(OGRE_PLUGINS_RELEASE ${OGRE_PLUGINS_RELEASE} PARENT_SCOPE) | 
|---|
|  | 117 | SET(OGRE_PLUGINS_DEBUG ${OGRE_PLUGINS_DEBUG} PARENT_SCOPE) | 
|---|
|  | 118 |  | 
|---|
|  | 119 | ENDFUNCTION(CHECK_OGRE_PLUGINS) | 
|---|