FindFTGL.cmake 5.73 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
# - Find FTGL
# Find the native FTGL headers and libraries.
#
#  FTGL_INCLUDE_DIR -  where to find FTGL.h, etc.
#  FTGL_LIBRARIES    - List of libraries when using FTGL.
#  FTGL_FOUND        - True if FTGL found.

GET_FILENAME_COMPONENT(module_file_path ${CMAKE_CURRENT_LIST_FILE} PATH )

# Look for the header file.
FIND_PATH(FTGL_INCLUDE_DIR NAMES FTGL/ftgl.h 
                           PATHS /usr/include
                                 /usr/local/include
                                 ../../External/include
                                 "C:\\libs\\ftgl\\ftgl"
                                 ${module_file_path}/../../../External/include)
#MARK_AS_ADVANCED(FTGL_INCLUDE_DIR)

if ( WIN32 )
 # Look for the library.
 FIND_LIBRARY(FTGL_LIBRARY_RELEASE NAMES ftgl ftgl_dynamic_MTD
                           PATHS /usr/lib64
                                 /usr/local/lib64
                                 /usr/lib
                                 /usr/local/lib
                                 ../../External/lib
                                 "C:\\libs\\ftgl\\msvc\\Build"
                ${module_file_path}/../../../External/lib)

 FIND_LIBRARY(FTGL_LIBRARY_DEBUG NAMES ftgl_d ftgld
                           PATHS /usr/lib64
                                 /usr/local/lib64
                                 /usr/lib
                                 /usr/local/lib
                                 ../../External/lib
                                 "C:\\libs\\ftgl\\msvc\\Build"    
                  ${module_file_path}/../../../External/lib) 

 set( FTGL_LIBRARY optimized;${FTGL_LIBRARY_RELEASE};debug;${FTGL_LIBRARY_DEBUG} )

 # Get paths to libraries. Required to link to libs and copy dlls from there
 GET_FILENAME_COMPONENT( FTGL_LIBRARY_DIR_RELEASE ${FTGL_LIBRARY_RELEASE} PATH )
 GET_FILENAME_COMPONENT( FTGL_LIBRARY_DIR_DEBUG ${FTGL_LIBRARY_DEBUG} PATH )
 list(APPEND FTGL_LIBRARY_DIRS ${FTGL_LIBRARY_DIR_DEBUG} ${FTGL_LIBRARY_DIR_RELEASE} )

else(WIN32)
 FIND_LIBRARY(FTGL_LIBRARY NAMES ftgl ftgl_dynamic_MTD
                           PATHS /usr/lib64
                                 /usr/local/lib64
                                 /usr/lib
                                 /usr/local/lib
                                 ../../External/lib
                                 "C:\\libs\\ftgl\\msvc\\Build"
                ${module_file_path}/../../../External/lib)


endif(WIN32)


#MARK_AS_ADVANCED(FTGL_LIBRARY)

IF( WIN32 AND PREFER_STATIC_LIBRARIES )
  SET( FTGL_STATIC_LIBRARY_NAME ftgl_static_MTD )
  IF( MSVC80 )
    SET( FTGL_STATIC_LIBRARY_NAME ftgl_static_MTD_vc8 )
  ELSEIF( MSVC90 )
    SET( FTGL_STATIC_LIBRARY_NAME ftgl_static_MTD_vc9 )
  ENDIF( MSVC80 )
  
  FIND_LIBRARY( FTGL_STATIC_LIBRARY NAMES ${FTGL_STATIC_LIBRARY_NAME}
                                    PATHS /usr/lib64
                                          /usr/local/lib64
                                          /usr/lib
                                          /usr/local/lib
                                          ../../External/lib
                                          ${module_file_path}/../../../External/lib )
  MARK_AS_ADVANCED(FTGL_STATIC_LIBRARY)
  
  FIND_LIBRARY( FTGL_STATIC_DEBUG_LIBRARY NAMES ${FTGL_STATIC_LIBRARY_NAME}_d
                                          PATHS /usr/lib64
                                                /usr/local/lib64
                                                /usr/lib
                                                /usr/local/lib
                                                ../../External/lib
                                                ${module_file_path}/../../../External/lib )
  MARK_AS_ADVANCED(FTGL_STATIC_DEBUG_LIBRARY)
  
  IF( FTGL_STATIC_LIBRARY OR FTGL_STATIC_DEBUG_LIBRARY )
    SET( FTGL_STATIC_LIBRARIES_FOUND 1 )
  ENDIF( FTGL_STATIC_LIBRARY OR FTGL_STATIC_DEBUG_LIBRARY )
ENDIF( WIN32 AND PREFER_STATIC_LIBRARIES )

IF( FTGL_LIBRARY OR FTGL_STATIC_LIBRARIES_FOUND )
  SET( FTGL_LIBRARIES_FOUND 1 )
ENDIF( FTGL_LIBRARY OR FTGL_STATIC_LIBRARIES_FOUND )

# Copy the results to the output variables.
IF(FTGL_INCLUDE_DIR AND FTGL_LIBRARIES_FOUND)
  SET(FTGL_FOUND 1)
  
  IF( WIN32 AND PREFER_STATIC_LIBRARIES AND FTGL_STATIC_LIBRARIES_FOUND )
    IF(FTGL_STATIC_LIBRARY)
      SET(FTGL_LIBRARIES optimized ${FTGL_STATIC_LIBRARY} )
    ELSE(FTGL_STATIC_LIBRARY)
      SET(FTGL_LIBRARIES optimized ${FTGL_STATIC_LIBRARY_NAME} )
      MESSAGE( STATUS, "FTGL static release libraries not found. Release build might not work." )
    ENDIF(FTGL_STATIC_LIBRARY)

    IF(FTGL_STATIC_DEBUG_LIBRARY)
      SET(FTGL_LIBRARIES ${FTGL_LIBRARIES} debug ${FTGL_STATIC_DEBUG_LIBRARY} )
    ELSE(FTGL_STATIC_DEBUG_LIBRARY)
      SET(FTGL_LIBRARIES ${FTGL_LIBRARIES} debug ${FTGL_STATIC_LIBRARY_NAME}_d )
      MESSAGE( STATUS, "FTGL static debug libraries not found. Debug build might not work." )
    ENDIF(FTGL_STATIC_DEBUG_LIBRARY)
    
    SET( FTGL_LIBRARY_STATIC 1 )
  ELSE( WIN32 AND PREFER_STATIC_LIBRARIES AND FTGL_STATIC_LIBRARIES_FOUND )
    SET(FTGL_LIBRARIES ${FTGL_LIBRARY})
  ENDIF( WIN32 AND PREFER_STATIC_LIBRARIES AND FTGL_STATIC_LIBRARIES_FOUND )

  SET(FTGL_INCLUDE_DIR ${FTGL_INCLUDE_DIR})
ELSE(FTGL_INCLUDE_DIR AND FTGL_LIBRARIES_FOUND)
  SET(FTGL_FOUND 0)
  SET(FTGL_LIBRARIES)
  SET(FTGL_INCLUDE_DIR)
ENDIF(FTGL_INCLUDE_DIR AND FTGL_LIBRARIES_FOUND)

# Report the results.
IF(NOT FTGL_FOUND)
  SET(FTGL_DIR_MESSAGE
    "FTGL was not found. Make sure FTGL_LIBRARY and FTGL_INCLUDE_DIR are set to the directories containing the include and lib files for FTGL. If you do not have the library you will not be able to use the Text node.")
  IF(FTGL_FIND_REQUIRED)
      MESSAGE(FATAL_ERROR "${FTGL_DIR_MESSAGE}")
  ELSEIF(NOT FTGL_FIND_QUIETLY)
    MESSAGE(STATUS "${FTGL_DIR_MESSAGE}")
  ELSE(NOT FTGL_FIND_QUIETLY)
  ENDIF(FTGL_FIND_REQUIRED)
ENDIF(NOT FTGL_FOUND)