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 | |
---|
35 | FUNCTION(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 lib lib/OGRE bin bin/Release bin/release Release release |
---|
52 | ) |
---|
53 | FIND_LIBRARY(OGRE_PLUGIN_${_plugin}_DEBUG |
---|
54 | NAMES ${_plugin}d ${_plugin}_d |
---|
55 | PATHS $ENV{OGRE_HOME} $ENV{OGRE_PLUGIN_DIR} |
---|
56 | PATH_SUFFIXES lib lib/OGRE bin bin/Debug bin/debug Debug debug |
---|
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(NOT OGRE_PLUGIN_${_plugin}_DEBUG) |
---|
70 | SET(OGRE_PLUGIN_${_plugin}_DEBUG ${OGRE_PLUGIN_${_plugin}_OPTIMIZED} CACHE STRING "" FORCE) |
---|
71 | ENDIF() |
---|
72 | MARK_AS_ADVANCED(OGRE_PLUGIN_${_plugin}_OPTIMIZED OGRE_PLUGIN_${_plugin}_DEBUG) |
---|
73 | |
---|
74 | ### Set variables to configure orxonox.ini correctly afterwards in bin/ ### |
---|
75 | # Check and set the folders |
---|
76 | GET_FILENAME_COMPONENT(_release_folder ${OGRE_PLUGIN_${_plugin}_OPTIMIZED} PATH) |
---|
77 | IF(OGRE_PLUGINS_FOLDER_RELEASE AND NOT OGRE_PLUGINS_FOLDER_RELEASE STREQUAL _release_folder) |
---|
78 | MESSAGE(FATAL_ERROR "Ogre release plugins have to be in the same folder!") |
---|
79 | ENDIF() |
---|
80 | SET(OGRE_PLUGINS_FOLDER_RELEASE ${_release_folder}) |
---|
81 | GET_FILENAME_COMPONENT(_debug_folder ${OGRE_PLUGIN_${_plugin}_DEBUG} PATH) |
---|
82 | IF(OGRE_PLUGINS_FOLDER_DEBUG AND NOT OGRE_PLUGINS_FOLDER_DEBUG STREQUAL _debug_folder) |
---|
83 | MESSAGE(FATAL_ERROR "Ogre debug plugins have to be in the same folder!") |
---|
84 | ENDIF() |
---|
85 | SET(OGRE_PLUGINS_FOLDER_DEBUG ${_debug_folder}) |
---|
86 | |
---|
87 | # Create a list with the plugins for relase and debug configurations |
---|
88 | LIST(APPEND OGRE_PLUGINS_RELEASE ${_plugin}) |
---|
89 | IF(OGRE_PLUGIN_${_plugin}_DEBUG) |
---|
90 | # Determine debug postfix ("d" or "_d") |
---|
91 | IF(OGRE_PLUGIN_${_plugin}_DEBUG MATCHES "_d\\.|_d$") |
---|
92 | LIST(APPEND OGRE_PLUGINS_DEBUG "${_plugin}_d") |
---|
93 | ELSE() |
---|
94 | LIST(APPEND OGRE_PLUGINS_DEBUG "${_plugin}d") |
---|
95 | ENDIF() |
---|
96 | ELSE() |
---|
97 | LIST(APPEND OGRE_PLUGINS_DEBUG ${_plugin}) |
---|
98 | ENDIF() |
---|
99 | ENDIF(OGRE_PLUGIN_${_plugin}_OPTIMIZED) |
---|
100 | ENDFOREACH(_plugin) |
---|
101 | IF(NOT OGRE_RENDER_SYSTEM_FOUND) |
---|
102 | MESSAGE(FATAL_ERROR "Could not find an OGRE render system plugin") |
---|
103 | ENDIF() |
---|
104 | |
---|
105 | # List has to be comma separated for orxonox.ini |
---|
106 | STRING(REPLACE ";" ", " OGRE_PLUGINS_RELEASE "${OGRE_PLUGINS_RELEASE}") |
---|
107 | STRING(REPLACE ";" ", " OGRE_PLUGINS_DEBUG "${OGRE_PLUGINS_DEBUG}") |
---|
108 | |
---|
109 | # Set variables outside function scope |
---|
110 | SET(OGRE_PLUGINS_FOLDER_DEBUG ${OGRE_PLUGINS_FOLDER_DEBUG} PARENT_SCOPE) |
---|
111 | SET(OGRE_PLUGINS_FOLDER_RELEASE ${OGRE_PLUGINS_FOLDER_RELEASE} PARENT_SCOPE) |
---|
112 | SET(OGRE_PLUGINS_RELEASE ${OGRE_PLUGINS_RELEASE} PARENT_SCOPE) |
---|
113 | SET(OGRE_PLUGINS_DEBUG ${OGRE_PLUGINS_DEBUG} PARENT_SCOPE) |
---|
114 | |
---|
115 | ENDFUNCTION(CHECK_OGRE_PLUGINS) |
---|