Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation3/cmake/tools/CheckOGREPlugins.cmake @ 7139

Last change on this file since 7139 was 7139, checked in by rgrieder, 14 years ago

Moved non-config CMake files from cmake to cmake/tools.
That should make it easier to keep actual configuration files apart from helper files.

  • Property svn:eol-style set to native
File size: 5.4 KB
Line 
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 #  Note:
34 #    You must not specify render systems as input. That will be taken care of
35 #    automatically.
36 #
37
38FUNCTION(CHECK_OGRE_PLUGINS)
39
40  SET(OGRE_PLUGINS ${ARGN})
41
42  IF(WIN32)
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)
45  ENDIF(WIN32)
46  # Do not prefix "lib" on any platform
47  SET(CMAKE_FIND_LIBRARY_PREFIXES "")
48
49  SET(OGRE_RENDER_SYSTEMS RenderSystem_GL RenderSystem_Direct3D9)
50  SET(OGRE_RENDER_SYSTEM_FOUND FALSE)
51  FOREACH(_plugin ${OGRE_PLUGINS} ${OGRE_RENDER_SYSTEMS})
52    FIND_LIBRARY(OGRE_PLUGIN_${_plugin}_OPTIMIZED
53      NAMES ${_plugin}
54      PATHS $ENV{OGRE_HOME} $ENV{OGRE_PLUGIN_DIR}
55      PATH_SUFFIXES bin/Release bin/release Release release lib lib/OGRE bin
56    )
57    FIND_LIBRARY(OGRE_PLUGIN_${_plugin}_DEBUG
58      NAMES ${_plugin}d ${_plugin}_d ${_plugin}
59      PATHS $ENV{OGRE_HOME} $ENV{OGRE_PLUGIN_DIR}
60      PATH_SUFFIXES bin/Debug bin/debug Debug debug lib lib/OGRE bin
61    )
62    # We only need at least one render system. Check at the end.
63    IF(NOT ${_plugin} MATCHES "RenderSystem")
64      IF(NOT OGRE_PLUGIN_${_plugin}_OPTIMIZED)
65        MESSAGE(FATAL_ERROR "Could not find OGRE plugin named ${_plugin}")
66      ENDIF()
67    ELSEIF(OGRE_PLUGIN_${_plugin}_OPTIMIZED)
68      SET(OGRE_RENDER_SYSTEM_FOUND TRUE)
69    ENDIF()
70
71    IF(OGRE_PLUGIN_${_plugin}_OPTIMIZED)
72      # If debug version is not available, release will do as well
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)
76      ENDIF()
77      MARK_AS_ADVANCED(OGRE_PLUGIN_${_plugin}_OPTIMIZED OGRE_PLUGIN_${_plugin}_DEBUG)
78
79      ### Set variables to configure orxonox.ini correctly afterwards in bin/ ###
80      # Check and set the folders
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)
83        MESSAGE(FATAL_ERROR "Ogre release plugins have to be in the same folder!")
84      ENDIF()
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)
90        MESSAGE(FATAL_ERROR "Ogre debug plugins have to be in the same folder!")
91      ENDIF()
92      SET(OGRE_PLUGINS_FOLDER_DEBUG ${_plugins_folder})
93
94      # Create a list with the plugins for release and debug configurations
95      LIST(APPEND OGRE_PLUGINS_RELEASE ${_plugin})
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")
101      ELSE()
102        LIST(APPEND OGRE_PLUGINS_DEBUG "${_plugin}")
103      ENDIF()
104    ENDIF(OGRE_PLUGIN_${_plugin}_OPTIMIZED)
105  ENDFOREACH(_plugin)
106  IF(NOT OGRE_RENDER_SYSTEM_FOUND)
107      MESSAGE(FATAL_ERROR "Could not find an OGRE render system plugin")
108  ENDIF()
109
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.