]> Creatis software - crea.git/blob - cmake/FindGTK2.cmake
Feature #1711
[crea.git] / cmake / FindGTK2.cmake
1
2 IF (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
3   # in cache already
4   SET(GTK2_FOUND TRUE)
5 ELSE (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
6   IF(UNIX)
7     # use pkg-config to get the directories and then use these values
8     # in the FIND_PATH() and FIND_LIBRARY() calls
9     INCLUDE(UsePkgConfig)
10
11 #    PKGCONFIG
12 FindPkgConfig(gtk-2.0 _GTK22IncDir _GTK22LinkDir _GTK22LinkFlags _GTK22Cflags)
13
14 #   pkg_search_module(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
15 #     checks for given modules and uses the first working one
16
17     FIND_PATH(GTK2_GTK_INCLUDE_PATH gtk/gtk.h
18       $ENV{GTK2_HOME}
19       ${_GTK22IncDir}
20       /usr/include/gtk-2.0
21       /usr/local/include/gtk-2.0
22       /opt/include/gtk-2.0
23       /opt/gnome/include/gtk-2.0
24       /sw/include/gtk-2.0
25     )
26
27     # Some Linux distributions (e.g. Red Hat) have glibconfig.h
28     # and glib.h in different directories, so we need to look
29     # for both.
30     #  - Atanas Georgiev <atanas@cs.columbia.edu>
31     PKGCONFIG(glib-2.0 _GLIB2IncDir _GLIB2inkDir _GLIB2LinkFlags _GLIB2Cflags)
32     PKGCONFIG(gmodule-2.0 _GMODULE2IncDir _GMODULE2inkDir _GMODULE2LinkFlags _GMODULE2Cflags)
33     SET(GDIR /opt/gnome/lib/glib-2.0/include)
34
35     FIND_PATH(GTK2_GLIBCONFIG_INCLUDE_PATH glibconfig.h
36       ${_GLIB2IncDir}
37       /opt/gnome/lib64/glib-2.0/include
38       /opt/gnome/lib/glib-2.0/include
39       /opt/lib/glib-2.0/include
40       /usr/lib64/glib-2.0/include
41       /usr/lib/glib-2.0/include
42       /sw/lib/glib-2.0/include
43     )
44     #MESSAGE(STATUS "DEBUG: GTK2_GLIBCONFIG_INCLUDE_PATH = ${GTK2_GLIBCONFIG_INCLUDE_PATH}")
45
46     FIND_PATH(GTK2_GLIB_INCLUDE_PATH glib.h
47       ${_GLIB2IncDir}
48       /opt/include/glib-2.0
49       /opt/gnome/include/glib-2.0
50       /usr/include/glib-2.0
51       /sw/include/glib-2.0
52     )
53     #MESSAGE(STATUS "DEBUG: GTK2_GLIBCONFIG_INCLUDE_PATH = ${GTK2_GLIBCONFIG_INCLUDE_PATH}")
54
55     FIND_PATH(GTK2_GTKGL_INCLUDE_PATH gtkgl/gtkglarea.h
56       ${_GLIB2IncDir}
57       /usr/include
58       /usr/local/include
59       /usr/openwin/share/include
60       /opt/gnome/include
61       /opt/include
62       /sw/include
63     )
64
65     PKGCONFIG(pango _PANGOIncDir _PANGOinkDir _PANGOLinkFlags _PANGOCflags)
66
67     FIND_PATH(GTK2_PANGO_INCLUDE_PATH pango/pango.h
68       ${_PANGOIncDir}
69       /opt/gnome/include/pango-1.0
70       /opt/include/pango-1.0
71       /usr/include/pango-1.0
72       /sw/include/pango-1.0
73     )
74
75     PKGCONFIG(gdk-2.0 _GDK2IncDir _GDK2inkDir _GDK2LinkFlags _GDK2Cflags)
76
77     FIND_PATH(GTK2_GDKCONFIG_INCLUDE_PATH gdkconfig.h
78       ${_GDK2IncDir}
79       /opt/gnome/lib/gtk-2.0/include
80       /opt/gnome/lib64/gtk-2.0/include
81       /opt/lib/gtk-2.0/include
82       /usr/lib/gtk-2.0/include
83       /usr/lib64/gtk-2.0/include
84       /sw/lib/gtk-2.0/include
85     )
86
87     # Dave:
88     FIND_PATH(GTK2_GDK_INCLUDE_PATH gdk.h
89       ${_GDK2IncDir}
90       /usr/include/gtk-2.0
91       /usr/include/gtk-2.0/gdk
92     )
93     #MESSAGE(STATUS "DEBUG: GTK2_GLIBCONFIG_INCLUDE_PATH = ${GTK2_GLIBCONFIG_INCLUDE_PATH}")
94
95     PKGCONFIG(cairo _CAIROIncDir _CAIROinkDir _CAIROLinkFlags _CAIROCflags)
96
97     FIND_PATH(GTK2_CAIRO_INCLUDE_PATH cairo.h
98       ${_CAIROIncDir}
99       /opt/gnome/include/cairo
100       /usr/include
101       /usr/include/cairo
102       /opt/include
103       /opt/include/cairo
104       /sw/include
105       /sw/include/cairo
106     )
107     #MESSAGE(STATUS "DEBUG: GTK2_CAIRO_INCLUDE_PATH = ${GTK2_CAIRO_INCLUDE_PATH}")
108
109     PKGCONFIG(atk _ATKIncDir _ATKinkDir _ATKLinkFlags _ATKCflags)
110
111     FIND_PATH(GTK2_ATK_INCLUDE_PATH atk/atk.h
112       ${_ATKIncDir}
113       /opt/gnome/include/atk-1.0
114       /usr/include/atk-1.0
115       /opt/include/atk-1.0
116       /sw/include/atk-1.0
117     )
118     #MESSAGE(STATUS "DEBUG: GTK2_ATK_INCLUDE_PATH = ${GTK2_ATK_INCLUDE_PATH}")
119
120     FIND_LIBRARY(GTK2_GTKGL_LIBRARY
121       NAMES
122         gtkgl
123       PATHS
124         ${_GTK22IncDir}
125         /usr/lib
126         /usr/local/lib
127         /usr/openwin/lib
128         /usr/X11R6/lib
129         /opt/gnome/lib
130         /opt/lib
131         /sw/lib
132     )
133
134     FIND_LIBRARY(GTK2_GTK_LIBRARY
135       NAMES
136         gtk-x11-2.0
137       PATHS
138         ${_GTK22LinkDir}
139         /usr/lib
140         /usr/local/lib
141         /usr/openwin/lib
142         /usr/X11R6/lib
143         /opt/gnome/lib
144         /opt/lib
145         /sw/lib
146     )
147
148     FIND_LIBRARY(GTK2_GDK_LIBRARY
149       NAMES
150         gdk-x11-2.0
151       PATHS
152         ${_GDK2LinkDir}
153         /usr/lib
154         /usr/local/lib
155         /usr/openwin/lib
156         /usr/X11R6/lib
157         /opt/gnome/lib
158         /opt/lib
159         /sw/lib
160     )
161
162     FIND_LIBRARY(GTK2_GMODULE_LIBRARY
163       NAMES
164         gmodule-2.0
165       PATHS
166         ${_GMODULE2inkDir}
167         /usr/lib
168         /usr/local/lib
169         /usr/openwin/lib
170         /usr/X11R6/lib
171         /opt/gnome/lib
172         /opt/lib
173         /sw/lib
174     )
175
176     FIND_LIBRARY(GTK2_GLIB_LIBRARY
177       NAMES
178         glib-2.0
179       PATHS
180         ${_GLIB2inkDir}
181         /usr/lib
182         /usr/local/lib
183         /usr/openwin/lib
184         /usr/X11R6/lib
185         /opt/gnome/lib
186         /opt/lib
187         /sw/lib
188     )
189
190     FIND_LIBRARY(GTK2_Xi_LIBRARY 
191       NAMES
192         Xi
193       PATHS 
194         /usr/lib
195         /usr/local/lib
196         /usr/openwin/lib
197         /usr/X11R6/lib
198         /opt/gnome/lib
199         /opt/lib
200         /sw/lib
201     )
202
203     FIND_LIBRARY(GTK2_GTHREAD_LIBRARY
204       NAMES
205         gthread-2.0
206       PATHS
207         /usr/lib
208         /usr/local/lib
209         /usr/openwin/lib
210         /usr/X11R6/lib
211         /opt/gnome/lib
212         /opt/lib
213         /sw/lib
214     )
215
216
217     FIND_LIBRARY(GTK2_GOBJECT_LIBRARY
218       NAMES
219         gobject-2.0
220       PATHS
221         /usr/lib
222         /usr/local/lib
223         /usr/openwin/lib
224         /usr/X11R6/lib
225         /opt/gnome/lib
226         /opt/lib
227         /sw/lib
228     )
229
230     IF(GTK2_GTK_INCLUDE_PATH)
231       IF(GTK2_GLIBCONFIG_INCLUDE_PATH)
232         IF(GTK2_GLIB_INCLUDE_PATH)
233           IF(GTK2_GTK_LIBRARY)
234             IF(GTK2_GLIB_LIBRARY)
235               IF(GTK2_PANGO_INCLUDE_PATH)
236                 IF(GTK2_ATK_INCLUDE_PATH)
237                   IF(GTK2_CAIRO_INCLUDE_PATH)
238                     # Assume that if gtk and glib were found, the other
239                     # supporting libraries have also been found.
240
241                     SET(GTK2_FOUND TRUE)
242
243                     SET(GTK2_INCLUDE_DIRS
244                       ${GTK2_GTK_INCLUDE_PATH}
245                       ${GTK2_GLIBCONFIG_INCLUDE_PATH}
246                       ${GTK2_GLIB_INCLUDE_PATH}
247                       ${GTK2_PANGO_INCLUDE_PATH}
248                       ${GTK2_GDKCONFIG_INCLUDE_PATH}
249                       # Dave:
250                       ${GTK2_GDK_INCLUDE_PATH}
251                       ${GTK2_ATK_INCLUDE_PATH}
252                       ${GTK2_CAIRO_INCLUDE_PATH}
253                     )
254
255                     SET(GTK2_LIBRARIES
256                       ${GTK2_GTK_LIBRARY}
257                       ${GTK2_GDK_LIBRARY}
258                       ${GTK2_GLIB_LIBRARY}
259                     )
260                     #${GTK2_GOBJECT_LIBRARY})
261
262                     IF(GTK2_GMODULE_LIBRARY)
263                       SET(GTK2_LIBRARIES
264                         ${GTK2_LIBRARIES}
265                         ${GTK2_GMODULE_LIBRARY}
266                       )
267                     ENDIF(GTK2_GMODULE_LIBRARY)
268
269                     IF(GTK2_GTHREAD_LIBRARY)
270                       SET(GTK2_LIBRARIES
271                         ${GTK2_LIBRARIES}
272                         ${GTK2_GTHREAD_LIBRARY}
273                       )
274                     SET(GTK2_LIBRARIES ${GTK2_LIBRARIES})
275                     ENDIF(GTK2_GTHREAD_LIBRARY)
276                   ELSE(GTK2_CAIRO_INCLUDE_PATH)
277                     MESSAGE(STATUS "Can not find cairo")
278                   ENDIF(GTK2_CAIRO_INCLUDE_PATH)
279                 ELSE(GTK2_ATK_INCLUDE_PATH)
280                   MESSAGE(STATUS "Can not find atk")
281                 ENDIF(GTK2_ATK_INCLUDE_PATH)
282               ELSE(GTK2_PANGO_INCLUDE_PATH)
283                 MESSAGE(STATUS "Can not find pango includes")
284               ENDIF(GTK2_PANGO_INCLUDE_PATH)
285             ELSE(GTK2_GLIB_LIBRARY)
286               MESSAGE(STATUS "Can not find glib lib")
287             ENDIF(GTK2_GLIB_LIBRARY)
288           ELSE(GTK2_GTK_LIBRARY)
289             MESSAGE(STATUS "Can not find gtk lib")
290           ENDIF(GTK2_GTK_LIBRARY)
291         ELSE(GTK2_GLIB_INCLUDE_PATH)
292           MESSAGE(STATUS "Can not find glib includes")
293         ENDIF(GTK2_GLIB_INCLUDE_PATH)
294       ELSE(GTK2_GLIBCONFIG_INCLUDE_PATH)
295         MESSAGE(STATUS "Can not find glibconfig")
296       ENDIF(GTK2_GLIBCONFIG_INCLUDE_PATH)
297     ELSE (GTK2_GTK_INCLUDE_PATH)
298       MESSAGE(STATUS "Can not find gtk includes")
299     ENDIF (GTK2_GTK_INCLUDE_PATH)
300
301     IF (GTK2_FOUND)
302       IF (NOT GTK2_FIND_QUIETLY)
303         MESSAGE(STATUS "Looking for gtk2... - found ${GTK2_LIBRARIES}")
304       ENDIF (NOT GTK2_FIND_QUIETLY)
305     ELSE (GTK2_FOUND)
306       IF (GTK2_FIND_REQUIRED)
307         MESSAGE(SEND_ERROR "Could NOT find GTK2")
308       ENDIF (GTK2_FIND_REQUIRED)
309     ENDIF (GTK2_FOUND)
310
311     MARK_AS_ADVANCED(
312       GTK2_GDK_LIBRARY
313       GTK2_GLIB_INCLUDE_PATH
314       GTK2_GLIB_LIBRARY
315       GTK2_GLIBCONFIG_INCLUDE_PATH
316       GTK2_GMODULE_LIBRARY
317       GTK2_GTHREAD_LIBRARY
318       GTK2_Xi_LIBRARY
319       GTK2_GTK_INCLUDE_PATH
320       GTK2_GTK_LIBRARY
321       GTK2_GTKGL_INCLUDE_PATH
322       GTK2_GTKGL_LIBRARY
323       GTK2_ATK_INCLUDE_PATH
324       GTK2_GDKCONFIG_INCLUDE_PATH
325       # Dave:
326       GTK2_GDK_INCLUDE_PATH
327       #GTK2_GOBJECT_LIBRARY
328       GTK2_PANGO_INCLUDE_PATH
329       # LG :
330       GTK2_CAIRO_INCLUDE_PATH
331       GTK2_GOBJECT_LIBRARY
332     )
333   ENDIF(UNIX)
334 ENDIF (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
335