Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/buildsystem2/cmake/CheckOGREPlugins.cmake @ 2648

Last change on this file since 2648 was 2628, checked in by rgrieder, 16 years ago

Small fixes:

  • CheckOGREPlugins wasn't handling debug libraries correctly
  • OpenAL was missig the "Found OpenAL" message
  • changed all find scripts to show the library in the output instead of the include directory
  • Run script gets overridden by force
  • Also copy run script to the bin folder
  • Property svn:eol-style set to native
File size: 5.2 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 #
34
35FUNCTION(CHECK_OGRE_PLUGINS)
36
37  SET(OGRE_PLUGINS ${ARGN})
38
39  IF(WIN32)
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)
42  ENDIF(WIN32)
43  # Do not prefix "lib" on any platform
44  SET(CMAKE_FIND_LIBRARY_PREFIXES "")
45
46  SET(OGRE_RENDER_SYSTEM_FOUND FALSE)
47  FOREACH(_plugin ${OGRE_PLUGINS})
48    FIND_LIBRARY(OGRE_PLUGIN_${_plugin}_OPTIMIZED
49      NAMES ${_plugin}
50      PATHS $ENV{OGRE_HOME} $ENV{OGRE_PLUGIN_DIR}
51      PATH_SUFFIXES bin/Release bin/release Release release lib lib/OGRE bin
52    )
53    FIND_LIBRARY(OGRE_PLUGIN_${_plugin}_DEBUG
54      NAMES ${_plugin}d ${_plugin}_d ${_plugin}
55      PATHS $ENV{OGRE_HOME} $ENV{OGRE_PLUGIN_DIR}
56      PATH_SUFFIXES bin/Debug bin/debug Debug debug lib lib/OGRE bin
57    )
58    # We only need at least one render system. Check at the end.
59    IF(NOT ${_plugin} MATCHES "RenderSystem")
60      IF(NOT OGRE_PLUGIN_${_plugin}_OPTIMIZED)
61        MESSAGE(FATAL_ERROR "Could not find OGRE plugin named ${_plugin}")
62      ENDIF()
63    ELSEIF(OGRE_PLUGIN_${_plugin}_OPTIMIZED)
64      SET(OGRE_RENDER_SYSTEM_FOUND TRUE)
65    ENDIF()
66
67    IF(OGRE_PLUGIN_${_plugin}_OPTIMIZED)
68      # If debug version is not available, release will do as well
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)
72      ENDIF()
73      MARK_AS_ADVANCED(OGRE_PLUGIN_${_plugin}_OPTIMIZED OGRE_PLUGIN_${_plugin}_DEBUG)
74
75      ### Set variables to configure orxonox.ini correctly afterwards in bin/ ###
76      # Check and set the folders
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)
79        MESSAGE(FATAL_ERROR "Ogre release plugins have to be in the same folder!")
80      ENDIF()
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)
86        MESSAGE(FATAL_ERROR "Ogre debug plugins have to be in the same folder!")
87      ENDIF()
88      SET(OGRE_PLUGINS_FOLDER_DEBUG ${_plugins_folder})
89
90      # Create a list with the plugins for release and debug configurations
91      LIST(APPEND OGRE_PLUGINS_RELEASE ${_plugin})
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")
97      ELSE()
98        LIST(APPEND OGRE_PLUGINS_DEBUG "${_plugin}")
99      ENDIF()
100    ENDIF(OGRE_PLUGIN_${_plugin}_OPTIMIZED)
101  ENDFOREACH(_plugin)
102  IF(NOT OGRE_RENDER_SYSTEM_FOUND)
103      MESSAGE(FATAL_ERROR "Could not find an OGRE render system plugin")
104  ENDIF()
105
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
116ENDFUNCTION(CHECK_OGRE_PLUGINS)
Note: See TracBrowser for help on using the repository browser.