zibbr

Random 3d and p2p stuff that was originally the beginnings of an overly ambitious p2p virtual world thingy
git clone https://code.literati.org/zibbr.git
Log | Files | Refs

FindOGRE.cmake (19181B)


      1 #-------------------------------------------------------------------
      2 # This file is part of the CMake build system for OGRE
      3 #     (Object-oriented Graphics Rendering Engine)
      4 # For the latest info, see http://www.ogre3d.org/
      5 #
      6 # The contents of this file are placed in the public domain. Feel
      7 # free to make use of it in any way you like.
      8 #-------------------------------------------------------------------
      9 
     10 # - Try to find OGRE
     11 # If you have multiple versions of Ogre installed, use the CMake or
     12 # the environment variable OGRE_HOME to point to the path where the
     13 # desired Ogre version can be found.
     14 # By default this script will look for a dynamic Ogre build. If you
     15 # need to link against static Ogre libraries, set the CMake variable
     16 # OGRE_STATIC to TRUE.
     17 #
     18 # Once done, this will define
     19 #
     20 #  OGRE_FOUND - system has OGRE
     21 #  OGRE_INCLUDE_DIRS - the OGRE include directories 
     22 #  OGRE_LIBRARIES - link these to use the OGRE core
     23 #
     24 # Additionally this script searches for the following optional
     25 # parts of the Ogre package:
     26 #  Plugin_BSPSceneManager, Plugin_CgProgramManager,
     27 #  Plugin_OctreeSceneManager, Plugin_OctreeZone,
     28 #  Plugin_ParticleFX, Plugin_PCZSceneManager,
     29 #  RenderSystem_GL, RenderSystem_Direct3D9, RenderSystem_Direct3D10,
     30 #  CEGUIRenderer, Paging, Terrain
     31 #
     32 # For each of these components, the following variables are defined:
     33 #
     34 #  OGRE_${COMPONENT}_FOUND - ${COMPONENT} is available
     35 #  OGRE_${COMPONENT}_INCLUDE_DIRS - additional include directories for ${COMPONENT}
     36 #  OGRE_${COMPONENT}_LIBRARIES - link these to use ${COMPONENT} 
     37 #
     38 # Finally, the following variables are defined:
     39 #
     40 #  OGRE_PLUGIN_DIR_REL - The directory where the release versions of
     41 #       the OGRE plugins are located
     42 #  OGRE_PLUGIN_DIR_DBG - The directory where the debug versions of
     43 #       the OGRE plugins are located
     44 #  OGRE_MEDIA_DIR - The directory where the OGRE sample media is
     45 #       located, if available
     46 
     47 include(FindPkgMacros)
     48 include(PreprocessorUtils)
     49 findpkg_begin(OGRE)
     50 
     51 
     52 # Get path, convert backslashes as ${ENV_${var}}
     53 getenv_path(OGRE_HOME)
     54 getenv_path(OGRE_SDK)
     55 getenv_path(OGRE_SOURCE)
     56 getenv_path(OGRE_BUILD)
     57 getenv_path(PROGRAMFILES)
     58 
     59 
     60 # Determine whether to search for a dynamic or static build
     61 if (OGRE_STATIC)
     62   set(OGRE_LIB_SUFFIX "Static")
     63 else ()
     64   set(OGRE_LIB_SUFFIX "")
     65 endif ()
     66 
     67 
     68 set(OGRE_LIBRARY_NAMES "OgreMain${OGRE_LIB_SUFFIX}")
     69 get_debug_names(OGRE_LIBRARY_NAMES)
     70 
     71 # construct search paths from environmental hints and
     72 # OS specific guesses
     73 if (WIN32)
     74   set(OGRE_PREFIX_GUESSES
     75     ${ENV_PROGRAMFILES}/OGRE
     76     C:/OgreSDK
     77   )
     78 elseif (UNIX)
     79   set(OGRE_PREFIX_GUESSES
     80     /opt/ogre
     81     /opt/OGRE
     82     /usr/lib/ogre
     83     /usr/lib/OGRE
     84     /usr/local/lib/ogre
     85     /usr/local/lib/OGRE
     86     $ENV{HOME}/ogre
     87     $ENV{HOME}/OGRE
     88   )
     89 endif ()
     90 set(OGRE_PREFIX_PATH
     91   ${OGRE_HOME} ${ENV_OGRE_HOME} ${ENV_OGRE_SDK}
     92   ${OGRE_PREFIX_GUESSES}
     93 )
     94 create_search_paths(OGRE)
     95 # If both OGRE_BUILD and OGRE_SOURCE are set, prepare to find Ogre in a build dir
     96 set(OGRE_PREFIX_SOURCE ${OGRE_SOURCE} ${ENV_OGRE_SOURCE})
     97 set(OGRE_PREFIX_BUILD ${OGRE_BUILD} ${ENV_OGRE_BUILD})
     98 if (OGRE_PREFIX_SOURCE AND OGRE_PREFIX_BUILD)
     99   foreach(dir ${OGRE_PREFIX_SOURCE})
    100     set(OGRE_INC_SEARCH_PATH ${dir}/OgreMain/include ${dir}/Dependencies/include ${dir}/iPhoneDependencies/include ${OGRE_INC_SEARCH_PATH})
    101     set(OGRE_LIB_SEARCH_PATH ${dir}/lib ${dir}/Dependencies/lib ${dir}/iPhoneDependencies/lib ${OGRE_LIB_SEARCH_PATH})
    102   endforeach(dir)
    103   foreach(dir ${OGRE_PREFIX_BUILD})
    104     set(OGRE_INC_SEARCH_PATH ${dir}/include ${OGRE_INC_SEARCH_PATH})
    105     set(OGRE_LIB_SEARCH_PATH ${dir}/lib ${OGRE_LIB_SEARCH_PATH})
    106   endforeach(dir)
    107 else()
    108   set(OGRE_PREFIX_SOURCE "NOTFOUND")
    109   set(OGRE_PREFIX_BUILD "NOTFOUND")
    110 endif ()
    111 
    112 # redo search if any of the environmental hints changed
    113 set(OGRE_COMPONENTS Paging Terrain CEGUIRenderer
    114   Plugin_BSPSceneManager Plugin_CgProgramManager Plugin_OctreeSceneManager
    115   Plugin_OctreeZone Plugin_PCZSceneManager Plugin_ParticleFX
    116   RenderSystem_Direct3D10 RenderSystem_Direct3D9 RenderSystem_GL RenderSystem_GLES)
    117 set(OGRE_RESET_VARS 
    118   OGRE_CONFIG_INCLUDE_DIR OGRE_INCLUDE_DIR 
    119   OGRE_LIBRARY_FWK OGRE_LIBRARY_REL OGRE_LIBRARY_DBG
    120   OGRE_PLUGIN_DIR_DBG OGRE_PLUGIN_DIR_REL OGRE_MEDIA_DIR)
    121 foreach (comp ${OGRE_COMPONENTS})
    122   set(OGRE_RESET_VARS ${OGRE_RESET_VARS}
    123     OGRE_${comp}_INCLUDE_DIR OGRE_${comp}_LIBRARY_FWK
    124     OGRE_${comp}_LIBRARY_DBG OGRE_${comp}_LIBRARY_REL
    125   )
    126 endforeach (comp)
    127 set(OGRE_PREFIX_WATCH ${OGRE_PREFIX_PATH} ${OGRE_PREFIX_SOURCE} ${OGRE_PREFIX_BUILD})
    128 clear_if_changed(OGRE_PREFIX_WATCH ${OGRE_RESET_VARS})
    129 
    130 # try to locate Ogre via pkg-config
    131 use_pkgconfig(OGRE_PKGC "OGRE${OGRE_LIB_SUFFIX}")
    132 # try to find framework on OSX
    133 findpkg_framework(OGRE)
    134 
    135 # locate Ogre include files
    136 find_path(OGRE_CONFIG_INCLUDE_DIR NAMES OgreConfig.h HINTS ${OGRE_INC_SEARCH_PATH} ${OGRE_FRAMEWORK_INCLUDES} ${OGRE_PKGC_INCLUDE_DIRS} PATH_SUFFIXES "OGRE")
    137 find_path(OGRE_INCLUDE_DIR NAMES OgreRoot.h HINTS ${OGRE_CONFIG_INCLUDE_DIR} ${OGRE_INC_SEARCH_PATH} ${OGRE_FRAMEWORK_INCLUDES} ${OGRE_PKGC_INCLUDE_DIRS} PATH_SUFFIXES "OGRE")
    138 set(OGRE_INCOMPATIBLE FALSE)
    139 
    140 if (OGRE_INCLUDE_DIR AND OGRE_CONFIG_INCLUDE_DIR)
    141   # determine Ogre version
    142   file(READ ${OGRE_INCLUDE_DIR}/OgrePrerequisites.h OGRE_TEMP_VERSION_CONTENT)
    143   get_preprocessor_entry(OGRE_TEMP_VERSION_CONTENT OGRE_VERSION_MAJOR OGRE_VERSION_MAJOR)
    144   get_preprocessor_entry(OGRE_TEMP_VERSION_CONTENT OGRE_VERSION_MINOR OGRE_VERSION_MINOR)
    145   get_preprocessor_entry(OGRE_TEMP_VERSION_CONTENT OGRE_VERSION_PATCH OGRE_VERSION_PATCH)
    146   get_preprocessor_entry(OGRE_TEMP_VERSION_CONTENT OGRE_VERSION_NAME OGRE_VERSION_NAME)
    147   set(OGRE_VERSION "${OGRE_VERSION_MAJOR}.${OGRE_VERSION_MINOR}.${OGRE_VERSION_PATCH}")
    148   pkg_message(OGRE "Found Ogre ${OGRE_VERSION_NAME} (${OGRE_VERSION})")
    149 
    150   # determine configuration settings
    151   set(OGRE_CONFIG_HEADERS
    152     ${OGRE_CONFIG_INCLUDE_DIR}/buildsettings.h
    153     ${OGRE_CONFIG_INCLUDE_DIR}/config.h
    154     ${OGRE_CONFIG_INCLUDE_DIR}/OgreConfig.h
    155   )
    156   foreach(CFG_FILE ${OGRE_CONFIG_HEADERS})
    157     if (EXISTS ${CFG_FILE})
    158       set(OGRE_CONFIG_HEADER ${CFG_FILE})
    159       break()
    160     endif()
    161   endforeach()
    162   if (OGRE_CONFIG_HEADER)
    163     file(READ ${OGRE_CONFIG_HEADER} OGRE_TEMP_CONFIG_CONTENT)
    164     has_preprocessor_entry(OGRE_TEMP_CONFIG_CONTENT OGRE_STATIC_LIB OGRE_CONFIG_STATIC)
    165     get_preprocessor_entry(OGRE_TEMP_CONFIG_CONTENT OGRE_THREAD_SUPPORT OGRE_CONFIG_THREADS)
    166     get_preprocessor_entry(OGRE_TEMP_CONFIG_CONTENT OGRE_NO_FREEIMAGE OGRE_CONFIG_FREEIMAGE)
    167     if (OGRE_CONFIG_STATIC AND OGRE_STATIC)
    168     elseif (OGRE_CONFIG_STATIC OR OGRE_STATIC)
    169       pkg_message(OGRE "Build type (static, dynamic) does not match the requested one.")
    170       set(OGRE_INCOMPATIBLE TRUE)
    171     endif ()
    172   else ()
    173     pkg_message(OGRE "Could not determine Ogre build configuration.")
    174     set(OGRE_INCOMPATIBLE TRUE)
    175   endif ()
    176 else ()
    177   set(OGRE_INCOMPATIBLE FALSE)
    178 endif ()
    179 
    180 find_library(OGRE_LIBRARY_REL NAMES ${OGRE_LIBRARY_NAMES} HINTS ${OGRE_LIB_SEARCH_PATH} ${OGRE_PKGC_LIBRARY_DIRS} ${OGRE_FRAMEWORK_SEARCH_PATH} PATH_SUFFIXES "" "release" "relwithdebinfo" "minsizerel")
    181 find_library(OGRE_LIBRARY_DBG NAMES ${OGRE_LIBRARY_NAMES_DBG} HINTS ${OGRE_LIB_SEARCH_PATH} ${OGRE_PKGC_LIBRARY_DIRS} ${OGRE_FRAMEWORK_SEARCH_PATH} PATH_SUFFIXES "" "debug")
    182 make_library_set(OGRE_LIBRARY)
    183 
    184 if(APPLE)
    185 set(OGRE_LIBRARY_DBG ${OGRE_LIB_SEARCH_PATH})
    186 endif()
    187 if (OGRE_INCOMPATIBLE)
    188   set(OGRE_LIBRARY "NOTFOUND")
    189 endif ()
    190 
    191 set(OGRE_INCLUDE_DIR ${OGRE_CONFIG_INCLUDE_DIR} ${OGRE_INCLUDE_DIR})
    192 list(REMOVE_DUPLICATES OGRE_INCLUDE_DIR)
    193 findpkg_finish(OGRE)
    194 add_parent_dir(OGRE_INCLUDE_DIRS OGRE_INCLUDE_DIR)
    195 
    196 mark_as_advanced(OGRE_CONFIG_INCLUDE_DIR OGRE_MEDIA_DIR OGRE_PLUGIN_DIR_REL OGRE_PLUGIN_DIR_DBG)
    197 
    198 if (NOT OGRE_FOUND)
    199   return()
    200 endif ()
    201 
    202 
    203 # look for required Ogre dependencies in case of static build and/or threading
    204 if (OGRE_STATIC)
    205   set(OGRE_DEPS_FOUND TRUE)
    206   find_package(Cg QUIET)
    207   find_package(DirectX QUIET)
    208   find_package(FreeImage QUIET)
    209   find_package(Freetype QUIET)
    210   find_package(OpenGL QUIET)
    211   find_package(OpenGLES QUIET)
    212   find_package(ZLIB QUIET)
    213   find_package(ZZip QUIET)
    214   if (UNIX AND NOT APPLE)
    215     find_package(X11 QUIET)
    216     find_library(XAW_LIBRARY NAMES Xaw Xaw7 PATHS ${DEP_LIB_SEARCH_DIR} ${X11_LIB_SEARCH_PATH})
    217     if (NOT XAW_LIBRARY OR NOT X11_Xt_FOUND)
    218       set(X11_FOUND FALSE)
    219     endif ()
    220   endif ()
    221   if (APPLE)
    222     find_package(Cocoa QUIET)
    223     find_package(Carbon QUIET)
    224     if (NOT Cocoa_FOUND OR NOT Carbon_FOUND)
    225       set(OGRE_DEPS_FOUND FALSE)
    226     endif ()
    227   endif ()
    228 
    229   set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${OGRE_LIBRARY_FWK} ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES} 
    230     ${FreeImage_LIBRARIES} ${FREETYPE_LIBRARIES} 
    231     ${X11_LIBRARIES} ${X11_Xt_LIBRARIES} ${XAW_LIBRARY} ${X11_Xrandr_LIB}
    232     ${Cocoa_LIBRARIES} ${Carbon_LIBRARIES})
    233 
    234   if (NOT ZLIB_FOUND OR NOT ZZip_FOUND)
    235     set(OGRE_DEPS_FOUND FALSE)
    236   endif ()
    237   if (NOT FreeImage_FOUND AND NOT OGRE_CONFIG_FREEIMAGE)
    238     set(OGRE_DEPS_FOUND FALSE)
    239   endif ()
    240   if (NOT FREETYPE_FOUND)
    241     set(OGRE_DEPS_FOUND FALSE)
    242   endif ()
    243   if (UNIX AND NOT APPLE)
    244 	if (NOT X11_FOUND)
    245       set(OGRE_DEPS_FOUND FALSE)
    246 	endif ()
    247   endif ()
    248   
    249   if (OGRE_CONFIG_THREADS)
    250     find_package(Boost COMPONENTS thread QUIET)
    251     if (NOT Boost_THREAD_FOUND)
    252       set(OGRE_DEPS_FOUND FALSE)
    253     endif ()
    254   endif ()
    255   
    256   if (NOT OGRE_DEPS_FOUND)
    257     pkg_message(OGRE "Could not find all required dependencies for the Ogre package.")
    258     set(OGRE_FOUND FALSE)
    259   endif ()
    260 endif ()
    261 
    262 if (NOT OGRE_FOUND)
    263   return()
    264 endif ()
    265 
    266 
    267 get_filename_component(OGRE_LIBRARY_DIR_REL "${OGRE_LIBRARY_REL}" PATH)
    268 get_filename_component(OGRE_LIBRARY_DIR_DBG "${OGRE_LIBRARY_DBG}" PATH)
    269 set(OGRE_LIBRARY_DIRS ${OGRE_LIBRARY_DIR_REL} ${OGRE_LIBRARY_DIR_DBG})
    270 
    271 
    272 # look for Paging component
    273 find_path(OGRE_Paging_INCLUDE_DIR NAMES OgrePage.h HINTS ${OGRE_INCLUDE_DIRS} ${OGRE_PREFIX_SOURCE} PATH_SUFFIXES Paging OGRE/Paging Components/Paging/include)
    274 set(OGRE_Paging_LIBRARY_NAMES "OgrePaging${OGRE_LIB_SUFFIX}")
    275 get_debug_names(OGRE_Paging_LIBRARY_NAMES)
    276 find_library(OGRE_Paging_LIBRARY_REL NAMES ${OGRE_Paging_LIBRARY_NAMES} HINTS ${OGRE_LIBRARY_DIR_REL} PATH_SUFFIXES "" "release" "relwithdebinfo" "minsizerel")
    277 find_library(OGRE_Paging_LIBRARY_DBG NAMES ${OGRE_Paging_LIBRARY_NAMES_DBG} HINTS ${OGRE_LIBRARY_DIR_DBG} PATH_SUFFIXES "" "debug")
    278 set(OGRE_Paging_LIBRARY_FWK ${OGRE_LIBRARY_FWK})
    279 make_library_set(OGRE_Paging_LIBRARY)
    280 if (OGRE_Paging_INCLUDE_DIR AND OGRE_Paging_LIBRARY)
    281   set(OGRE_Paging_FOUND TRUE)
    282   set(OGRE_Paging_INCLUDE_DIRS ${OGRE_Paging_INCLUDE_DIRS})
    283   set(OGRE_Paging_LIBRARIES ${OGRE_Paging_LIBRARIES})
    284 endif ()
    285 mark_as_advanced(OGRE_Paging_INCLUDE_DIR OGRE_Paging_LIBRARY_REL OGRE_Paging_LIBRARY_DBG OGRE_Paging_LIBRARY_FWK)
    286 
    287 # look for Terrain component
    288 find_path(OGRE_Terrain_INCLUDE_DIR NAMES OgreTerrain.h HINTS ${OGRE_INCLUDE_DIRS} ${OGRE_PREFIX_SOURCE} PATH_SUFFIXES Terrain OGRE/Terrain Components/Terrain/include)
    289 set(OGRE_Terrain_LIBRARY_NAMES "OgreTerrain${OGRE_LIB_SUFFIX}")
    290 get_debug_names(OGRE_Terrain_LIBRARY_NAMES)
    291 find_library(OGRE_Terrain_LIBRARY_REL NAMES ${OGRE_Terrain_LIBRARY_NAMES} HINTS ${OGRE_LIBRARY_DIR_REL} PATH_SUFFIXES "" "release" "relwithdebinfo" "minsizerel")
    292 find_library(OGRE_Terrain_LIBRARY_DBG NAMES ${OGRE_Terrain_LIBRARY_NAMES_DBG} HINTS ${OGRE_LIBRARY_DIR_DBG} PATH_SUFFIXES "" "debug")
    293 make_library_set(OGRE_Terrain_LIBRARY)
    294 if (OGRE_Terrain_INCLUDE_DIR AND OGRE_Terrain_LIBRARY)
    295   set(OGRE_Terrain_FOUND TRUE)
    296   set(OGRE_Terrain_INCLUDE_DIRS ${OGRE_Terrain_INCLUDE_DIRS})
    297   set(OGRE_Terrain_LIBRARIES ${OGRE_Terrain_LIBRARIES} ${OGRE_Terrain_LIBRARY})
    298 endif ()
    299 mark_as_advanced(OGRE_Terrain_INCLUDE_DIR OGRE_Terrain_LIBRARY_REL OGRE_Terrain_LIBRARY_DBG OGRE_Terrain_LIBRARY_FWK)
    300 
    301 # look for CEGUI Ogre Renderer
    302 find_package(CEGUI QUIET)
    303 if (CEGUI_FOUND)
    304   get_filename_component(CEGUI_LIBRARY_DIR_REL ${CEGUI_LIBRARY_REL} PATH)
    305   get_filename_component(CEGUI_LIBRARY_DIR_DBG ${CEGUI_LIBRARY_DBG} PATH)
    306   set(CEGUI_LIBRARY_DIRS ${CEGUI_LIBRARY_DIR_REL} ${CEGUI_LIBRARY_DIR_DBG})
    307   find_path(OGRE_CEGUIRenderer_INCLUDE_DIR NAMES OgreCEGUIRenderer.h 
    308     HINTS ${OGRE_INCLUDE_DIRS} ${OGRE_PREFIX_SOURCE} ${CEGUI_INCLUDE_DIRS} PATH_SUFFIXES CEGUIRenderer OGRE OGRE/CEGUIRenderer CEGUI Samples/Common/CEGUIRenderer/include)
    309   set(OGRE_CEGUIRenderer_LIBRARY_NAMES "CEGUIOgreRenderer${OGRE_LIB_SUFFIX}" "OgreCEGUIRenderer${OGRE_LIB_SUFFIX}" "OgreGUIRenderer${OGRE_LIB_SUFFIX}")
    310   get_debug_names(OGRE_CEGUIRenderer_LIBRARY_NAMES)
    311   find_library(OGRE_CEGUIRenderer_LIBRARY_REL NAMES ${OGRE_CEGUIRenderer_LIBRARY_NAMES} HINTS ${OGRE_LIBRARY_DIRS} ${CEGUI_LIBRARY_DIRS}
    312     ${OGRE_FRAMEWORK_SEARCH_PATH} PATH_SUFFIXES "" "release" "relwithdebinfo" "minsizerel") 
    313   find_library(OGRE_CEGUIRenderer_LIBRARY_DBG NAMES ${OGRE_CEGUIRenderer_LIBRARY_NAMES_DBG} HINTS ${OGRE_LIBRARY_DIRS} ${CEGUI_LIBRARY_DIRS}
    314     ${OGRE_FRAMEWORK_SEARCH_PATH} PATH_SUFFIXES "" "debug") 
    315   make_library_set(OGRE_CEGUIRenderer_LIBRARY)
    316   
    317   if (OGRE_CEGUIRenderer_INCLUDE_DIR AND OGRE_CEGUIRenderer_LIBRARY)
    318     set(OGRE_CEGUIRenderer_FOUND TRUE)
    319     set(OGRE_CEGUIRenderer_INCLUDE_DIRS ${OGRE_CEGUIRenderer_INCLUDE_DIR} ${CEGUI_INCLUDE_DIRS})
    320     set(OGRE_CEGUIRenderer_LIBRARIES ${OGRE_CEGUIRenderer_LIBRARY} ${CEGUI_LIBRARIES})
    321   endif()
    322 
    323   mark_as_advanced(OGRE_CEGUIRenderer_INCLUDE_DIR OGRE_CEGUIRenderer_LIBRARY_REL OGRE_CEGUIRenderer_LIBRARY_DBG OGRE_CEGUIRenderer_LIBRARY_FWK)
    324 endif ()
    325 
    326 
    327 #########################################################
    328 # Find Ogre plugins
    329 #########################################################
    330 
    331 macro(ogre_find_plugin PLUGIN HEADER)
    332   # On Unix, the plugins might have no prefix
    333   if (CMAKE_FIND_LIBRARY_PREFIXES)
    334     set(TMP_CMAKE_LIB_PREFIX ${CMAKE_FIND_LIBRARY_PREFIXES})
    335     set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "")
    336   endif()
    337   
    338   # strip RenderSystem_ or Plugin_ prefix from plugin name
    339   string(REPLACE "RenderSystem_" "" PLUGIN_TEMP ${PLUGIN})
    340   string(REPLACE "Plugin_" "" PLUGIN_NAME ${PLUGIN_TEMP})
    341   
    342   # header files for plugins are not usually needed, but find them anyway if they are present
    343   set(OGRE_PLUGIN_PATH_SUFFIXES
    344     PlugIns PlugIns/${PLUGIN_NAME} Plugins Plugins/${PLUGIN_NAME} ${PLUGIN} 
    345     RenderSystems RenderSystems/${PLUGIN_NAME} ${ARGN})
    346   find_path(OGRE_${PLUGIN}_INCLUDE_DIR NAMES ${HEADER} 
    347     HINTS ${OGRE_INCLUDE_DIRS} ${OGRE_PREFIX_SOURCE}  
    348     PATH_SUFFIXES ${OGRE_PLUGIN_PATH_SUFFIXES})
    349   # find link libraries for plugins
    350   set(OGRE_${PLUGIN}_LIBRARY_NAMES "${PLUGIN}${OGRE_LIB_SUFFIX}")
    351   get_debug_names(OGRE_${PLUGIN}_LIBRARY_NAMES)
    352   set(OGRE_${PLUGIN}_LIBRARY_FWK ${OGRE_LIBRARY_FWK})
    353   find_library(OGRE_${PLUGIN}_LIBRARY_REL NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES}
    354     HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE opt release release/opt relwithdebinfo relwithdebinfo/opt minsizerel minsizerel/opt)
    355   find_library(OGRE_${PLUGIN}_LIBRARY_DBG NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES_DBG}
    356     HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE opt debug debug/opt)
    357   make_library_set(OGRE_${PLUGIN}_LIBRARY)
    358 
    359   if (OGRE_${PLUGIN}_LIBRARY OR OGRE_${PLUGIN}_INCLUDE_DIR)
    360     set(OGRE_${PLUGIN}_FOUND TRUE)
    361     if (OGRE_${PLUGIN}_INCLUDE_DIR)
    362       set(OGRE_${PLUGIN}_INCLUDE_DIRS ${OGRE_${PLUGIN}_INCLUDE_DIR})
    363     endif()
    364     set(OGRE_${PLUGIN}_LIBRARIES ${OGRE_${PLUGIN}_LIBRARY})
    365   endif ()
    366 
    367   mark_as_advanced(OGRE_${PLUGIN}_INCLUDE_DIR OGRE_${PLUGIN}_LIBRARY_REL OGRE_${PLUGIN}_LIBRARY_DBG OGRE_${PLUGIN}_LIBRARY_FWK)
    368 
    369   # look for plugin dirs
    370   if (OGRE_${PLUGIN}_FOUND)
    371     if (NOT OGRE_PLUGIN_DIR_REL OR NOT OGRE_PLUGIN_DIR_DBG)
    372       if (WIN32)
    373         set(OGRE_PLUGIN_SEARCH_PATH_REL 
    374           ${OGRE_LIBRARY_DIR_REL}/..
    375           ${OGRE_LIBRARY_DIR_REL}/../..
    376         )
    377         set(OGRE_PLUGIN_SEARCH_PATH_DBG
    378           ${OGRE_LIBRARY_DIR_DBG}/..
    379           ${OGRE_LIBRARY_DIR_DBG}/../..
    380         )
    381         find_path(OGRE_PLUGIN_DIR_REL NAMES "${PLUGIN}.dll" HINTS ${OGRE_PLUGIN_SEARCH_PATH_REL}
    382           PATH_SUFFIXES "" bin bin/release bin/relwithdebinfo bin/minsizerel)
    383         find_path(OGRE_PLUGIN_DIR_DBG NAMES "${PLUGIN}_d.dll" HINTS ${OGRE_PLUGIN_SEARCH_PATH_DBG}
    384           PATH_SUFFIXES "" bin bin/debug)
    385       elseif (UNIX)
    386         get_filename_component(OGRE_PLUGIN_DIR_TMP ${OGRE_${PLUGIN}_LIBRARY_REL} PATH)
    387         set(OGRE_PLUGIN_DIR_REL ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (release)")
    388         get_filename_component(OGRE_PLUGIN_DIR_TMP ${OGRE_${PLUGIN}_LIBRARY_DBG} PATH)
    389         set(OGRE_PLUGIN_DIR_DBG ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (debug)")
    390       endif ()
    391     endif ()
    392   endif ()
    393 
    394   if (TMP_CMAKE_LIB_PREFIX)
    395     set(CMAKE_FIND_LIBRARY_PREFIXES ${TMP_CMAKE_LIB_PREFIX})
    396   endif ()
    397 endmacro(ogre_find_plugin)
    398 
    399 ogre_find_plugin(Plugin_PCZSceneManager OgrePCZSceneManager.h PCZ PlugIns/PCZSceneManager/include)
    400 ogre_find_plugin(Plugin_OctreeZone OgreOctreeZone.h PCZ PlugIns/OctreeZone/include)
    401 ogre_find_plugin(Plugin_BSPSceneManager OgreBspSceneManager.h PlugIns/BSPSceneManager/include)
    402 ogre_find_plugin(Plugin_CgProgramManager OgreCgProgram.h PlugIns/CgProgramManager/include)
    403 ogre_find_plugin(Plugin_OctreeSceneManager OgreOctreeSceneManager.h PlugIns/OctreeSceneManager/include)
    404 ogre_find_plugin(Plugin_ParticleFX OgreParticleFXPrerequisites.h PlugIns/ParticleFX/include)
    405 ogre_find_plugin(RenderSystem_GL OgreGLRenderSystem.h RenderSystems/GL/include)
    406 ogre_find_plugin(RenderSystem_GLES OgreGLESRenderSystem.h RenderSystems/GLES/include)
    407 ogre_find_plugin(RenderSystem_Direct3D9 OgreD3D9RenderSystem.h RenderSystems/Direct3D9/include)
    408 ogre_find_plugin(RenderSystem_Direct3D10 OgreD3D10RenderSystem.h RenderSystems/Direct3D10/include)
    409 
    410 if (OGRE_STATIC)
    411   # check if dependencies for plugins are met
    412   if (NOT DirectX_FOUND)
    413     set(OGRE_RenderSystem_Direct3D9_FOUND FALSE)
    414   endif ()
    415   if (NOT DirectX_D3D10_FOUND)
    416     set(OGRE_RenderSystem_Direct3D10_FOUND FALSE)
    417   endif ()
    418   if (NOT OPENGL_FOUND)
    419     set(OGRE_RenderSystem_GL_FOUND FALSE)
    420   endif ()
    421   if (NOT OPENGLES_FOUND AND NOT OPENGLES2_FOUND)
    422     set(OGRE_RenderSystem_GLES_FOUND FALSE)
    423   endif ()
    424   if (NOT Cg_FOUND)
    425     set(OGRE_Plugin_CgProgramManager_FOUND FALSE)
    426   endif ()
    427   
    428   set(OGRE_RenderSystem_Direct3D9_LIBRARIES ${OGRE_RenderSystem_Direct3D9_LIBRARIES}
    429     ${DirectX_LIBRARIES}
    430   )
    431   set(OGRE_RenderSystem_Direct3D10_LIBRARIES ${OGRE_RenderSystem_Direct3D10_LIBRARIES}
    432     ${DirectX_D3D10_LIBRARIES}
    433   )
    434   set(OGRE_RenderSystem_GL_LIBRARIES ${OGRE_RenderSystem_GL_LIBRARIES}
    435     ${OPENGL_LIBRARIES}
    436   )
    437   set(OGRE_RenderSystem_GLES_LIBRARIES ${OGRE_RenderSystem_GLES_LIBRARIES}
    438     ${OPENGLES_LIBRARIES}
    439   )
    440   set(OGRE_Plugin_CgProgramManager_LIBRARIES ${OGRE_Plugin_CgProgramManager_LIBRARIES}
    441     ${Cg_LIBRARIES}
    442   )
    443 endif ()
    444 
    445 # look for the media directory
    446 set(OGRE_MEDIA_SEARCH_PATH
    447   ${OGRE_LIBRARY_DIR_REL}/..
    448   ${OGRE_LIBRARY_DIR_DBG}/..
    449   ${OGRE_LIBRARY_DIR_REL}/../..
    450   ${OGRE_LIBRARY_DIR_DBG}/../..
    451   ${OGRE_PREFIX_SOURCE}
    452 )
    453 set(OGRE_MEDIA_SEARCH_SUFFIX
    454   Media
    455   media
    456   share/OGRE/media
    457   Samples/Media
    458 )
    459 clear_if_changed(OGRE_PREFIX_WATCH OGRE_MEDIA_DIR)
    460 find_path(OGRE_MEDIA_DIR NAMES packs/OgreCore.zip HINTS ${OGRE_MEDIA_SEARCH_PATH}
    461   PATHS ${OGRE_PREFIX_PATH} PATH_SUFFIXES ${OGRE_MEDIA_SEARCH_SUFFIX})
    462