Skip to content
Newer
Older
100644 122 lines (108 sloc) 3.48 KB
c3f1ab2 Changes reqiured to open source HipHop
Scott MacVicar authored
1 # - Find GD
2 # Find the native GD includes and library
3 # This module defines
4 # GD_INCLUDE_DIR, where to find gd.h, etc.
5 # GD_LIBRARIES, the libraries needed to use GD.
6 # GD_FOUND, If false, do not try to use GD.
7 # also defined, but not for general use are
8 # GD_LIBRARY, where to find the GD library.
9 # GD_SUPPORTS_PNG, GD_SUPPORTS_JPEG, GD_SUPPORTS_GIF, test
10 # support for image formats in GD.
11
12 FIND_PATH(GD_INCLUDE_DIR gd.h
13 /usr/local/include
14 /usr/include
15 )
16
17 if(WIN32 AND NOT CYGWIN)
18 SET(GD_NAMES ${GD_NAMES} bgd)
19 else(WIN32)
20 SET(GD_NAMES ${GD_NAMES} gd)
21 endif(WIN32 AND NOT CYGWIN)
22
23 FIND_LIBRARY(GD_LIBRARY
24 NAMES ${GD_NAMES}
25 PATHS /usr/lib64 /usr/lib /usr/local/lib
26 )
27
28 IF (GD_LIBRARY AND GD_INCLUDE_DIR)
29 SET(GD_LIBRARIES ${GD_LIBRARY})
30 SET(GD_FOUND "YES")
31 ELSE (GD_LIBRARY AND GD_INCLUDE_DIR)
32 SET(GD_FOUND "NO")
33 ENDIF (GD_LIBRARY AND GD_INCLUDE_DIR)
34
35 IF (GD_FOUND)
36 IF (WIN32 AND NOT CYGWIN)
37 SET(GD_SUPPORTS_PNG ON)
38 SET(GD_SUPPORTS_JPEG ON)
39 SET(GD_SUPPORTS_GIF ON)
40 get_filename_component(GD_LIBRARY_DIR ${GD_LIBRARY} PATH)
41 ELSE (WIN32 AND NOT CYGWIN)
42 INCLUDE(CheckLibraryExists)
43 GET_FILENAME_COMPONENT(GD_LIB_PATH ${GD_LIBRARY} PATH)
44 GET_FILENAME_COMPONENT(GD_LIB ${GD_LIBRARY} NAME)
45
46 CHECK_LIBRARY_EXISTS("${GD_LIBRARY}" "gdImagePng" "${GD_LIB_PATH}" GD_SUPPORTS_PNG)
47 IF (GD_SUPPORTS_PNG)
48 find_package(PNG)
49 IF (PNG_FOUND)
50 SET(GD_LIBRARIES ${GD_LIBRARIES} ${PNG_LIBRARIES})
51 SET(GD_INCLUDE_DIR ${GD_INCLUDE_DIR} ${PNG_INCLUDE_DIR})
52 ELSE (PNG_FOUND)
53 SET(GD_SUPPORTS_PNG "NO")
54 ENDIF (PNG_FOUND)
55 ENDIF (GD_SUPPORTS_PNG)
56
57 CHECK_LIBRARY_EXISTS("${GD_LIBRARY}" "gdImageJpeg" "${GD_LIB_PATH}" GD_SUPPORTS_JPEG)
58 IF (GD_SUPPORTS_JPEG)
59 find_package(JPEG)
60 IF (JPEG_FOUND)
61 SET(GD_LIBRARIES ${GD_LIBRARIES} ${JPEG_LIBRARIES})
62 SET(GD_INCLUDE_DIR ${GD_INCLUDE_DIR} ${JPEG_INCLUDE_DIR})
63 ELSE (JPEG_FOUND)
64 SET(GD_SUPPORTS_JPEG "NO")
65 ENDIF (JPEG_FOUND)
66 ENDIF (GD_SUPPORTS_JPEG)
67
68 CHECK_LIBRARY_EXISTS("${GD_LIBRARY}" "gdImageGif" "${GD_LIB_PATH}" GD_SUPPORTS_GIF)
69
70 # Trim the list of include directories
71 SET(GDINCTRIM)
72 FOREACH(GD_DIR ${GD_INCLUDE_DIR})
73 SET(GD_TMP_FOUND OFF)
74 FOREACH(GD_TRIMMED ${GDINCTRIM})
75 IF ("${GD_DIR}" STREQUAL "${GD_TRIMMED}")
76 SET(GD_TMP_FOUND ON)
77 ENDIF ("${GD_DIR}" STREQUAL "${GD_TRIMMED}")
78 ENDFOREACH(GD_TRIMMED ${GDINCTRIM})
79 IF (NOT GD_TMP_FOUND)
80 SET(GDINCTRIM "${GDINCTRIM}" "${GD_DIR}")
81 ENDIF (NOT GD_TMP_FOUND)
82 ENDFOREACH(GD_DIR ${GD_INCLUDE_DIR})
83 SET(GD_INCLUDE_DIR ${GDINCTRIM})
84
85 SET(GD_LIBRARY_DIR)
86
87 # Generate trimmed list of library directories and list of libraries
88 FOREACH(GD_LIB ${GD_LIBRARIES})
89 GET_FILENAME_COMPONENT(GD_NEXTLIBDIR ${GD_LIB} PATH)
90 SET(GD_TMP_FOUND OFF)
91 FOREACH(GD_LIBDIR ${GD_LIBRARY_DIR})
92 IF ("${GD_NEXTLIBDIR}" STREQUAL "${GD_LIBDIR}")
93 SET(GD_TMP_FOUND ON)
94 ENDIF ("${GD_NEXTLIBDIR}" STREQUAL "${GD_LIBDIR}")
95 ENDFOREACH(GD_LIBDIR ${GD_LIBRARIES})
96 IF (NOT GD_TMP_FOUND)
97 SET(GD_LIBRARY_DIR "${GD_LIBRARY_DIR}" "${GD_NEXTLIBDIR}")
98 ENDIF (NOT GD_TMP_FOUND)
99 ENDFOREACH(GD_LIB ${GD_LIBRARIES})
100 ENDIF (WIN32 AND NOT CYGWIN)
101 ENDIF (GD_FOUND)
102
103 IF (GD_FOUND)
104 IF (NOT GD_FIND_QUIETLY)
105 MESSAGE(STATUS "Found GD: ${GD_LIBRARY}")
106 ENDIF (NOT GD_FIND_QUIETLY)
107 ELSE (GD_FOUND)
108 IF (GD_FIND_REQUIRED)
109 MESSAGE(FATAL_ERROR "Could not find GD library")
110 ENDIF (GD_FIND_REQUIRED)
111 ENDIF (GD_FOUND)
112
113 MARK_AS_ADVANCED(
114 GD_LIBRARY
115 GD_LIBRARIES
116 GD_INCLUDE_DIR
117 GD_LIBRARY_DIR
118 GD_SUPPORTS_PNG
119 GD_SUPPORTS_JPEG
120 GD_SUPPORTS_GIF
121 )
Something went wrong with that request. Please try again.