SHARE
TWEET

FindCEGUI

a guest Apr 28th, 2016 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ################################################################################
  2. # FindCEGUI
  3. #
  4. # Locate CEGUI LIBRARIES
  5. #
  6. # This module defines
  7. #    CEGUI_FOUND, if false, do not try to link to CEGUI
  8. #    CEGUI_INCLUDE_DIR, where to find headers.
  9. #    CEGUI_LIBRARIES, the LIBRARIES to link against
  10. #    CEGUI_BINARY_REL - location of the main CEGUI binary (win32 non-static only, release)
  11. #    CEGUI_BINARY_DBG - location of the main CEGUI binaries (win32 non-static only, debug)
  12. #
  13. #
  14. #         Modules :
  15. #    CEGUI_${COMPONENT}_FOUND - ${COMPONENT} is available
  16. #    CEGUI_${COMPONENT}_INCLUDE_DIRS - additional include directories for ${COMPONENT}
  17. #    CEGUI_${COMPONENT}_LIBRARIES - link these to use ${COMPONENT}
  18. #    CEGUI_${COMPONENT}_BINARY_REL - location of the component binary (win32 non-static only, release)
  19. #    CEGUI_${COMPONENT}_BINARY_DBG - location of the component binary (win32 non-static only, debug)
  20. #
  21. # VERSION 0.7.X:
  22. #        WindowsRenderer:
  23. #                Falagard
  24. #        Renderer:
  25. #                Direct3D9Renderer Direct3D10Renderer Direct3D11Renderer IrrlichtRenderer NullRenderer OgreRenderer OpenGLRenderer
  26. #        ImageCodec:
  27. #                CoronaImageCodec DevILImageCodec FreeImageImageCodec SILLYImageCodec STBImageCodec TGAImageCodec
  28. #        Parser:
  29. #                ExpatParser LibxmlParser RapidXMLParser TinyXMLParser XercesParser)
  30. #        Script:
  31. #                LuaScriptModule toluapp
  32.  
  33. # VERSION 0.8.X:
  34. #        WindowsRenderer:
  35. #                CoreWindowRendererSet
  36. #        Renderer:
  37. #                Direct3D9Renderer Direct3D10Renderer Direct3D11Renderer IrrlichtRenderer NullRenderer OgreRenderer OpenGLRenderer OpenGL3Renderer OpenGLESRenderer
  38. #        ImageCodec:
  39. #                CoronaImageCodec DevILImageCodec FreeImageImageCodec SILLYImageCodec STBImageCodec TGAImageCodec PVRImageCodec
  40. #        Parser:
  41. #                ExpatParser LibXMLParser RapidXMLParser TinyXMLParser XercesParser)
  42. #        Script:
  43. #                LuaScriptModule
  44. #
  45. # author: Guillaume Smaha
  46. #
  47. # People have asked us to include a FindCEGUI that is high quality that they will
  48. # be able to copy and use to find CEGUI, so we have finally done that.
  49. #
  50. # If you have improvements for this scripts, please consider sending them upstream.
  51. # See https://bitbucket.org/cegui/cegui
  52. ################################################################################
  53.  
  54.  
  55. ################################################################################
  56. # Get the value of a preprocessor entry
  57. ################################################################################
  58. macro(get_preprocessor_entry CONTENTS KEYWORD VARIABLE)
  59.     string(REGEX MATCH
  60.         "# *define +${KEYWORD} +((\"([^\n]*)\")|([^ \n]*))"
  61.         PREPROC_TEMP_VAR
  62.         ${${CONTENTS}}
  63.     )
  64.     if (CMAKE_MATCH_3)
  65.         set(${VARIABLE} ${CMAKE_MATCH_3})
  66.     else ()
  67.         set(${VARIABLE} ${CMAKE_MATCH_4})
  68.     endif ()
  69. endmacro()
  70.  
  71. ################################################################################
  72. # Check if exist a preprocessor entry
  73. ################################################################################
  74. macro(has_preprocessor_entry CONTENTS KEYWORD VARIABLE)
  75.     string(REGEX MATCH
  76.         "\n *# *define +(${KEYWORD})"
  77.         PREPROC_TEMP_VAR
  78.         ${${CONTENTS}}
  79.     )
  80.     if (CMAKE_MATCH_1)
  81.         set(${VARIABLE} TRUE)
  82.     else ()
  83.         set(${VARIABLE} FALSE)
  84.     endif ()
  85. endmacro()
  86.  
  87. ################################################################################
  88. # Replace the value of a preprocessor entry
  89. ################################################################################
  90. macro(replace_preprocessor_entry VARIABLE KEYWORD NEW_VALUE)
  91.     string(REGEX REPLACE
  92.         "(// *)?# *define +${KEYWORD} +[^ \n]*"
  93.         "#define ${KEYWORD} ${NEW_VALUE}"
  94.         ${VARIABLE}_TEMP
  95.         ${${VARIABLE}}
  96.     )
  97.     set(${VARIABLE} ${${VARIABLE}_TEMP})
  98. endmacro()
  99.  
  100. ################################################################################
  101. # Define the value of preprocessor entry
  102. ################################################################################
  103. macro(set_preprocessor_entry VARIABLE KEYWORD ENABLE)
  104.     if (${ENABLE})
  105.         set(TMP_REPLACE_STR "#define ${KEYWORD}")
  106.     else ()
  107.         set(TMP_REPLACE_STR "// #define ${KEYWORD}")
  108.     endif ()
  109.     string(REGEX REPLACE
  110.         "(// *)?# *define +${KEYWORD} *\n"
  111.         ${TMP_REPLACE_STR}
  112.         ${VARIABLE}_TEMP
  113.         ${${VARIABLE}}
  114.     )
  115.     set(${VARIABLE} ${${VARIABLE}_TEMP})
  116. endmacro()
  117.  
  118. ################################################################################
  119. # Begin processing of package
  120. ################################################################################
  121. macro(findpkg_begin PREFIX)
  122.     if (NOT ${PREFIX}_FIND_QUIETLY)
  123.         message(STATUS "Looking for ${PREFIX}...")
  124.     endif ()
  125. endmacro(findpkg_begin)
  126.  
  127. ################################################################################
  128. # Display a status message unless FIND_QUIETLY is set
  129. ################################################################################
  130. macro(pkg_message PREFIX)
  131.     if (NOT ${PREFIX}_FIND_QUIETLY)
  132.         message(STATUS ${ARGN})
  133.     endif ()
  134. endmacro(pkg_message)
  135.  
  136. ################################################################################
  137. # Get environment variable, define it as ENV_$var and make sure backslashes are converted to forward slashes
  138. ################################################################################
  139. macro(getenv_path VAR)
  140.      set(ENV_${VAR} $ENV{${VAR}})
  141.      # replace won't work if var is blank
  142.      if (ENV_${VAR})
  143.          string( REGEX REPLACE "\\\\" "/" ENV_${VAR} ${ENV_${VAR}} )
  144.      endif ()
  145. endmacro(getenv_path)
  146.  
  147. ################################################################################
  148. # Construct search paths for includes and libraries from a PREFIX_PATH
  149. ################################################################################
  150. macro(create_search_paths PREFIX)
  151.     foreach(dir ${${PREFIX}_PREFIX_PATH})
  152.         set(${PREFIX}_INC_SEARCH_PATH ${${PREFIX}_INC_SEARCH_PATH}
  153.             ${dir}/include ${dir}/Include ${dir}/include/${PREFIX} ${dir}/Headers)
  154.         set(${PREFIX}_INC_SEARCH_PATH ${${PREFIX}_INC_SEARCH_PATH}
  155.             ${dir}/${PREFIX}/include ${dir}/${PREFIX}/Include ${dir}/${PREFIX}/include/${PREFIX} ${dir}/${PREFIX}/Headers)
  156.         set(${PREFIX}_LIB_SEARCH_PATH ${${PREFIX}_LIB_SEARCH_PATH}
  157.             ${dir}/lib ${dir}/Lib ${dir}/lib/${PREFIX} ${dir}/Libs)
  158.         set(${PREFIX}_BIN_SEARCH_PATH ${${PREFIX}_BIN_SEARCH_PATH}
  159.             ${dir}/bin)
  160.     endforeach(dir)
  161.     if(ANDROID)
  162.         set(${PREFIX}_LIB_SEARCH_PATH ${${PREFIX}_LIB_SEARCH_PATH} ${OGRE_DEPENDENCIES_DIR}/lib/${ANDROID_ABI})
  163.     endif()
  164.     set(${PREFIX}_FRAMEWORK_SEARCH_PATH ${${PREFIX}_PREFIX_PATH})
  165. endmacro(create_search_paths)
  166.  
  167. ################################################################################
  168. # clear cache variables if a certain variable changed
  169. ################################################################################
  170. macro(clear_if_changed TESTVAR)
  171.     # test against internal check variable
  172.     # HACK: Apparently, adding a variable to the cache cleans up the list
  173.     # a bit. We need to also remove any empty strings from the list, but
  174.     # at the same time ensure that we are actually dealing with a list.
  175.     list(APPEND ${TESTVAR} "")
  176.     list(REMOVE_ITEM ${TESTVAR} "")
  177.     if (NOT "${${TESTVAR}}" STREQUAL "${${TESTVAR}_INT_CHECK}")
  178.         message(STATUS "${TESTVAR} changed.")
  179.         foreach(var ${ARGN})
  180.             set(${var} "NOTFOUND" CACHE STRING "${var}-docstring" FORCE)
  181.         endforeach(var)
  182.     endif ()
  183.     set(${TESTVAR}_INT_CHECK ${${TESTVAR}} CACHE INTERNAL "${TESTVAR}-docstring" FORCE)
  184. endmacro(clear_if_changed)
  185.  
  186. ################################################################################
  187. # Try to get some hints from pkg-config, if available
  188. ################################################################################
  189. macro(use_pkgconfig PREFIX PKGNAME)
  190.     find_package(PkgConfig)
  191.     if (PKG_CONFIG_FOUND)
  192.         pkg_check_modules(${PREFIX} ${PKGNAME} QUIET)
  193.     endif ()
  194. endmacro (use_pkgconfig)
  195.  
  196. ################################################################################
  197. # Couple a set of release AND debug libraries (or frameworks)
  198. ################################################################################
  199. macro(make_library_set PREFIX)
  200.  
  201.     if (${PREFIX}_FWK)
  202.         set(${PREFIX} ${${PREFIX}_FWK})
  203.     elseif (${PREFIX}_REL AND ${PREFIX}_DBG)
  204.         set(${PREFIX} optimized ${${PREFIX}_REL} debug ${${PREFIX}_DBG})
  205.     elseif (${PREFIX}_REL)
  206.         set(${PREFIX} ${${PREFIX}_REL})
  207.     elseif (${PREFIX}_DBG)
  208.         set(${PREFIX} ${${PREFIX}_DBG})
  209.     endif ()
  210. endmacro(make_library_set)
  211.  
  212. ################################################################################
  213. # Generate debug names from given release names
  214. ################################################################################
  215. macro(get_debug_names PREFIX)
  216.     foreach(i ${${PREFIX}})
  217.         set(${PREFIX}_DBG ${${PREFIX}_DBG} ${i}d ${i}D ${i}_d ${i}_D ${i}_debug ${i})
  218.     endforeach(i)
  219. endmacro(get_debug_names)
  220.  
  221. ################################################################################
  222. # Add the parent dir from DIR to VAR
  223. ################################################################################
  224. macro(add_parent_dir VAR DIR)
  225.     get_filename_component(${DIR}_TEMP "${${DIR}}/.." ABSOLUTE)
  226.     set(${VAR} ${${VAR}} ${${DIR}_TEMP})
  227. endmacro(add_parent_dir)
  228.  
  229. ################################################################################
  230. # Do the final processing for the package find.
  231. ################################################################################
  232. macro(findpkg_finish PREFIX)
  233.     # skip if already processed during this run
  234.     if (NOT ${PREFIX}_FOUND)
  235.         if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY)
  236.             set(${PREFIX}_FOUND TRUE)
  237.             set(${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIR})
  238.             set(${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARY})
  239.             if (NOT ${PREFIX}_FIND_QUIETLY)
  240.                 message(STATUS "Found ${PREFIX}: ${${PREFIX}_LIBRARIES}")
  241.             endif ()
  242.         else ()
  243.             if (NOT ${PREFIX}_FIND_QUIETLY)
  244.                 message(STATUS "Could not locate ${PREFIX}")
  245.             endif ()
  246.             if (${PREFIX}_FIND_REQUIRED)
  247.                 message(FATAL_ERROR "Required library ${PREFIX} not found! Install the library (including dev packages) and try again. If the library is already installed, set the missing variables manually in cmake.")
  248.             endif ()
  249.         endif ()
  250.  
  251.         mark_as_advanced(${PREFIX}_FOUND ${PREFIX}_LIBRARIES ${PREFIX}_INCLUDE_DIRS ${PREFIX}_INCLUDE_DIR ${PREFIX}_LIBRARY ${PREFIX}_LIBRARY_REL ${PREFIX}_LIBRARY_DBG ${PREFIX}_LIBRARY_FWK)
  252.     endif ()
  253. endmacro(findpkg_finish)
  254.  
  255.  
  256. #########################################################
  257. # Find cegui modules
  258. #########################################################
  259. macro(cegui_find_modules PLUGIN_COMPONENT)
  260.  
  261.     foreach (comp ${CEGUI_${PLUGIN_COMPONENT}_MODULES})
  262.  
  263.         set(LIBNAME ${comp})
  264.         set(HEADER ${CEGUI_${PLUGIN_COMPONENT}_MODULES_${comp}_HEADER})
  265.         set(PKGCONFIG ${CEGUI_${PLUGIN_COMPONENT}_MODULES_${comp}_PKGCONFIG})
  266.         set(CHECKNOPREFIX ${CEGUI_${PLUGIN_COMPONENT}_MODULES_${comp}_CHECKNOPREFIX})
  267.  
  268.         if (NOT "${HEADER}" STREQUAL "")
  269.  
  270.             findpkg_begin(CEGUI_${comp})
  271.  
  272.             if(PKGCONFIG)
  273.                 use_pkgconfig(CEGUI_${comp}_PKGC "CEGUI-${PKGCONFIG}")
  274.                 if(NOT CEGUI_${comp}_PKGC_INCLUDE_DIRS AND CEGUI_LIB_SUFFIX)
  275.                     use_pkgconfig(CEGUI_${comp}_PKGC "CEGUI${CEGUI_LIB_SUFFIX}-${PKGCONFIG}")
  276.                 endif()
  277.             endif()
  278.  
  279.             list(LENGTH HEADER len)
  280.             math(EXPR lenmax "${len} - 1")
  281.  
  282.             foreach(val RANGE ${lenmax})
  283.                 list(GET HEADER ${val} pathHeader)
  284.  
  285.                 if(CEGUI_${comp}_INCLUDE_DIR)
  286.                     set(CEGUI_${comp}_INCLUDE_DIR_TMP ${CEGUI_${comp}_INCLUDE_DIR})
  287.                     unset(CEGUI_${comp}_INCLUDE_DIR CACHE)
  288.                 endif()
  289.  
  290.                 get_filename_component(head "${pathHeader}" NAME)
  291.                 get_filename_component(dir "${pathHeader}" DIRECTORY)
  292.                 if (NOT "${dir}" STREQUAL "")
  293.                     set(dir "${dir}/")
  294.                 endif ()
  295.  
  296.                 find_path(CEGUI_${comp}_INCLUDE_DIR NAMES ${head} HINTS ${CEGUI_INCLUDE_DIRS} ${CEGUI_${comp}_PKGC_INCLUDE_DIRS} PATH_SUFFIXES ${dir} CEGUI/${dir})
  297.  
  298.                 if(CEGUI_${comp}_INCLUDE_DIR_TMP)
  299.                     set(CEGUI_${comp}_INCLUDE_DIR ${CEGUI_${comp}_INCLUDE_DIR} ${CEGUI_${comp}_INCLUDE_DIR_TMP})
  300.                     unset(CEGUI_${comp}_INCLUDE_DIR_TMP CACHE)
  301.                 endif()
  302.  
  303.             endforeach()
  304.             list(REMOVE_DUPLICATES CEGUI_${comp}_INCLUDE_DIR)
  305.  
  306.             set(CEGUI_SUBLIB_DIR "cegui-${CEGUI_VERSION_MAJOR}.${CEGUI_VERSION_MINOR}")
  307.  
  308.  
  309.             set(CEGUI_${comp}_LIBRARY_NAMES "CEGUI${comp}")
  310.             get_debug_names(CEGUI_${comp}_LIBRARY_NAMES)
  311.  
  312.             set(CEGUI_${comp}_LIBRARY_NAMES_SUFFIX "CEGUI${comp}${CEGUI_LIB_SUFFIX}")
  313.             get_debug_names(CEGUI_${comp}_LIBRARY_NAMES_SUFFIX)
  314.  
  315.             find_library(CEGUI_${comp}_LIBRARY_REL NAMES ${CEGUI_${comp}_LIBRARY_NAMES} ${CEGUI_${comp}_LIBRARY_NAMES_SUFFIX} HINTS ${CEGUI_LIBRARY_DIR_REL} ${CEGUI_LIBRARY_DIR_REL}/${CEGUI_SUBLIB_DIR} ${CEGUI_${comp}_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" "Release" "RelWithDebInfo" "MinSizeRel")
  316.             find_library(CEGUI_${comp}_LIBRARY_DBG NAMES ${CEGUI_${comp}_LIBRARY_NAMES_DBG} ${CEGUI_${comp}_LIBRARY_NAMES_SUFFIX_DBG} HINTS ${CEGUI_LIBRARY_DIR_DBG} ${CEGUI_LIBRARY_DIR_DBG}/${CEGUI_SUBLIB_DIR} ${CEGUI_${comp}_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" "Debug")
  317.  
  318.             if(CHECKNOPREFIX AND (NOT CEGUI_${comp}_LIBRARY_REL OR NOT CEGUI_${comp}_LIBRARY_DBG))
  319.                 set(CEGUI_${comp}_LIBRARY_NAMES "${comp}")
  320.                 get_debug_names(CEGUI_${comp}_LIBRARY_NAMES)
  321.  
  322.                 set(CEGUI_${comp}_LIBRARY_NAMES_SUFFIX "${comp}${CEGUI_LIB_SUFFIX}")
  323.                 get_debug_names(CEGUI_${comp}_LIBRARY_NAMES_SUFFIX)
  324.  
  325.                 find_library(CEGUI_${comp}_LIBRARY_REL NAMES ${CEGUI_${comp}_LIBRARY_NAMES} ${CEGUI_${comp}_LIBRARY_NAMES_SUFFIX} HINTS ${CEGUI_LIBRARY_DIR_REL} ${CEGUI_LIBRARY_DIR_REL}/${CEGUI_SUBLIB_DIR} ${CEGUI_${comp}_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" "Release" "RelWithDebInfo" "MinSizeRel")
  326.                 find_library(CEGUI_${comp}_LIBRARY_DBG NAMES ${CEGUI_${comp}_LIBRARY_NAMES_DBG} ${CEGUI_${comp}_LIBRARY_NAMES_SUFFIX_DBG} HINTS ${CEGUI_LIBRARY_DIR_DBG} ${CEGUI_LIBRARY_DIR_DBG}/${CEGUI_SUBLIB_DIR} ${CEGUI_${comp}_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" "Debug")
  327.             endif()
  328.  
  329.             make_library_set(CEGUI_${comp}_LIBRARY)
  330.  
  331.             if (NOT CEGUI_STATIC)
  332.                 if (WIN32)
  333.                     find_file(CEGUI_${comp}_BINARY_REL NAMES "CEGUI${comp}.dll" "CEGUI${comp}${CEGUI_LIB_SUFFIX}.dll" HINTS ${CEGUI_BIN_SEARCH_PATH} ${CEGUI_${comp}_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" "Release" "RelWithDebInfo" "MinSizeRel")
  334.                     find_file(CEGUI_${comp}_BINARY_DBG NAMES "CEGUI${comp}_d.dll" "CEGUI${comp}${CEGUI_LIB_SUFFIX}_d.dll" HINTS ${CEGUI_BIN_SEARCH_PATH} ${CEGUI_${comp}_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" "Debug")
  335.  
  336.                      if(CHECKNOPREFIX AND (NOT CEGUI_${comp}_LIBRARY_REL OR NOT CEGUI_${comp}_LIBRARY_DBG))
  337.                          find_file(CEGUI_${comp}_BINARY_REL NAMES "${comp}${CEGUI_LIB_SUFFIX}.dll" HINTS ${CEGUI_BIN_SEARCH_PATH} PATH_SUFFIXES "" "Release" "RelWithDebInfo" "MinSizeRel")
  338.                          find_file(CEGUI_${comp}_BINARY_DBG NAMES "${comp}${CEGUI_LIB_SUFFIX}_d.dll" HINTS ${CEGUI_BIN_SEARCH_PATH} PATH_SUFFIXES "" "Debug")
  339.                     endif()
  340.                 endif()
  341.  
  342.                 get_filename_component(CEGUI_${comp}_BINARY_DIR_REL "${CEGUI_${comp}_BINARY_REL}" PATH)
  343.                 get_filename_component(CEGUI_${comp}_BINARY_DIR_DBG "${CEGUI_${comp}_BINARY_DBG}" PATH)
  344.                 mark_as_advanced(CEGUI_${comp}_BINARY_REL CEGUI_${comp}_BINARY_DBG CEGUI_${comp}_BINARY_DIR_REL CEGUI_${comp}_BINARY_DIR_DBG)
  345.             endif()
  346.  
  347.             findpkg_finish(CEGUI_${comp})
  348.  
  349.         endif ()
  350.  
  351.     endforeach (comp)
  352.  
  353. endmacro(cegui_find_modules)
  354.  
  355.  
  356. #########################################################
  357. # register a module
  358. #########################################################
  359. macro(cegui_register_module TYPE LIBNAME HEADER PKGCONFIG)
  360.         set(CEGUI_MODULES ${CEGUI_MODULES} ${LIBNAME})
  361.         set(CEGUI_${TYPE}_MODULES ${CEGUI_${TYPE}_MODULES} ${LIBNAME})
  362.         set(CEGUI_${TYPE}_MODULES_${LIBNAME}_HEADER ${HEADER})
  363.         if(NOT "${PKGCONFIG}" STREQUAL "")
  364.             set(CEGUI_${TYPE}_MODULES_${LIBNAME}_PKGCONFIG ${PKGCONFIG})
  365.         endif()
  366. endmacro()
  367.  
  368.  
  369. #########################################################
  370. # Main
  371. #########################################################
  372.  
  373.  
  374. set(CEGUI_VERSION_MAJOR_DEFAULT "0")
  375.  
  376. # Register var to check change on base
  377. set(CEGUI_RESET_VARS CEGUI_CONFIG_INCLUDE_DIR CEGUI_INCLUDE_DIR CEGUI_LIBRARY_REL CEGUI_LIBRARY_DBG)
  378. set(CEGUI_PREFIX_WATCH ${CEGUI_PREFIX_PATH})
  379. clear_if_changed(CEGUI_PREFIX_WATCH ${CEGUI_RESET_VARS})
  380.  
  381. findpkg_begin(CEGUI)
  382.  
  383. # Get path, convert backslashes as ${ENV_${var}}
  384. getenv_path(CEGUI_HOME)
  385. getenv_path(CEGUI_DIR)
  386. getenv_path(CEGUI_ROOT)
  387. getenv_path(PROGRAMFILES)
  388.  
  389. # Determine whether to search for a dynamic or static build
  390. if (CEGUI_STATIC)
  391.     set(CMAKE_FIND_LIBRARY_SUFFIXES_OLD "${CMAKE_FIND_LIBRARY_SUFFIXES}")
  392.     if (WIN32)
  393.         set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll")
  394.     else()
  395.         set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so")
  396.     endif()
  397. endif ()
  398.  
  399. # construct search paths from environmental hints and
  400. # OS specific guesses
  401. if (WIN32)
  402.     set(CEGUI_PREFIX_GUESSES
  403.         ${ENV_PROGRAMFILES}/cegui
  404.         ${ENV_PROGRAMFILES}/CEGUI
  405.         C:/CEGUI-SDK
  406.         C:/lib/cegui
  407.         [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;CEGUI_HOME]
  408.         [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;CEGUI_DIR]
  409.         [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;CEGUI_ROOT]
  410.     )
  411. elseif (UNIX)
  412.     set(CEGUI_PREFIX_GUESSES
  413.         /opt/cegui
  414.         /opt/CEGUI
  415.         /usr
  416.         /usr/local
  417.         /usr/local/include/cegui-0/CEGUI
  418.         /usr/local/include/CEGUI/
  419.         $ENV{HOME}/cegui
  420.         $ENV{HOME}/CEGUI
  421.     )
  422.     if (APPLE)
  423.         set(CEGUI_PREFIX_GUESSES
  424.             ${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx
  425.             ${CEGUI_PREFIX_GUESSES}
  426.         )
  427.     endif ()
  428. endif ()
  429.  
  430. set(CEGUI_PREFIX_PATH
  431.         $ENV{CEGUI_HOME} $ENV{CEGUI_DIR} $ENV{CEGUI_ROOT}
  432.         ${CEGUI_PREFIX_GUESSES}
  433. )
  434.  
  435. # Construct search paths for includes and libraries
  436. create_search_paths(CEGUI)
  437.  
  438.  
  439.  
  440. # try to locate CEGUI via pkg-config
  441. use_pkgconfig(CEGUI_PKGC "CEGUI${CEGUI_LIB_SUFFIX};CEGUI${CEGUI_LIB_SUFFIX}-${CEGUI_VERSION_MAJOR_DEFAULT}")
  442.  
  443. # locate CEGUI include files
  444. find_path(CEGUI_CONFIG_INCLUDE_DIR_PREFIX NAMES CEGUIConfig.h HINTS ${CEGUI_INC_SEARCH_PATH} ${CEGUI_FRAMEWORK_INCLUDES} ${CEGUI_PKGC_INCLUDE_DIRS} PATH_SUFFIXES CEGUI cegui cegui-${CEGUI_VERSION_MAJOR_DEFAULT} cegui-${CEGUI_VERSION_MAJOR_DEFAULT}/CEGUI)
  445. find_path(CEGUI_CONFIG_INCLUDE_DIR NAMES CEGUIConfig.h Config.h HINTS ${CEGUI_INC_SEARCH_PATH} ${CEGUI_FRAMEWORK_INCLUDES} ${CEGUI_PKGC_INCLUDE_DIRS} PATH_SUFFIXES CEGUI cegui cegui-${CEGUI_VERSION_MAJOR_DEFAULT} cegui-${CEGUI_VERSION_MAJOR_DEFAULT}/CEGUI)
  446. find_path(CEGUI_INCLUDE_DIR NAMES CEGUI.h HINTS ${CEGUI_INC_SEARCH_PATH} ${CEGUI_FRAMEWORK_INCLUDES} ${CEGUI_PKGC_INCLUDE_DIRS} PATH_SUFFIXES CEGUI cegui cegui-${CEGUI_VERSION_MAJOR_DEFAULT} cegui-${CEGUI_VERSION_MAJOR_DEFAULT}/CEGUI)
  447.  
  448. set(CEGUI_INCOMPATIBLE FALSE)
  449. if (CEGUI_INCLUDE_DIR)
  450.     # determine CEGUI version
  451.     if(CEGUI_CONFIG_INCLUDE_DIR_PREFIX)
  452.         file(READ ${CEGUI_INCLUDE_DIR}/CEGUIVersion.h CEGUI_TEMP_VERSION_CONTENT)
  453.     else()
  454.         file(READ ${CEGUI_INCLUDE_DIR}/Version.h CEGUI_TEMP_VERSION_CONTENT)
  455.     endif()
  456.  
  457.     if (NOT "${CEGUI_TEMP_VERSION_CONTENT}" STREQUAL "")
  458.         get_preprocessor_entry(CEGUI_TEMP_VERSION_CONTENT CEGUI_VERSION_MAJOR CEGUI_VERSION_MAJOR)
  459.         get_preprocessor_entry(CEGUI_TEMP_VERSION_CONTENT CEGUI_VERSION_MINOR CEGUI_VERSION_MINOR)
  460.         get_preprocessor_entry(CEGUI_TEMP_VERSION_CONTENT CEGUI_VERSION_PATCH CEGUI_VERSION_PATCH)
  461.         get_preprocessor_entry(CEGUI_TEMP_VERSION_CONTENT CEGUI_VERSION_NAME CEGUI_VERSION_NAME)
  462.         set(CEGUI_VERSION "${CEGUI_VERSION_MAJOR}.${CEGUI_VERSION_MINOR}.${CEGUI_VERSION_PATCH}")
  463.         pkg_message(CEGUI "Found CEGUI ${CEGUI_VERSION_NAME} (${CEGUI_VERSION})")
  464.     else()
  465.         message(SEND_ERROR "Can't found CEGUI version !")
  466.         set(CEGUI_INCOMPATIBLE FALSE)
  467.     endif()
  468.  
  469. else ()
  470.     set(CEGUI_INCOMPATIBLE FALSE)
  471. endif ()
  472.  
  473.  
  474. if ("${CEGUI_VERSION}" VERSION_GREATER "0.8.0")
  475.     set(CEGUI_LIB_SUFFIX "-${CEGUI_VERSION_MAJOR}")
  476. endif ()
  477.  
  478.  
  479. set(CEGUI_LIBRARY_NAMES "CEGUIBase${CEGUI_LIB_SUFFIX}")
  480. get_debug_names(CEGUI_LIBRARY_NAMES)
  481. find_library(CEGUI_LIBRARY_REL NAMES ${CEGUI_LIBRARY_NAMES} HINTS ${CEGUI_LIB_SEARCH_PATH} ${CEGUI_PKGC_LIBRARY_DIRS} ${CEGUI_FRAMEWORK_SEARCH_PATH} PATH_SUFFIXES "" "release" "relwithdebinfo" "minsizerel")
  482. find_library(CEGUI_LIBRARY_DBG NAMES ${CEGUI_LIBRARY_NAMES_DBG} HINTS ${CEGUI_LIB_SEARCH_PATH} ${CEGUI_PKGC_LIBRARY_DIRS} ${CEGUI_FRAMEWORK_SEARCH_PATH} PATH_SUFFIXES "" "debug")
  483. make_library_set(CEGUI_LIBRARY)
  484.  
  485.  
  486. if (CEGUI_INCOMPATIBLE)
  487.     set(CEGUI_LIBRARY "NOTFOUND")
  488. endif ()
  489.  
  490. set(CEGUI_INCLUDE_DIR ${CEGUI_CONFIG_INCLUDE_DIR} ${CEGUI_INCLUDE_DIR})
  491. list(REMOVE_DUPLICATES CEGUI_INCLUDE_DIR)
  492. findpkg_finish(CEGUI)
  493.  
  494. # Starting CEGUI 0.8, the headers are in the CEGUI subdirectory, and we must include
  495. # its parent rather than directly the subdirectory. Otherwise we'll get compiler errors.
  496. if ("${CEGUI_VERSION}" VERSION_GREATER "0.8.0")
  497.     add_parent_dir(CEGUI_INCLUDE_DIRS_TEMP CEGUI_INCLUDE_DIR)
  498.     # we basically overwrite CEGUI_INCLUDE_DIR so that it contains only the parent directory.
  499.     set(CEGUI_INCLUDE_DIR ${CEGUI_INCLUDE_DIRS_TEMP})
  500. endif()
  501.  
  502. set(CEGUI_INCLUDE_DIRS ${CEGUI_INCLUDE_DIR})
  503.  
  504. mark_as_advanced(CEGUI_CONFIG_INCLUDE_DIR)
  505.  
  506. if (NOT CEGUI_FOUND)
  507.     return()
  508. endif ()
  509.  
  510.  
  511. get_filename_component(CEGUI_LIBRARY_DIR_REL "${CEGUI_LIBRARY_REL}" PATH)
  512. get_filename_component(CEGUI_LIBRARY_DIR_DBG "${CEGUI_LIBRARY_DBG}" PATH)
  513. set(CEGUI_LIBRARY_DIRS ${CEGUI_LIBRARY_DIR_REL} ${CEGUI_LIBRARY_DIR_DBG})
  514.  
  515.  
  516. # find binaries
  517. if (NOT CEGUI_STATIC)
  518.         if (WIN32)
  519.                 find_file(CEGUI_BINARY_REL NAMES "CEGUIBase${CEGUI_LIB_SUFFIX}.dll" "CEGUIBase.dll" HINTS ${CEGUI_BIN_SEARCH_PATH} PATH_SUFFIXES "" "Release" "RelWithDebInfo" "MinSizeRel")
  520.                 find_file(CEGUI_BINARY_DBG NAMES "CEGUIBase${CEGUI_LIB_SUFFIX}_d.dll" "CEGUIBase_d.dll" HINTS ${CEGUI_BIN_SEARCH_PATH} PATH_SUFFIXES "" "Debug")
  521.         endif()
  522.  
  523.         get_filename_component(CEGUI_BINARY_DIR_REL "${CEGUI_BINARY_REL}" PATH)
  524.         get_filename_component(CEGUI_BINARY_DIR_DBG "${CEGUI_BINARY_DBG}" PATH)
  525.         mark_as_advanced(CEGUI_BINARY_REL CEGUI_BINARY_DBG CEGUI_BINARY_DIR_REL CEGUI_BINARY_DIR_DBG)
  526. endif()
  527.  
  528. if ("${CEGUI_VERSION}" VERSION_GREATER "0.8.0")
  529.     # Base
  530.     cegui_register_module(BASE CommonDialogs CommonDialogs/Module.h "")
  531.  
  532.     # WindowsRenderer
  533.     cegui_register_module(WINDOWSRENDERER CoreWindowRendererSet WindowRendererSets/Core/Module.h "")
  534.  
  535.     # Renderer
  536.     cegui_register_module(RENDERER Direct3D9Renderer RendererModules/Direct3D9/Renderer.h "")
  537.     cegui_register_module(RENDERER Direct3D10Renderer RendererModules/Direct3D10/Renderer.h "")
  538.     cegui_register_module(RENDERER Direct3D11Renderer RendererModules/Direct3D11/Renderer.h "")
  539.     cegui_register_module(RENDERER DirectFBRenderer RendererModules/DirectFB/Renderer.h "")
  540.     cegui_register_module(RENDERER IrrlichtRenderer RendererModules/Irrlicht/Renderer.h "IRRLICHT")
  541.     cegui_register_module(RENDERER NullRenderer RendererModules/Null/Renderer.h "NULL")
  542.     cegui_register_module(RENDERER OgreRenderer RendererModules/Ogre/Renderer.h "OGRE")
  543.     cegui_register_module(RENDERER OpenGLRenderer RendererModules/OpenGL/GLRenderer.h "OPENGL")
  544.     cegui_register_module(RENDERER OpenGL3Renderer RendererModules/OpenGL/GL3Renderer.h "OPENGL3")
  545.     cegui_register_module(RENDERER OpenGLESRenderer RendererModules/OpenGLES/Renderer.h "")
  546.  
  547.     # ImageCodec
  548.     cegui_register_module(IMAGECODEC CoronaImageCodec ImageCodecModules/Corona/ImageCodec.h "")
  549.     cegui_register_module(IMAGECODEC DevILImageCodec ImageCodecModules/DevIL/ImageCodec.h "")
  550.     cegui_register_module(IMAGECODEC FreeImageImageCodec ImageCodecModules/FreeImage/ImageCodec.h "")
  551.     cegui_register_module(IMAGECODEC SILLYImageCodec ImageCodecModules/SILLY/ImageCodec.h "")
  552.     cegui_register_module(IMAGECODEC STBImageCodec ImageCodecModules/STB/ImageCodec.h "")
  553.     cegui_register_module(IMAGECODEC TGAImageCodec ImageCodecModules/TGA/ImageCodec.h "")
  554.     cegui_register_module(IMAGECODEC PVRImageCodec ImageCodecModules/PVR/ImageCodec.h "")
  555.  
  556.     # Parser
  557.     cegui_register_module(PARSER ExpatParser XMLParserModules/Expat/XMLParser.h "")
  558.     cegui_register_module(PARSER LibXMLParser XMLParserModules/Libxml2/XMLParser.h "")
  559.     cegui_register_module(PARSER RapidXMLParser XMLParserModules/RapidXML/XMLParser.h "")
  560.     cegui_register_module(PARSER TinyXMLParser XMLParserModules/TinyXML/XMLParser.h "")
  561.     cegui_register_module(PARSER XercesParser XMLParserModules/Xerces/XMLParser.h "")
  562.  
  563.     # Script
  564.     cegui_register_module(SCRIPT LuaScriptModule ScriptModules/Lua/ScriptModule.h "LUA")
  565.  
  566. else ()
  567.  
  568.     # WindowsRenderer
  569.     cegui_register_module(WINDOWSRENDERER FalagardWRBase "WindowRendererSets/Falagard/FalModule.h;falagard/CEGUIFalNamedArea.h" "")
  570.  
  571.     # Renderer
  572.     cegui_register_module(RENDERER Direct3D9Renderer RendererModules/Direct3D9/CEGUIDirect3D9Renderer.h "")
  573.     cegui_register_module(RENDERER Direct3D10Renderer RendererModules/Direct3D10/CEGUIDirect3D10Renderer.h "")
  574.     cegui_register_module(RENDERER Direct3D11Renderer RendererModules/Direct3D11/CEGUIDirect3D11Renderer.h "")
  575.     cegui_register_module(RENDERER DirectFBRenderer RendererModules/DirectFB/CEGUIDirectFBRenderer.h "")
  576.     cegui_register_module(RENDERER IrrlichtRenderer RendererModules/Irrlicht/CEGUIIrrlichtRenderer.h "")
  577.     cegui_register_module(RENDERER NullRenderer RendererModules/Null/CEGUINullRenderer.h "NULL")
  578.     cegui_register_module(RENDERER OgreRenderer RendererModules/Ogre/CEGUIOgreRenderer.h "OGRE")
  579.     cegui_register_module(RENDERER OpenGLRenderer RendererModules/OpenGL/CEGUIOpenGLRenderer.h "OPENGL")
  580.  
  581.     # ImageCodec
  582.     cegui_register_module(IMAGECODEC CoronaImageCodec ImageCodecModules/CoronaImageCodec/CEGUICoronaImageCodec.h "")
  583.     cegui_register_module(IMAGECODEC DevILImageCodec ImageCodecModules/DevILImageCodec/CEGUIDevILImageCodec.h "")
  584.     cegui_register_module(IMAGECODEC FreeImageImageCodec ImageCodecModules/FreeImageImageCodec/CEGUIFreeImageImageCodec.h "")
  585.     cegui_register_module(IMAGECODEC SILLYImageCodec ImageCodecModules/SILLYImageCodec/CEGUISILLYImageCodec.h "")
  586.     cegui_register_module(IMAGECODEC STBImageCodec ImageCodecModules/STBImageCodec/CEGUISTBImageCodec.h "")
  587.     cegui_register_module(IMAGECODEC TGAImageCodec ImageCodecModules/TGAImageCodec/CEGUITGAImageCodec.h "")
  588.  
  589.     # Parser
  590.     cegui_register_module(PARSER ExpatParser XMLParserModules/ExpatParser/CEGUIExpatParser.h "")
  591.     cegui_register_module(PARSER LibxmlParser XMLParserModules/LibxmlParser/CEGUILibxmlParser.h "")
  592.     cegui_register_module(PARSER RapidXMLParser XMLParserModules/RapidXMLParser/CEGUIRapidXMLParser.h "")
  593.     cegui_register_module(PARSER TinyXMLParser XMLParserModules/TinyXMLParser/CEGUITinyXMLParser.h "")
  594.     cegui_register_module(PARSER XercesParser XMLParserModules/XercesParser/CEGUIXercesParser.h "")
  595.  
  596.     # Script
  597.     cegui_register_module(SCRIPT LuaScriptModule ScriptingModules/LuaScriptModule/CEGUILua.h "")
  598.  
  599.     if(WIN32)
  600.         cegui_register_module(SCRIPT tolua++ ScriptingModules/LuaScriptModule/support/tolua++/tolua++.h "")
  601.         set(CEGUI_SCRIPT_MODULES_tolua++_CHECKNOPREFIX TRUE)
  602.     else()
  603.         cegui_register_module(SCRIPT toluapp ScriptingModules/LuaScriptModule/support/tolua++/tolua++.h "")
  604.     endif()
  605.  
  606. endif ()
  607.  
  608.  
  609. # Register var to check change on modules
  610. set(CEGUI_RESET_MODULES_VARS "")
  611. foreach (comp ${CEGUI_MODULES})
  612.     set(CEGUI_RESET_MODULES_VARS ${CEGUI_RESET_MODULES_VARS}
  613.         CEGUI_${comp}_INCLUDE_DIR CEGUI_${comp}_LIBRARY_FWK
  614.         CEGUI_${comp}_LIBRARY_DBG CEGUI_${comp}_LIBRARY_REL
  615.     )
  616. endforeach (comp)
  617. set(CEGUI_PREFIX_MODULES_WATCH ${CEGUI_PREFIX_MODULES_PATH})
  618. clear_if_changed(CEGUI_PREFIX_WATCH ${CEGUI_RESET_MODULES_VARS})
  619.  
  620.  
  621. # Find modules
  622. cegui_find_modules(BASE)
  623. cegui_find_modules(WINDOWSRENDERER)
  624. cegui_find_modules(RENDERER)
  625. cegui_find_modules(IMAGECODEC)
  626. cegui_find_modules(PARSER)
  627. cegui_find_modules(SCRIPT)
  628.  
  629.  
  630. # Find modules
  631. if (CEGUI_STATIC)
  632.     set(CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES_OLD}")
  633. endif()
  634.  
  635.  
  636. #Check change on modules
  637. clear_if_changed(CEGUI_PREFIX_WATCH)
  638. clear_if_changed(CEGUI_PREFIX_MODULES_WATCH)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top