Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/cmake/tools/CheckOGREPlugins.cmake @ 11482

Last change on this file since 11482 was 9165, checked in by rgrieder, 13 years ago

Fixed OGRE plugin finding for Ubuntu precise. Untested!

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