Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/cmake/CheckOGREPlugins.cmake @ 6896

Last change on this file since 6896 was 5781, checked in by rgrieder, 15 years ago

Reverted trunk again. We might want to find a way to delete these revisions again (x3n's changes are still available as diff in the commit mails).

  • Property svn:eol-style set to native
File size: 5.4 KB
RevLine 
[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.
[2673]33 #  Note:
[5695]34 #    You must not specify render systems as input. That will be taken care of
35 #    automatically.
[2626]36 #
[2618]37
38FUNCTION(CHECK_OGRE_PLUGINS)
39
40  SET(OGRE_PLUGINS ${ARGN})
41
42  IF(WIN32)
[2585]43    # On Windows we need only *.dll, not *.lib. Especially the MSVC generator doesn't look for *.dll
44    SET(CMAKE_FIND_LIBRARY_SUFFIXES .dll)
[2618]45  ENDIF(WIN32)
46  # Do not prefix "lib" on any platform
47  SET(CMAKE_FIND_LIBRARY_PREFIXES "")
[2586]48
[2673]49  SET(OGRE_RENDER_SYSTEMS RenderSystem_GL RenderSystem_Direct3D9)
[2618]50  SET(OGRE_RENDER_SYSTEM_FOUND FALSE)
[2673]51  FOREACH(_plugin ${OGRE_PLUGINS} ${OGRE_RENDER_SYSTEMS})
[2585]52    FIND_LIBRARY(OGRE_PLUGIN_${_plugin}_OPTIMIZED
[2618]53      NAMES ${_plugin}
54      PATHS $ENV{OGRE_HOME} $ENV{OGRE_PLUGIN_DIR}
[2628]55      PATH_SUFFIXES bin/Release bin/release Release release lib lib/OGRE bin
[2585]56    )
57    FIND_LIBRARY(OGRE_PLUGIN_${_plugin}_DEBUG
[2628]58      NAMES ${_plugin}d ${_plugin}_d ${_plugin}
[2618]59      PATHS $ENV{OGRE_HOME} $ENV{OGRE_PLUGIN_DIR}
[2628]60      PATH_SUFFIXES bin/Debug bin/debug Debug debug lib lib/OGRE bin
[2585]61    )
[2618]62    # We only need at least one render system. Check at the end.
[2585]63    IF(NOT ${_plugin} MATCHES "RenderSystem")
[2618]64      IF(NOT OGRE_PLUGIN_${_plugin}_OPTIMIZED)
65        MESSAGE(FATAL_ERROR "Could not find OGRE plugin named ${_plugin}")
[2624]66      ENDIF()
[2586]67    ELSEIF(OGRE_PLUGIN_${_plugin}_OPTIMIZED)
[2585]68      SET(OGRE_RENDER_SYSTEM_FOUND TRUE)
[2624]69    ENDIF()
[2585]70
[2586]71    IF(OGRE_PLUGIN_${_plugin}_OPTIMIZED)
[2618]72      # If debug version is not available, release will do as well
[2628]73      IF(OGRE_PLUGIN_${_plugin}_DEBUG STREQUAL OGRE_PLUGIN_${_plugin}_OPTIMIZED)
74        # In this case the library finder didn't find real debug versions
75        SET(OGRE_PLUGIN_${_plugin}_DEBUG "OGRE_PLUGIN_${_plugin}_DEBUG-NOTFOUND" CACHE STRING "" FORCE)
[2624]76      ENDIF()
[2618]77      MARK_AS_ADVANCED(OGRE_PLUGIN_${_plugin}_OPTIMIZED OGRE_PLUGIN_${_plugin}_DEBUG)
[2585]78
[2618]79      ### Set variables to configure orxonox.ini correctly afterwards in bin/ ###
80      # Check and set the folders
[2628]81      GET_FILENAME_COMPONENT(_plugins_folder ${OGRE_PLUGIN_${_plugin}_OPTIMIZED} PATH)
82      IF(OGRE_PLUGINS_FOLDER_RELEASE AND NOT OGRE_PLUGINS_FOLDER_RELEASE STREQUAL _plugins_folder)
[2618]83        MESSAGE(FATAL_ERROR "Ogre release plugins have to be in the same folder!")
[2624]84      ENDIF()
[2628]85      SET(OGRE_PLUGINS_FOLDER_RELEASE ${_plugins_folder})
86      IF(OGRE_PLUGIN_${_plugin}_DEBUG)
87        GET_FILENAME_COMPONENT(_plugins_folder ${OGRE_PLUGIN_${_plugin}_DEBUG} PATH)
88      ENDIF()
89      IF(OGRE_PLUGINS_FOLDER_DEBUG AND NOT OGRE_PLUGINS_FOLDER_DEBUG STREQUAL _plugins_folder)
[2618]90        MESSAGE(FATAL_ERROR "Ogre debug plugins have to be in the same folder!")
[2624]91      ENDIF()
[2628]92      SET(OGRE_PLUGINS_FOLDER_DEBUG ${_plugins_folder})
[2585]93
[2628]94      # Create a list with the plugins for release and debug configurations
[2618]95      LIST(APPEND OGRE_PLUGINS_RELEASE ${_plugin})
[2628]96      # Determine debug postfix ("d" or "_d" or none)
97      IF(OGRE_PLUGIN_${_plugin}_DEBUG MATCHES "_d\\.|_d$")
98        LIST(APPEND OGRE_PLUGINS_DEBUG "${_plugin}_d")
99      ELSEIF(OGRE_PLUGIN_${_plugin}_DEBUG MATCHES "d\\.|d$")
100        LIST(APPEND OGRE_PLUGINS_DEBUG "${_plugin}d")
[2624]101      ELSE()
[2628]102        LIST(APPEND OGRE_PLUGINS_DEBUG "${_plugin}")
[2624]103      ENDIF()
[2586]104    ENDIF(OGRE_PLUGIN_${_plugin}_OPTIMIZED)
[2618]105  ENDFOREACH(_plugin)
106  IF(NOT OGRE_RENDER_SYSTEM_FOUND)
107      MESSAGE(FATAL_ERROR "Could not find an OGRE render system plugin")
[2624]108  ENDIF()
[2585]109
[2618]110  # List has to be comma separated for orxonox.ini
111  STRING(REPLACE ";" ", " OGRE_PLUGINS_RELEASE "${OGRE_PLUGINS_RELEASE}")
112  STRING(REPLACE ";" ", " OGRE_PLUGINS_DEBUG   "${OGRE_PLUGINS_DEBUG}")
113
114  # Set variables outside function scope
115  SET(OGRE_PLUGINS_FOLDER_DEBUG ${OGRE_PLUGINS_FOLDER_DEBUG} PARENT_SCOPE)
116  SET(OGRE_PLUGINS_FOLDER_RELEASE ${OGRE_PLUGINS_FOLDER_RELEASE} PARENT_SCOPE)
117  SET(OGRE_PLUGINS_RELEASE ${OGRE_PLUGINS_RELEASE} PARENT_SCOPE)
118  SET(OGRE_PLUGINS_DEBUG ${OGRE_PLUGINS_DEBUG} PARENT_SCOPE)
119
120ENDFUNCTION(CHECK_OGRE_PLUGINS)
Note: See TracBrowser for help on using the repository browser.