[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: |
---|
| 23 | # Function that checks each OGRE plugin for existance. Also looks for debug |
---|
| 24 | # versions and sets them accordingly. |
---|
| 25 | # All the plugins specified as function arguments have to be found or the |
---|
| 26 | # script will issue a fatal error. Additionally, all release plugins have |
---|
| 27 | # to be found in the same folder. Analogously for debug plugins. |
---|
| 28 | # Output: |
---|
| 29 | # OGRE_PLUGINS_FOLDER_DEBUG Folder with the debug plugins |
---|
| 30 | # OGRE_PLUGINS_FOLDER_RELEASE Folder with the release plugins |
---|
| 31 | # OGRE_PLUGINS_DEBUG Names of the debug plugins without extension |
---|
| 32 | # OGRE_PLUGINS_RELEASE Names of the release plugins without ext. |
---|
| 33 | # |
---|
[2618] | 34 | |
---|
| 35 | FUNCTION(CHECK_OGRE_PLUGINS) |
---|
| 36 | |
---|
| 37 | SET(OGRE_PLUGINS ${ARGN}) |
---|
| 38 | |
---|
| 39 | IF(WIN32) |
---|
[2585] | 40 | # On Windows we need only *.dll, not *.lib. Especially the MSVC generator doesn't look for *.dll |
---|
| 41 | SET(CMAKE_FIND_LIBRARY_SUFFIXES .dll) |
---|
[2618] | 42 | ENDIF(WIN32) |
---|
| 43 | # Do not prefix "lib" on any platform |
---|
| 44 | SET(CMAKE_FIND_LIBRARY_PREFIXES "") |
---|
[2586] | 45 | |
---|
[2618] | 46 | SET(OGRE_RENDER_SYSTEM_FOUND FALSE) |
---|
| 47 | FOREACH(_plugin ${OGRE_PLUGINS}) |
---|
[2585] | 48 | FIND_LIBRARY(OGRE_PLUGIN_${_plugin}_OPTIMIZED |
---|
[2618] | 49 | NAMES ${_plugin} |
---|
| 50 | PATHS $ENV{OGRE_HOME} $ENV{OGRE_PLUGIN_DIR} |
---|
[2628] | 51 | PATH_SUFFIXES bin/Release bin/release Release release lib lib/OGRE bin |
---|
[2585] | 52 | ) |
---|
| 53 | FIND_LIBRARY(OGRE_PLUGIN_${_plugin}_DEBUG |
---|
[2628] | 54 | NAMES ${_plugin}d ${_plugin}_d ${_plugin} |
---|
[2618] | 55 | PATHS $ENV{OGRE_HOME} $ENV{OGRE_PLUGIN_DIR} |
---|
[2628] | 56 | PATH_SUFFIXES bin/Debug bin/debug Debug debug lib lib/OGRE bin |
---|
[2585] | 57 | ) |
---|
[2618] | 58 | # We only need at least one render system. Check at the end. |
---|
[2585] | 59 | IF(NOT ${_plugin} MATCHES "RenderSystem") |
---|
[2618] | 60 | IF(NOT OGRE_PLUGIN_${_plugin}_OPTIMIZED) |
---|
| 61 | MESSAGE(FATAL_ERROR "Could not find OGRE plugin named ${_plugin}") |
---|
[2624] | 62 | ENDIF() |
---|
[2586] | 63 | ELSEIF(OGRE_PLUGIN_${_plugin}_OPTIMIZED) |
---|
[2585] | 64 | SET(OGRE_RENDER_SYSTEM_FOUND TRUE) |
---|
[2624] | 65 | ENDIF() |
---|
[2585] | 66 | |
---|
[2586] | 67 | IF(OGRE_PLUGIN_${_plugin}_OPTIMIZED) |
---|
[2618] | 68 | # If debug version is not available, release will do as well |
---|
[2628] | 69 | IF(OGRE_PLUGIN_${_plugin}_DEBUG STREQUAL OGRE_PLUGIN_${_plugin}_OPTIMIZED) |
---|
| 70 | # In this case the library finder didn't find real debug versions |
---|
| 71 | SET(OGRE_PLUGIN_${_plugin}_DEBUG "OGRE_PLUGIN_${_plugin}_DEBUG-NOTFOUND" CACHE STRING "" FORCE) |
---|
[2624] | 72 | ENDIF() |
---|
[2618] | 73 | MARK_AS_ADVANCED(OGRE_PLUGIN_${_plugin}_OPTIMIZED OGRE_PLUGIN_${_plugin}_DEBUG) |
---|
[2585] | 74 | |
---|
[2618] | 75 | ### Set variables to configure orxonox.ini correctly afterwards in bin/ ### |
---|
| 76 | # Check and set the folders |
---|
[2628] | 77 | GET_FILENAME_COMPONENT(_plugins_folder ${OGRE_PLUGIN_${_plugin}_OPTIMIZED} PATH) |
---|
| 78 | IF(OGRE_PLUGINS_FOLDER_RELEASE AND NOT OGRE_PLUGINS_FOLDER_RELEASE STREQUAL _plugins_folder) |
---|
[2618] | 79 | MESSAGE(FATAL_ERROR "Ogre release plugins have to be in the same folder!") |
---|
[2624] | 80 | ENDIF() |
---|
[2628] | 81 | SET(OGRE_PLUGINS_FOLDER_RELEASE ${_plugins_folder}) |
---|
| 82 | IF(OGRE_PLUGIN_${_plugin}_DEBUG) |
---|
| 83 | GET_FILENAME_COMPONENT(_plugins_folder ${OGRE_PLUGIN_${_plugin}_DEBUG} PATH) |
---|
| 84 | ENDIF() |
---|
| 85 | IF(OGRE_PLUGINS_FOLDER_DEBUG AND NOT OGRE_PLUGINS_FOLDER_DEBUG STREQUAL _plugins_folder) |
---|
[2618] | 86 | MESSAGE(FATAL_ERROR "Ogre debug plugins have to be in the same folder!") |
---|
[2624] | 87 | ENDIF() |
---|
[2628] | 88 | SET(OGRE_PLUGINS_FOLDER_DEBUG ${_plugins_folder}) |
---|
[2585] | 89 | |
---|
[2628] | 90 | # Create a list with the plugins for release and debug configurations |
---|
[2618] | 91 | LIST(APPEND OGRE_PLUGINS_RELEASE ${_plugin}) |
---|
[2628] | 92 | # Determine debug postfix ("d" or "_d" or none) |
---|
| 93 | IF(OGRE_PLUGIN_${_plugin}_DEBUG MATCHES "_d\\.|_d$") |
---|
| 94 | LIST(APPEND OGRE_PLUGINS_DEBUG "${_plugin}_d") |
---|
| 95 | ELSEIF(OGRE_PLUGIN_${_plugin}_DEBUG MATCHES "d\\.|d$") |
---|
| 96 | LIST(APPEND OGRE_PLUGINS_DEBUG "${_plugin}d") |
---|
[2624] | 97 | ELSE() |
---|
[2628] | 98 | LIST(APPEND OGRE_PLUGINS_DEBUG "${_plugin}") |
---|
[2624] | 99 | ENDIF() |
---|
[2586] | 100 | ENDIF(OGRE_PLUGIN_${_plugin}_OPTIMIZED) |
---|
[2618] | 101 | ENDFOREACH(_plugin) |
---|
| 102 | IF(NOT OGRE_RENDER_SYSTEM_FOUND) |
---|
| 103 | MESSAGE(FATAL_ERROR "Could not find an OGRE render system plugin") |
---|
[2624] | 104 | ENDIF() |
---|
[2585] | 105 | |
---|
[2618] | 106 | # List has to be comma separated for orxonox.ini |
---|
| 107 | STRING(REPLACE ";" ", " OGRE_PLUGINS_RELEASE "${OGRE_PLUGINS_RELEASE}") |
---|
| 108 | STRING(REPLACE ";" ", " OGRE_PLUGINS_DEBUG "${OGRE_PLUGINS_DEBUG}") |
---|
| 109 | |
---|
| 110 | # Set variables outside function scope |
---|
| 111 | SET(OGRE_PLUGINS_FOLDER_DEBUG ${OGRE_PLUGINS_FOLDER_DEBUG} PARENT_SCOPE) |
---|
| 112 | SET(OGRE_PLUGINS_FOLDER_RELEASE ${OGRE_PLUGINS_FOLDER_RELEASE} PARENT_SCOPE) |
---|
| 113 | SET(OGRE_PLUGINS_RELEASE ${OGRE_PLUGINS_RELEASE} PARENT_SCOPE) |
---|
| 114 | SET(OGRE_PLUGINS_DEBUG ${OGRE_PLUGINS_DEBUG} PARENT_SCOPE) |
---|
| 115 | |
---|
| 116 | ENDFUNCTION(CHECK_OGRE_PLUGINS) |
---|