[1505] | 1 | # Find OGRE includes and library |
---|
| 2 | # |
---|
| 3 | # This module defines |
---|
| 4 | # OGRE_INCLUDE_DIR |
---|
[2509] | 5 | # OGRE_LIBRARY, the library to link against to use OGRE. |
---|
[1505] | 6 | # OGRE_FOUND, If false, do not try to use OGRE |
---|
| 7 | # |
---|
| 8 | # Copyright © 2007, Matt Williams |
---|
| 9 | # Modified by Nicolas Schlumberger to make it work on the Tardis-Infrastucture of the ETH Zurich |
---|
| 10 | # |
---|
| 11 | # Redistribution and use is allowed according to the terms of the BSD license. |
---|
[1776] | 12 | # |
---|
| 13 | # Several changes and additions by Fabian 'x3n' Landau |
---|
[2509] | 14 | # Lots of simplifications by Adrian Friedli |
---|
[2585] | 15 | # Plugin checking by Reto Grieder |
---|
[1776] | 16 | # > www.orxonox.net < |
---|
[1505] | 17 | |
---|
[2583] | 18 | INCLUDE(FindPackageHandleStandardArgs) |
---|
| 19 | INCLUDE(HandleLibraryTypes) |
---|
| 20 | |
---|
[2509] | 21 | FIND_PATH(OGRE_INCLUDE_DIR Ogre.h |
---|
[2583] | 22 | PATHS $ENV{OGRE_HOME} /usr/local /usr |
---|
[2509] | 23 | PATH_SUFFIXES include include/OGRE |
---|
| 24 | ) |
---|
[2579] | 25 | FIND_LIBRARY(OGRE_LIBRARY_OPTIMIZED |
---|
| 26 | NAMES OgreMain |
---|
[2583] | 27 | PATHS $ENV{OGRE_HOME} /usr/local /usr |
---|
[2585] | 28 | PATH_SUFFIXES lib bin/Release bin/release Release release |
---|
[2579] | 29 | ) |
---|
| 30 | FIND_LIBRARY(OGRE_LIBRARY_DEBUG |
---|
[2583] | 31 | NAMES OgreMain${LIBRARY_DEBUG_POSTFIX} |
---|
| 32 | PATHS $ENV{OGRE_HOME} /usr/local /usr |
---|
[2585] | 33 | PATH_SUFFIXES lib bin/Debug bin/debug Debug debug |
---|
[2579] | 34 | ) |
---|
[1505] | 35 | |
---|
[2509] | 36 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(OGRE DEFAULT_MSG |
---|
[2579] | 37 | OGRE_LIBRARY_OPTIMIZED |
---|
[2509] | 38 | OGRE_INCLUDE_DIR |
---|
| 39 | ) |
---|
[1776] | 40 | |
---|
[2579] | 41 | # Set optimized and debug libraries |
---|
| 42 | HandleLibraryTypes(OGRE) |
---|
| 43 | |
---|
[2585] | 44 | ############################################### |
---|
| 45 | # Also make sure we have the required plugins # |
---|
| 46 | ############################################### |
---|
| 47 | |
---|
| 48 | IF(WIN32) |
---|
| 49 | # On Windows we need only *.dll, not *.lib. Especially the MSVC generator doesn't look for *.dll |
---|
| 50 | SET(CMAKE_FIND_LIBRARY_SUFFIXES_STORED ${CMAKE_FIND_LIBRARY_SUFFIXES}) |
---|
| 51 | SET(CMAKE_FIND_LIBRARY_SUFFIXES .dll) |
---|
| 52 | ENDIF(WIN32) |
---|
[2594] | 53 | SET(CMAKE_FIND_LIBRARY_PREFIXES_STORED "${CMAKE_FIND_LIBRARY_PREFIXES}") |
---|
[2586] | 54 | SET(CMAKE_FIND_LIBRARY_PREFIXES "") |
---|
| 55 | |
---|
[2585] | 56 | SET(OGRE_RENDER_SYSTEM_FOUND FALSE) |
---|
| 57 | FOREACH(_plugin ${OGRE_PLUGINS}) |
---|
| 58 | FIND_LIBRARY(OGRE_PLUGIN_${_plugin}_OPTIMIZED |
---|
| 59 | NAMES ${_plugin} |
---|
[2586] | 60 | PATHS $ENV{OGRE_HOME} /usr/local /usr |
---|
[2585] | 61 | PATH_SUFFIXES lib lib/OGRE bin bin/Release bin/release Release release |
---|
| 62 | ) |
---|
| 63 | FIND_LIBRARY(OGRE_PLUGIN_${_plugin}_DEBUG |
---|
| 64 | NAMES ${_plugin}${LIBRARY_DEBUG_POSTFIX} |
---|
| 65 | PATHS $ENV{OGRE_HOME} /usr/local /usr |
---|
| 66 | PATH_SUFFIXES lib lib/OGRE bin bin/Debug bin/debug Debug debug |
---|
| 67 | ) |
---|
| 68 | # We only need at least one render system. Check at the end |
---|
| 69 | IF(NOT ${_plugin} MATCHES "RenderSystem") |
---|
[2586] | 70 | IF(NOT OGRE_PLUGIN_${_plugin}_OPTIMIZED) |
---|
| 71 | MESSAGE(FATAL_ERROR "Could not find OGRE plugin named ${_plugin}") |
---|
| 72 | ENDIF(NOT OGRE_PLUGIN_${_plugin}_OPTIMIZED) |
---|
| 73 | ELSEIF(OGRE_PLUGIN_${_plugin}_OPTIMIZED) |
---|
[2585] | 74 | SET(OGRE_RENDER_SYSTEM_FOUND TRUE) |
---|
| 75 | ENDIF(NOT ${_plugin} MATCHES "RenderSystem") |
---|
| 76 | |
---|
[2586] | 77 | IF(OGRE_PLUGIN_${_plugin}_OPTIMIZED) |
---|
| 78 | # If debug version is not available, release will do as well |
---|
| 79 | IF(NOT OGRE_PLUGIN_${_plugin}_DEBUG) |
---|
[2593] | 80 | SET(OGRE_PLUGIN_${_plugin}_DEBUG ${OGRE_PLUGIN_${_plugin}_OPTIMIZED} CACHE STRING "" FORCE) |
---|
[2586] | 81 | ENDIF(NOT OGRE_PLUGIN_${_plugin}_DEBUG) |
---|
| 82 | MARK_AS_ADVANCED(OGRE_PLUGIN_${_plugin}_OPTIMIZED OGRE_PLUGIN_${_plugin}_DEBUG) |
---|
[2585] | 83 | |
---|
[2586] | 84 | ### Set variables to configure orxonox.ini correctly afterwards in bin/ ### |
---|
| 85 | # Check and set the folders |
---|
| 86 | GET_FILENAME_COMPONENT(_release_folder ${OGRE_PLUGIN_${_plugin}_OPTIMIZED} PATH) |
---|
| 87 | IF(OGRE_PLUGINS_FOLDER_RELEASE AND NOT OGRE_PLUGINS_FOLDER_RELEASE STREQUAL _release_folder) |
---|
| 88 | MESSAGE(FATAL_ERROR "Ogre release plugins have to be in the same folder!") |
---|
| 89 | ENDIF(OGRE_PLUGINS_FOLDER_RELEASE AND NOT OGRE_PLUGINS_FOLDER_RELEASE STREQUAL _release_folder) |
---|
| 90 | SET(OGRE_PLUGINS_FOLDER_RELEASE ${_release_folder}) |
---|
| 91 | GET_FILENAME_COMPONENT(_debug_folder ${OGRE_PLUGIN_${_plugin}_DEBUG} PATH) |
---|
| 92 | IF(OGRE_PLUGINS_FOLDER_DEBUG AND NOT OGRE_PLUGINS_FOLDER_DEBUG STREQUAL _debug_folder) |
---|
| 93 | MESSAGE(FATAL_ERROR "Ogre debug plugins have to be in the same folder!") |
---|
| 94 | ENDIF(OGRE_PLUGINS_FOLDER_DEBUG AND NOT OGRE_PLUGINS_FOLDER_DEBUG STREQUAL _debug_folder) |
---|
| 95 | SET(OGRE_PLUGINS_FOLDER_DEBUG ${_debug_folder}) |
---|
[2585] | 96 | |
---|
[2586] | 97 | # Create a list with the plugins for relase and debug configurations |
---|
| 98 | LIST(APPEND OGRE_PLUGINS_RELEASE ${_plugin}) |
---|
| 99 | IF(OGRE_PLUGIN_${_plugin}_DEBUG) |
---|
| 100 | LIST(APPEND OGRE_PLUGINS_DEBUG ${_plugin}${LIBRARY_DEBUG_POSTFIX}) |
---|
| 101 | ELSE(OGRE_PLUGIN_${_plugin}_DEBUG) |
---|
| 102 | LIST(APPEND OGRE_PLUGINS_DEBUG ${_plugin}) |
---|
| 103 | ENDIF(OGRE_PLUGIN_${_plugin}_DEBUG) |
---|
| 104 | ENDIF(OGRE_PLUGIN_${_plugin}_OPTIMIZED) |
---|
[2585] | 105 | ENDFOREACH(_plugin) |
---|
| 106 | IF(NOT OGRE_RENDER_SYSTEM_FOUND) |
---|
| 107 | MESSAGE(FATAL_ERROR "Could not find an OGRE render system plugin") |
---|
| 108 | ENDIF(NOT OGRE_RENDER_SYSTEM_FOUND) |
---|
| 109 | IF(WIN32) |
---|
| 110 | # Restore previous settings (see above before FOREACH) |
---|
[2587] | 111 | SET(CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES_STORED}") |
---|
[2585] | 112 | ENDIF(WIN32) |
---|
[2587] | 113 | SET(CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES_STORED}") |
---|
[2585] | 114 | |
---|
| 115 | # List has to be comma separated for orxonox.ini |
---|
| 116 | STRING(REPLACE ";" ", " OGRE_PLUGINS_RELEASE "${OGRE_PLUGINS_RELEASE}") |
---|
| 117 | STRING(REPLACE ";" ", " OGRE_PLUGINS_DEBUG "${OGRE_PLUGINS_DEBUG}") |
---|
| 118 | |
---|
| 119 | |
---|
[2509] | 120 | MARK_AS_ADVANCED( |
---|
| 121 | OGRE_LIBRARY |
---|
[2579] | 122 | OGRE_LIBRARY_OPTIMIZED |
---|
| 123 | OGRE_LIBRARY_DEBUG |
---|
[2509] | 124 | OGRE_INCLUDE_DIR |
---|
| 125 | ) |
---|