Page 1 of 1

findCEGUI.cmake

Posted: Thu Jul 21, 2011 20:45
by osbios
I made myself a cmake find script for CEGUI 7.5. It is bassed on a simpler find script that didn't do all what I wanted it to do.

How to use:
Copy this in a file called findCEGUI.cmake

And before you all copy findCEGUI.cmake in your cmake module directory here is a much more elegant way:

Create a directory like "cmake_modules" in you project directory and move the "findCEGUI.cmake" there.

Then add the line set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules") to your "CMakeLists.txt".
Now you can use it with the regular Find_Package(CEGUI REQUIRED COMPONENTS OPENGL).

This is very useful because people that compile your project dont have to copy around the "findCEGUI.cmake" script.

Code: Select all

# Locate CEGUI (Made for CEGUI 7.5)
#
# This module defines
# CEGUI_FOUND, if false, do not try to link to CEGUI
# CEGUI_LIBRARY, where to find the librarys
# CEGUI_INCLUDE_DIR, where to find the headers
#
# $CEGUIDIR is an environment variable that would
# correspond to the ./configure --prefix=$CEGUIDIR
#
# There are several COMPONENTS that can be included:
# NULL, OPENGL, DIRECT3D9, DIRECT3D10, DIRECT3D11, DIRECTFB, OGRE, IRRLICHT
# Selecting no render as COMPONENT will create a error massage!
#
# 2011-07-21 Created by Frederik vom Hofe using the findSFML.cmake versions from David Guthrie with code from Robert Osfield.

SET(CEGUI_FOUND "YES")
SET(CEGUI_LIBRARY "")
SET(CEGUI_INCLUDE_DIR "")

SET( CEGUIDIR $ENV{CEGUIDIR} )
IF((WIN32 OR WIN64) AND NOT(CYGWIN))
   # Convert backslashes to slashes
   STRING(REGEX REPLACE "\\\\" "/" CEGUIDIR "${CEGUIDIR}")
ENDIF()


#To always have the right case sensitive name we use this list and a helper macro:
SET(RENDER_NAME
   Null
   OpenGL
   Direct3D9
   Direct3D10
   Direct3D11
   DirectFB
   Ogre
   Irrlicht
)

MACRO(HELPER_GET_CASE_FROM_LIST SEARCHSTR LOOKUPLIST RESULTSTR)
   SET(${RESULTSTR} ${SEARCHSTR}) #default return value if nothing is found
   FOREACH(LOOP_S IN LISTS ${LOOKUPLIST})
      string(TOLOWER ${LOOP_S} LOOP_S_LOWER)
      string(TOLOWER ${SEARCHSTR} LOOP_SEARCHSTR_LOWER)
      string(COMPARE EQUAL ${LOOP_S_LOWER} ${LOOP_SEARCHSTR_LOWER} LOOP_STR_COMPARE)
      IF(LOOP_STR_COMPARE)
         SET(${RESULTSTR} ${LOOP_S})
      ENDIF()
   ENDFOREACH()
ENDMACRO()

#********** First we locate the include directorys ********** ********** ********** **********
SET( CEGUI_INCLUDE_SEARCH_DIR
   ${CEGUIDIR}/include
   ${CEGUIDIR}/cegui/include
   ~/Library/Frameworks
   /Library/Frameworks
   /usr/local/include
   /usr/include
   /sw/include # Fink
   /opt/local/include # DarwinPorts
   /opt/csw/include # Blastwave
   /opt/include
   /usr/freeware/include
)

#helper
MACRO(FIND_PATH_HELPER FILENAME DIR SUFFIX)
   FIND_PATH(${FILENAME}_DIR ${FILENAME} PATHS ${${DIR}} PATH_SUFFIXES ${SUFFIX})
   IF(NOT ${FILENAME}_DIR)
      MESSAGE("Could not located ${FILENAME}")
      SET(CEGUI_FOUND "NO")
   ELSE()
      MESSAGE("${FILENAME} : ${${FILENAME}_DIR}")
      LIST(APPEND CEGUI_INCLUDE_DIR ${${FILENAME}_DIR})
   ENDIF()
ENDMACRO()

FIND_PATH_HELPER(CEGUI.h CEGUI_INCLUDE_SEARCH_DIR CEGUI)

IF("${CEGUI_FIND_COMPONENTS}" STREQUAL "")
   MESSAGE("ERROR: No CEGUI renderer selected. \n\nSelect a renderer by including it's name in the component list:\n\ne.g. Find_Package(CEGUI REQUIRED COMPONENTS OPENGL)\n\nCEGUI renderers:")
   FOREACH(LOOP_S IN LISTS RENDER_NAME)
      MESSAGE("${LOOP_S}")
   ENDFOREACH()
   MESSAGE("\n")
   MESSAGE(SEND_ERROR "Select at last one renderer!" )
ENDIF()

FOREACH(COMPONENT ${CEGUI_FIND_COMPONENTS})
   HELPER_GET_CASE_FROM_LIST( ${COMPONENT} RENDER_NAME COMPONENT_CASE)
   FIND_PATH_HELPER( "CEGUI${COMPONENT_CASE}Renderer.h" "CEGUI_INCLUDE_SEARCH_DIR" "CEGUI/RendererModules/${COMPONENT_CASE}/;RendererModules/${COMPONENT_CASE}/" )
ENDFOREACH(COMPONENT)

IF (APPLE)
   FIND_PATH(CEGUI_FRAMEWORK_DIR CEGUI.h
     PATHS
       ~/Library/Frameworks/CEGUI.framework/Headers
       /Library/Frameworks/CEGUI.framework/Headers
       ${DELTA3D_EXT_DIR}/Frameworks/CEGUI.framework/Headers
)
ENDIF (APPLE)

IF(CEGUI_FRAMEWORK_DIR)
   LIST(APPEND CEGUI_INCLUDE_DIR ${CEGUI_FRAMEWORK_DIR})
ELSE()
   LIST(APPEND CEGUI_INCLUDE_DIR ${CEGUI_FRAMEWORK_DIR}/CEGUI)
ENDIF()


#********** Then we locate the Librarys ********** ********** ********** **********
SET( CEGUI_LIBRARY_SEARCH_DIR
   ${CEGUIDIR}/lib
        ${CEGUIDIR}
        ~/Library/Frameworks
        /Library/Frameworks
        /usr/local/lib
        /usr/lib
        /sw/lib
        /opt/local/lib
        /opt/csw/lib
        /opt/lib
        [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;CEGUI_ROOT]/lib
        /usr/freeware/lib64
)

#helper
MACRO(FIND_LIBRARY_HELPER FILENAME DIR)
   FIND_LIBRARY(${FILENAME}_DIR NAMES ${FILENAME} PATHS ${${DIR}})
   IF(NOT ${FILENAME}_DIR)
      MESSAGE("Could not located ${FILENAME}")
      SET(CEGUI_FOUND "NO")
   ELSE()
      MESSAGE("${FILENAME} : ${${FILENAME}_DIR}")
      LIST(APPEND CEGUI_LIBRARY ${${FILENAME}_DIR})
   ENDIF()
ENDMACRO()

FIND_LIBRARY_HELPER( CEGUIBase CEGUI_LIBRARY_SEARCH_DIR )

FOREACH(COMPONENT ${CEGUI_FIND_COMPONENTS})
   HELPER_GET_CASE_FROM_LIST( ${COMPONENT} RENDER_NAME COMPONENT_CASE)
   MESSAGE("Looking for lib: CEGUI${COMPONENT_CASE}Renderer")
   FIND_LIBRARY_HELPER( CEGUI${COMPONENT_CASE}Renderer "CEGUI_LIBRARY_SEARCH_DIR" CEGUI)
ENDFOREACH(COMPONENT)

#********** And we are done ********** ********** ********** ********** ********** ********** ********** **********

IF(NOT CEGUI_FOUND)
   MESSAGE(SEND_ERROR "Error(s) during CEGUI dedection!")
ENDIF()

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CEGUI DEFAULT_MSG CEGUI_LIBRARY CEGUI_INCLUDE_DIR)

Re: findCEGUI.cmake

Posted: Sun Jul 24, 2011 16:45
by Kulik
Cool, thanks for the contrib

I am thinking of shipping FindCEGUI with CEGUI 0.8 (we only use pkg-config there right now).

Re: findCEGUI.cmake

Posted: Tue Aug 09, 2011 13:28
by jacmoe
It works really well - thanks! :)

Re: findCEGUI.cmake

Posted: Wed Oct 12, 2011 01:18
by MrSteam
I found this little gem a little bit ago and have been using it since, but the mass renaming that recently occurred in the trunk broke it. The following tiny change seems to be all that is required to be able to find the renderer module headers again.

Enjoy.

Code: Select all

diff --git a/cmake/FindCEGUI.cmake b/cmake/FindCEGUI.cmake
index 03d028a..9743d9c 100644
--- a/cmake/FindCEGUI.cmake
+++ b/cmake/FindCEGUI.cmake
@@ -65,8 +65,8 @@ SET( CEGUI_INCLUDE_SEARCH_DIR
 )
 
 #helper
-MACRO(FIND_PATH_HELPER FILENAME DIR)
-   FIND_PATH(${FILENAME}_DIR ${FILENAME} PATHS ${${DIR}} PATH_SUFFIXES)
+MACRO(FIND_PATH_HELPER FILENAME DIR SUFFIX)
+   FIND_PATH(${FILENAME}_DIR ${FILENAME} PATHS ${${DIR}} PATH_SUFFIXES ${SUFFIX})
    IF(NOT ${FILENAME}_DIR)
       MESSAGE("Could not located ${FILENAME}")
       SET(CEGUI_FOUND "NO")
@@ -76,7 +76,7 @@ MACRO(FIND_PATH_HELPER FILENAME DIR)
    ENDIF()
 ENDMACRO()
 
-FIND_PATH_HELPER(CEGUI/CEGUI.h CEGUI_INCLUDE_SEARCH_DIR)
+FIND_PATH_HELPER(CEGUI.h CEGUI_INCLUDE_SEARCH_DIR CEGUI)
 
 IF("${CEGUI_FIND_COMPONENTS}" STREQUAL "")
    MESSAGE("ERROR: No CEGUI renderer selected. \n\nSelect a renderer by including it's name in the component list:\n\ne.g. Find_Package(CEGUI REQUIRED COMPONENTS OPENGL)\n\nCEGUI renderers:")
@@ -89,7 +89,7 @@ ENDIF()
 
 FOREACH(COMPONENT ${CEGUI_FIND_COMPONENTS})
    HELPER_GET_CASE_FROM_LIST( ${COMPONENT} RENDER_NAME COMPONENT_CASE)
-   FIND_PATH_HELPER( "Renderer.h" "CEGUI_INCLUDE_SEARCH_DIR" "CEGUI/RendererModules/${COMPONENT_CASE}/;RendererModules/${COMPONENT_CASE}/" )
+   FIND_PATH_HELPER( "CEGUI${COMPONENT_CASE}Renderer.h" "CEGUI_INCLUDE_SEARCH_DIR" "CEGUI/RendererModules/${COMPONENT_CASE}/;RendererModules/${COMPONENT_CASE}/" )
 ENDFOREACH(COMPONENT)
 
 IF (APPLE)


Edit: Turns out there were changes required to get the includes right too.

Re: findCEGUI.cmake

Posted: Wed Jul 31, 2013 17:58
by tyrolite
I found a similar script on Ogre forums: http://linode.ogre3d.org/forums/viewtopic.php?f=2&t=70205

This script was working with the older versions of CEGUI (0.7.x) and I made it to work for 0.8.x . I tested it and it works fine on my archlinux machine and on a win XP SP3 virtual machine, but there is a drawback: it depends on two cmake modules provided with the OGRE SDK(FindPkgMacros and PreprocessorUtils). If you're using CEGUI with OGRE then it should work right out of the box, otherwise you should copy those modules in your CMAKE_MODULES_PATH .

Here's the updated FindCEGUI.cmake script:

Code: Select all

# - Locate CEGUI LIBRARIES
# This module defines
#  CEGUI_FOUND, if false, do not try to link to CEGUI
#  CEGUI_INCLUDE_DIR, where to find headers.
#  CEGUI_LIBRARIES, the LIBRARIES to link against
#  CEGUI_BINARY_REL - location of the main CEGUI binary (win32 non-static only, release)
#  CEGUI_BINARY_DBG - location of the main CEGUI binaries (win32 non-static only, debug)
#
#
#    Modules :
#  CEGUI_${COMPONENT}_FOUND - ${COMPONENT} is available
#  CEGUI_${COMPONENT}_INCLUDE_DIRS - additional include directories for ${COMPONENT}
#  CEGUI_${COMPONENT}_LIBRARIES - link these to use ${COMPONENT}
#  CEGUI_${COMPONENT}_BINARY_REL - location of the component binary (win32 non-static only, release)
#  CEGUI_${COMPONENT}_BINARY_DBG - location of the component binary (win32 non-static only, debug)
#
#   WindowsRenderer:
#      Falagard
#   Renderer:
#      Direct3D9Renderer Direct3D10Renderer Direct3D11Renderer IrrlichtRenderer NullRenderer OgreRenderer OpenGLRenderer
#   ImageCodec:
#      CoronaImageCodec DevILImageCodec FreeImageImageCodec SILLYImageCodec STBImageCodec TGAImageCodec
#   Parser:
#      ExpatParser LibXMLParser RapidXMLParser TinyXMLParser XercesParser)
#   Script:
#      LuaScriptModule
     
include(FindPkgMacros)
include(PreprocessorUtils)

# Print component specific variables
macro(PRINT_COMPONENT_INFO COMPONENT)
    message(
          "${COMPONENT}_FOUND : " ${CEGUI_${COMPONENT}_FOUND} "\n"
          "${COMPONENT}_INCLUDE_DIRS: " ${CEGUI_${COMPONENT}_INCLUDE_DIRS} "\n"
          "${COMPONENT}_LIBRARIES: " ${CEGUI_${COMPONENT}_LIBRARIES} "\n"
          "${COMPONENT}_BINARY_REL: " ${CEGUI_${COMPONENT}_BINARY_REL} "\n"
          "${COMPONENT}_BINARY_DBG: " ${CEGUI_${COMPONENT}_BINARY_DBG} "\n"
    )
endmacro(PRINT_COMPONENT_INFO)

findpkg_begin(CEGUI)
set(CEGUI_FIND_REQUIRED 1)
 
# Get path, convert backslashes as ${ENV_${var}}
getenv_path(CEGUI_HOME)
getenv_path(CEGUI_DIR)
getenv_path(CEGUI_ROOT)
getenv_path(PROGRAMFILES)
 
# Determine whether to search for a dynamic or static build
if (CEGUI_STATIC)
  set(CEGUI_LIB_SUFFIX "_Static")
else ()
  set(CEGUI_LIB_SUFFIX "")
endif ()
 
set(CEGUI_LIBRARY_NAMES "CEGUIBase${CEGUI_LIB_SUFFIX}")
get_debug_names(CEGUI_LIBRARY_NAMES)
 
# construct search paths from environmental hints and
# OS specific guesses
if (WIN32)
  set(CEGUI_PREFIX_GUESSES
    ${ENV_PROGRAMFILES}/cegui
    ${ENV_PROGRAMFILES}/CEGUI
    C:/CEGUI-SDK
    C:/lib/cegui
    [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;CEGUI_HOME]
    [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;CEGUI_DIR]
    [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;CEGUI_ROOT]
  )
elseif (UNIX)
  set(CEGUI_PREFIX_GUESSES
    /opt/cegui
    /opt/CEGUI
    /usr
    /usr/local
    $ENV{HOME}/cegui
    $ENV{HOME}/CEGUI
  )
endif ()
 
set(CEGUI_PREFIX_PATH
   $ENV{CEGUI_HOME} $ENV{CEGUI_DIR} $ENV{CEGUI_ROOT}
   ${CEGUI_PREFIX_GUESSES}
)
 
create_search_paths(CEGUI)
 
# redo search if any of the environmental hints changed
set(CEGUI_WINDOWSRENDERER_COMPONENTS
   CoreWindowRendererSet
)
set(CEGUI_RENDERER_COMPONENTS
   Direct3D9Renderer Direct3D10Renderer Direct3D11Renderer IrrlichtRenderer NullRenderer OgreRenderer OpenGLRenderer
)
set(CEGUI_IMAGECODEC_COMPONENTS
   CoronaImageCodec DevILImageCodec FreeImageImageCodec SILLYImageCodec STBImageCodec TGAImageCodec
)
set(CEGUI_PARSER_COMPONENTS
   ExpatParser LibXMLParser RapidXMLParser TinyXMLParser XercesParser
)
set(CEGUI_SCRIPT_COMPONENTS
   LuaScriptModule
)
set(CEGUI_COMPONENTS ${CEGUI_WINDOWSRENDERER_COMPONENTS} ${CEGUI_RENDERER_COMPONENTS} ${CEGUI_IMAGECODEC_COMPONENTS} ${CEGUI_PARSER_COMPONENTS} ${CEGUI_SCRIPT_COMPONENTS})
 
set(CEGUI_RESET_VARS
  CEGUI_CONFIG_INCLUDE_DIR CEGUI_INCLUDE_DIR
  CEGUI_LIBRARY_REL CEGUI_LIBRARY_DBG
)
 
foreach (comp ${CEGUI_COMPONENTS})
  set(CEGUI_RESET_VARS ${CEGUI_RESET_VARS}
    CEGUI_${comp}_INCLUDE_DIR CEGUI_${comp}_LIBRARY_FWK
    CEGUI_${comp}_LIBRARY_DBG CEGUI_${comp}_LIBRARY_REL
  )
endforeach (comp)
set(CEGUI_PREFIX_WATCH ${CEGUI_PREFIX_PATH})
clear_if_changed(CEGUI_PREFIX_WATCH ${CEGUI_RESET_VARS})
 
# try to locate CEGUI via pkg-config
use_pkgconfig(CEGUI_PKGC "CEGUI${CEGUI_LIB_SUFFIX}")

#message("CEGUI_INC_SEARCH_PATH:" ${CEGUI_INC_SEARCH_PATH})
#message("CEGUI_FRAMEWORK_INCLUDES:" ${CEGUI_FRAMEWORK_INCLUDES})
#message("CEGUI_PKGC_INCLUDE_DIRS:" ${CEGUI_PKGC_INCLUDE_DIRS})
 
# locate CEGUI include files
find_path(CEGUI_CONFIG_INCLUDE_DIR NAMES Config.h
          HINTS ${CEGUI_INC_SEARCH_PATH} ${CEGUI_FRAMEWORK_INCLUDES} ${CEGUI_PKGC_INCLUDE_DIRS}
        PATH_SUFFIXES "" "CEGUI" "cegui-0/CEGUI")

find_path(CEGUI_INCLUDE_DIR NAMES CEGUI.h
          HINTS ${CEGUI_INC_SEARCH_PATH} ${CEGUI_FRAMEWORK_INCLUDES} ${CEGUI_PKGC_INCLUDE_DIRS}
        PATH_SUFFIXES "" "CEGUI" "cegui-0/CEGUI")
set(CEGUI_INCOMPATIBLE FALSE)   
 
if (CEGUI_INCLUDE_DIR)
  # determine CEGUI version
  file(READ ${CEGUI_INCLUDE_DIR}/Version.h CEGUI_TEMP_VERSION_CONTENT)
  get_preprocessor_entry(CEGUI_TEMP_VERSION_CONTENT CEGUI_VERSION_MAJOR CEGUI_VERSION_MAJOR)
  get_preprocessor_entry(CEGUI_TEMP_VERSION_CONTENT CEGUI_VERSION_MINOR CEGUI_VERSION_MINOR)
  get_preprocessor_entry(CEGUI_TEMP_VERSION_CONTENT CEGUI_VERSION_PATCH CEGUI_VERSION_PATCH)
  get_preprocessor_entry(CEGUI_TEMP_VERSION_CONTENT CEGUI_VERSION_NAME CEGUI_VERSION_NAME)
  set(CEGUI_VERSION "${CEGUI_VERSION_MAJOR}.${CEGUI_VERSION_MINOR}.${CEGUI_VERSION_PATCH}")
  pkg_message(CEGUI "Found CEGUI headers ${CEGUI_VERSION_NAME} (${CEGUI_VERSION})")
  pkg_message(CEGUI "Include dir: " ${CEGUI_INCLUDE_DIR})
 
  #set(CEGUI_VERSION "0.7.9")
  if ((${CEGUI_VERSION} VERSION_GREATER "0.8.0") OR (${CEGUI_VERSION} VERSION_EQUAL "0.8.0"))
     set(CEGUI_LIBRARY_NAMES "CEGUIBase-${CEGUI_VERSION_MAJOR}${CEGUI_LIB_SUFFIX}")
  else()
   set(CEGUI_INCOMPATIBLE TRUE)
   message(FATAL_ERROR "CEGUI version 0.8.0 or greater required !")
  endif()
 
  # determine configuration settings
  set(CEGUI_CONFIG_HEADERS
    ${CEGUI_CONFIG_INCLUDE_DIR}/Config.h
  )
  set(CEGUI_CONFIG_HEADER NOTFOUND)
  foreach(CFG_FILE ${CEGUI_CONFIG_HEADERS})
    if (EXISTS ${CFG_FILE})
      set(CEGUI_CONFIG_HEADER ${CFG_FILE}) # take the first config header from headers
      break()
    endif()
  endforeach()

  #message("Config header:" ${CEGUI_CONFIG_HEADER})
 
  if (CEGUI_CONFIG_HEADER)
    file(READ ${CEGUI_CONFIG_HEADER} CEGUI_TEMP_CONFIG_CONTENT)
    has_preprocessor_entry(CEGUI_TEMP_CONFIG_CONTENT CEGUI_STATIC_LIB CEGUI_CONFIG_STATIC)
    get_preprocessor_entry(CEGUI_TEMP_CONFIG_CONTENT CEGUI_THREAD_SUPPORT CEGUI_CONFIG_THREADS)
    get_preprocessor_entry(CEGUI_TEMP_CONFIG_CONTENT CEGUI_THREAD_PROVIDER CEGUI_CONFIG_THREAD_PROVIDER)
    get_preprocessor_entry(CEGUI_TEMP_CONFIG_CONTENT CEGUI_NO_FREEIMAGE CEGUI_CONFIG_FREEIMAGE)
    if (CEGUI_CONFIG_STATIC AND CEGUI_STATIC)
    elseif (CEGUI_CONFIG_STATIC OR CEGUI_STATIC)
      pkg_message(CEGUI "Build type (static, dynamic) does not match the requested one.")
      set(CEGUI_INCOMPATIBLE TRUE)
    endif ()
  else ()
    pkg_message(OGRE "Could not determine Ogre build configuration.")
    set(CEGUI_INCOMPATIBLE TRUE)
  endif ()
else ()
  set(CEGUI_INCOMPATIBLE FALSE)
endif ()

#message("Library names: " ${CEGUI_LIBRARY_NAMES})
#message("CEGUI_LIB_SEARCH_PATH: " ${CEGUI_LIB_SEARCH_PATH})
 
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")

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")

#message("CEGUI_LIBRARY_REL : " ${CEGUI_LIBRARY_REL})
#message("CEGUI_FOUND : " ${CEGUI_FOUND})
make_library_set(CEGUI_LIBRARY)
 
if (CEGUI_INCOMPATIBLE)
  set(CEGUI_LIBRARY "NOTFOUND")
endif ()

#message("CEGUI_INCOMPATIBLE : " ${CEGUI_INCOMPATIBLE})
#message("CEGUI_LIBRARY : " ${CEGUI_LIBRARY})
 
set(CEGUI_INCLUDE_DIR ${CEGUI_CONFIG_INCLUDE_DIR} ${CEGUI_INCLUDE_DIR})
list(REMOVE_DUPLICATES CEGUI_INCLUDE_DIR)
findpkg_finish(CEGUI)
add_parent_dir(CEGUI_INCLUDE_DIRS CEGUI_INCLUDE_DIR)
 
mark_as_advanced(CEGUI_CONFIG_INCLUDE_DIR)
 
if (NOT CEGUI_FOUND)
  return()
endif ()
     
get_filename_component(CEGUI_LIBRARY_DIR_REL "${CEGUI_LIBRARY_REL}" PATH)
get_filename_component(CEGUI_LIBRARY_DIR_DBG "${CEGUI_LIBRARY_DBG}" PATH)
set(CEGUI_LIBRARY_DIRS ${CEGUI_LIBRARY_DIR_REL} ${CEGUI_LIBRARY_DIR_DBG})

#message("lib dirs0:" ${CEGUI_LIBRARY_DIRS})

# find binaries WIN32
if (NOT CEGUI_STATIC)
   #message("not static" ${CEGUI_BIN_SEARCH_PATH})
   if (WIN32)
      find_file(CEGUI_BINARY_REL NAMES "CEGUIBase-${CEGUI_VERSION_MAJOR}.dll"
                HINTS ${CEGUI_BIN_SEARCH_PATH}
                PATH_SUFFIXES "" release relwithdebinfo minsizerel)
      find_file(CEGUI_BINARY_DBG NAMES "CEGUIBase${CEGUI_VERSION_MAJOR}_d.dll"
                HINTS ${CEGUI_BIN_SEARCH_PATH}
                PATH_SUFFIXES "" debug )

      get_filename_component(CEGUI_BINARY_DIR_REL "${CEGUI_BINARY_REL}" PATH)
      get_filename_component(CEGUI_BINARY_DIR_DBG "${CEGUI_BINARY_DBG}" PATH)

      set(CEGUI_LIBRARY_DIRS ${CEGUI_BINARY_DIR_REL} ${CEGUI_BINARY_DIR_DBG})
     
   else () # UNIX and APPLE
      set(CEGUI_BINARY_REL NOTFOUND)
      set(CEGUI_BINARY_DBG NOTFOUND)
      set(CEGUI_BINARY_DIR_REL NOTFOUND)
      set(CEGUI_BINARY_DIR_DBG NOTFOUND)             
   endif()
      mark_as_advanced(CEGUI_BINARY_REL CEGUI_BINARY_DBG CEGUI_BINARY_DIR_REL CEGUI_BINARY_DIR_DBG)
endif()

#message("lib dirs1:" ${CEGUI_LIBRARY_DIRS})
 
# look for CoreWindowRendererSet component
findpkg_begin(CEGUI_CoreWindowRendererSet)
find_path(CEGUI_Falagard_INCLUDE_DIR NAMES NamedArea.h
          HINTS ${CEGUI_INCLUDE_DIRS}
          PATH_SUFFIXES falagard CEGUI/falagard)

find_path(CEGUI_CoreWindowRendererSet_INCLUDE_DIR NAMES Module.h
          HINTS ${CEGUI_INCLUDE_DIRS}
          PATH_SUFFIXES WindowRendererSets/Core CEGUI/WindowRendererSets/Core)

set(CEGUI_CoreWindowRendererSet_INCLUDE_DIR ${CEGUI_CoreWindowRendererSet_INCLUDE_DIR} ${CEGUI_Falagard_INCLUDE_DIR})
set(CEGUI_CoreWindowRendererSet_LIBRARY_NAMES "CEGUICoreWindowRendererSet${CEGUI_LIB_SUFFIX}")
get_debug_names(CEGUI_CoreWindowRendererSet_LIBRARY_NAMES)
find_library(CEGUI_CoreWindowRendererSet_LIBRARY_REL NAMES ${CEGUI_CoreWindowRendererSet_LIBRARY_NAMES}
             HINTS ${CEGUI_LIBRARY_DIR_REL} ${CEGUI_LIBRARY_DIR_REL}/cegui-${CEGUI_VERSION_MAJOR}.${CEGUI_VERSION_MINOR}
             PATH_SUFFIXES "" "release" "relwithdebinfo" "minsizerel")

find_library(CEGUI_CoreWindowRendererSet_LIBRARY_DBG NAMES ${CEGUI_CoreWindowRendererSet_LIBRARY_NAMES_DBG}
             HINTS ${CEGUI_LIBRARY_DIR_DBG} ${CEGUI_LIBRARY_DIR_DBG}/cegui-${CEGUI_VERSION_MAJOR}.${CEGUI_VERSION_MINOR}
             PATH_SUFFIXES "" "debug")
make_library_set(CEGUI_CoreWindowRendererSet_LIBRARY)
findpkg_finish(CEGUI_CoreWindowRendererSet)

#PRINT_COMPONENT_INFO(CoreWindowRendererSet)
 
#Search renderer components
foreach (comp ${CEGUI_RENDERER_COMPONENTS})
    findpkg_begin(CEGUI_${comp})
    string(REPLACE "Renderer" "" compName ${comp})
    #message("compName:" ${compName})
    find_path(CEGUI_${comp}_INCLUDE_DIR NAMES Renderer.h
              HINTS ${CEGUI_INCLUDE_DIRS}
              PATH_SUFFIXES RendererModules/${compName} CEGUI/RendererModules/${compName})

    #message("comp incl dir:" ${CEGUI_${comp}_INCLUDE_DIR})
    set(CEGUI_${comp}_LIBRARY_NAMES "CEGUI${comp}-${CEGUI_VERSION_MAJOR}${CEGUI_LIB_SUFFIX}")
    get_debug_names(CEGUI_${comp}_LIBRARY_NAMES)

    #message("renderer stuff:" ${CEGUI_${comp}_LIBRARY_NAMES} "|" ${CEGUI_LIBRARY_DIR_REL})
    find_library(CEGUI_${comp}_LIBRARY_REL NAMES ${CEGUI_${comp}_LIBRARY_NAMES}
                 HINTS ${CEGUI_LIBRARY_DIR_REL}
                 PATH_SUFFIXES "" "release" "relwithdebinfo" "minsizerel")

    find_library(CEGUI_${comp}_LIBRARY_DBG NAMES ${CEGUI_${comp}_LIBRARY_NAMES_DBG}
                 HINTS ${CEGUI_LIBRARY_DIR_DBG}
                 PATH_SUFFIXES "" "debug")

    make_library_set(CEGUI_${comp}_LIBRARY)
    findpkg_finish(CEGUI_${comp})
 
    #PRINT_COMPONENT_INFO(${comp})
endforeach (comp)

#Search image codec components
foreach (comp ${CEGUI_IMAGECODEC_COMPONENTS})
    findpkg_begin(CEGUI_${comp})
    find_path(CEGUI_${comp}_INCLUDE_DIR NAMES ImageCodec.h
              HINTS ${CEGUI_INCLUDE_DIRS}
              PATH_SUFFIXES ImageCodecModules/${comp} CEGUI/ImageCodecModules/${comp})

    set(CEGUI_${comp}_LIBRARY_NAMES "CEGUI${comp}${CEGUI_LIB_SUFFIX}")
    get_debug_names(CEGUI_${comp}_LIBRARY_NAMES)

    #message("image codec stuff: " ${CEGUI_${comp}_LIBRARY_NAMES} ${CEGUI_LIBRARY_DIR_REL})
    find_library(CEGUI_${comp}_LIBRARY_REL NAMES ${CEGUI_${comp}_LIBRARY_NAMES}
                 HINTS ${CEGUI_LIBRARY_DIR_REL} ${CEGUI_LIBRARY_DIR_REL}/cegui-${CEGUI_VERSION_MAJOR}.${CEGUI_VERSION_MINOR}
                 PATH_SUFFIXES "" "release" "relwithdebinfo" "minsizerel")

    find_library(CEGUI_${comp}_LIBRARY_DBG NAMES ${CEGUI_${comp}_LIBRARY_NAMES_DBG}
                 HINTS ${CEGUI_LIBRARY_DIR_DBG} ${CEGUI_LIBRARY_DIR_DBG}/cegui-${CEGUI_VERSION_MAJOR}.${CEGUI_VERSION_MINOR}
                 PATH_SUFFIXES "" "debug")

    make_library_set(CEGUI_${comp}_LIBRARY)
    findpkg_finish(CEGUI_${comp})

    #PRINT_COMPONENT_INFO(${comp})
endforeach (comp)

#Search parser components
foreach (comp ${CEGUI_PARSER_COMPONENTS})
    findpkg_begin(CEGUI_${comp})
    find_path(CEGUI_${comp}_INCLUDE_DIR NAMES XMLParser.h
              HINTS ${CEGUI_INCLUDE_DIRS}
              PATH_SUFFIXES XMLParserModules/${comp} CEGUI/XMLParserModules/${comp} )
   
    set(CEGUI_${comp}_LIBRARY_NAMES "CEGUI${comp}${CEGUI_LIB_SUFFIX}")
    get_debug_names(CEGUI_${comp}_LIBRARY_NAMES)

    #message("parser stuff: " ${CEGUI_${comp}_LIBRARY_NAMES} )
    find_library(CEGUI_${comp}_LIBRARY_REL NAMES ${CEGUI_${comp}_LIBRARY_NAMES}
                 HINTS ${CEGUI_LIBRARY_DIR_REL} ${CEGUI_LIBRARY_DIR_REL}/cegui-${CEGUI_VERSION_MAJOR}.${CEGUI_VERSION_MINOR}
                 PATH_SUFFIXES "" "release" "relwithdebinfo" "minsizerel")

    find_library(CEGUI_${comp}_LIBRARY_DBG NAMES ${CEGUI_${comp}_LIBRARY_NAMES_DBG}
                 HINTS ${CEGUI_LIBRARY_DIR_DBG} ${CEGUI_LIBRARY_DIR_DBG}/cegui-${CEGUI_VERSION_MAJOR}.${CEGUI_VERSION_MINOR}
                 PATH_SUFFIXES "" "debug")

    make_library_set(CEGUI_${comp}_LIBRARY)
    findpkg_finish(CEGUI_${comp})

    #PRINT_COMPONENT_INFO(${comp})
endforeach (comp)
     
foreach (comp ${CEGUI_SCRIPT_COMPONENTS})
    findpkg_begin(CEGUI_${comp})
    string(REPLACE "ScriptModule" "" compName ${comp})
   
#   message("comp: " ${comp})
#   message("compName: " ${compName})
   
    find_path(CEGUI_${comp}_INCLUDE_DIR NAMES ScriptModule.h
              HINTS ${CEGUI_INCLUDE_DIRS}
              PATH_SUFFIXES ScriptingModules/${compName} CEGUI/ScriptingModules/${compName})

    set(CEGUI_${comp}_LIBRARY_NAMES "CEGUI${comp}-${CEGUI_VERSION_MAJOR}${CEGUI_LIB_SUFFIX}")

    #message("script stuff: " ${CEGUI_${comp}_LIBRARY_NAMES} )
    get_debug_names(CEGUI_${comp}_LIBRARY_NAMES)
    find_library(CEGUI_${comp}_LIBRARY_REL NAMES ${CEGUI_${comp}_LIBRARY_NAMES}
                 HINTS ${CEGUI_LIBRARY_DIR_REL}
                 PATH_SUFFIXES "" "release" "relwithdebinfo" "minsizerel")

    find_library(CEGUI_${comp}_LIBRARY_DBG NAMES ${CEGUI_${comp}_LIBRARY_NAMES_DBG}
                 HINTS ${CEGUI_LIBRARY_DIR_DBG}
                 PATH_SUFFIXES "" "debug")

    make_library_set(CEGUI_${comp}_LIBRARY)
    findpkg_finish(CEGUI_${comp})

    #PRINT_COMPONENT_INFO(${comp})
endforeach (comp)
 
clear_if_changed(CEGUI_PREFIX_WATCH)

#stop the build to debug FindCEGUI.cmake
#message(FATAL_ERROR "Debug FindCEGUI")


PS: It would be nice if the CEGUI team will provide such a script along with the CEGUI SDK :D

Re: findCEGUI.cmake

Posted: Sun Jul 13, 2014 13:30
by holocronweaver
I searched around the forums and have not come across a reason CEGUI lib does not bundle a FindCEGUI.cmake script. Who what when where why? OGRE does it, so it must be a good idea!

Re: findCEGUI.cmake

Posted: Sun Jul 13, 2014 23:05
by Ident
holocronweaver wrote:OGRE does it, so it must be a good idea!

Ogre does some things good, others not.

I think adding this find script was only recently discussed in #cegui. I consider it a good idea, however we have to see how/where it is included into CEGUI etc., i think this was the outcome of the discussion anyways, Kulik should know/remember more than me.

Re: findCEGUI.cmake

Posted: Mon Jul 14, 2014 09:09
by Kulik
I am on this but I had to do other things first. I hope to include FindCEGUI.cmake in CEGUI 0.8.5 and have it be installed into cmake modules by default. I have quite a nice FindCEGUI.cmake script that I will use as the starting point and improve it from there.

Ogre3d actually does something really stupid, it uses other scripts from within its FindOgre.cmake, that means that you have to install more than 1 script which makes the FindOgre.cmake script less useful. I have seen that some packagers just copy all *.cmake files from Ogre to /usr/share/cmake/Modules, which is disastrously stupid and could clash with other projects in a spectacular way :lol: