/[zanavi_public1]/navit/cmake/FindGTK2.cmake
ZANavi

Contents of /navit/cmake/FindGTK2.cmake

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations) (download)
Fri Oct 28 21:19:04 2011 UTC (8 years, 9 months ago) by zoff99
File size: 13110 byte(s)
import files
1 # - Try to find GTK2
2 # Once done this will define
3 #
4 # GTK2_FOUND - System has Boost
5 # GTK2_INCLUDE_DIRS - GTK2 include directory
6 # GTK2_LIBRARIES - Link these to use GTK2
7 # GTK2_LIBRARY_DIRS - The path to where the GTK2 library files are.
8 # GTK2_DEFINITIONS - Compiler switches required for using GTK2
9 #
10 # Copyright (c) 2007 Andreas Schneider <mail@cynapses.org>
11 #
12 # Redistribution and use is allowed according to the terms of the New
13 # BSD license.
14 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
15 #
16
17 set(GTK2_DEBUG ON)
18
19 macro(GTK2_DEBUG_MESSAGE _message)
20 if (GTK2_DEBUG)
21 message(STATUS "(DEBUG) ${_message}")
22 endif (GTK2_DEBUG)
23 endmacro(GTK2_DEBUG_MESSAGE _message)
24
25 if (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
26 # in cache already
27 set(GTK2_FOUND TRUE)
28 else (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
29
30 # use pkg-config to get the directories and then use these values
31 # in the FIND_PATH() and FIND_LIBRARY() calls
32 include(UsePkgConfig)
33
34 pkgconfig(gtk+-2.0 _GTK2IncDir _GTK2LinkDir _GTK2LinkFlags _GTK2Cflags)
35
36 find_path(GTK2_GTK_INCLUDE_DIR
37 NAMES
38 gtk/gtk.h
39 PATHS
40 $ENV{GTK2_HOME}
41 ${_GTK2IncDir}
42 ${_GTK2IncDir}/gtk-2.0
43 /usr/include/gtk-2.0
44 /usr/local/include/gtk-2.0
45 /opt/include/gtk-2.0
46 /opt/gnome/include/gtk-2.0
47 /sw/include/gtk-2.0
48 )
49 gtk2_debug_message("GTK2_GTK_INCLUDE_DIR is ${GTK2_GTK_INCLUDE_DIR}")
50
51 # Some Linux distributions (e.g. Red Hat) have glibconfig.h
52 # and glib.h in different directories, so we need to look
53 # for both.
54 # - Atanas Georgiev <atanas@cs.columbia.edu>
55 pkgconfig(glib-2.0 _GLIB2IncDir _GLIB2LinkDir _GLIB2LinkFlags _GLIB2Cflags)
56 pkgconfig(gmodule-2.0 _GMODULE2IncDir _GMODULE2LinkDir _GMODULE2LinkFlags _GMODULE2Cflags)
57
58 find_path(GTK2_GLIBCONFIG_INCLUDE_DIR
59 NAMES
60 glibconfig.h
61 PATHS
62 ${_GLIB2IncDir}
63 ${_GMODULE2IncDir}
64 ${_GMODULE2IncDir}/glib-2.0
65 /opt/gnome/lib64/glib-2.0/include
66 /opt/gnome/lib/glib-2.0/include
67 /opt/lib/glib-2.0/include
68 /usr/lib64/glib-2.0/include
69 /usr/lib/glib-2.0/include
70 /sw/lib/glib-2.0/include
71 )
72 gtk2_debug_message("GTK2_GLIBCONFIG_INCLUDE_DIR is ${GTK2_GLIBCONFIG_INCLUDE_DIR}")
73
74 find_path(GTK2_GLIB_INCLUDE_DIR
75 NAMES
76 glib.h
77 PATHS
78 ${_GLIB2IncDir}
79 ${_GLIB2IncDir}/glib-2.0
80 ${_GMODULE2IncDir}
81 /opt/include/glib-2.0
82 /opt/gnome/include/glib-2.0
83 /usr/include/glib-2.0
84 /sw/include/glib-2.0
85 )
86 gtk2_debug_message("GTK2_GLIB_INCLUDE_DIR is ${GTK2_GLIB_INCLUDE_DIR}")
87
88 pkgconfig(gdk-2.0 _GDK2IncDir _GDK2LinkDir _GDK2LinkFlags _GDK2Cflags)
89
90 find_path(GTK2_GDK_INCLUDE_DIR
91 NAMES
92 gdkconfig.h
93 PATHS
94 ${_GDK2IncDir}
95 ${_GDK2IncDir}/gtk-2.0
96 /opt/gnome/lib/gtk-2.0/include
97 /opt/gnome/lib64/gtk-2.0/include
98 /opt/lib/gtk-2.0/include
99 /usr/lib/gtk-2.0/include
100 /usr/lib64/gtk-2.0/include
101 /sw/lib/gtk-2.0/include
102 )
103 gtk2_debug_message("GTK2_GDK_INCLUDE_DIR is ${GTK2_GDK_INCLUDE_DIR}")
104
105 find_path(GTK2_GTKGL_INCLUDE_DIR
106 NAMES
107 gtkgl/gtkglarea.h
108 PATHS
109 ${_GLIB2IncDir}
110 /usr/include
111 /usr/local/include
112 /usr/openwin/share/include
113 /opt/gnome/include
114 /opt/include
115 /sw/include
116 )
117 gtk2_debug_message("GTK2_GTKGL_INCLUDE_DIR is ${GTK2_GTKGL_INCLUDE_DIR}")
118
119 pkgconfig(pango _PANGOIncDir _PANGOLinkDir _PANGOLinkFlags _PANGOCflags)
120
121 find_path(GTK2_PANGO_INCLUDE_DIR
122 NAMES
123 pango/pango.h
124 PATHS
125 ${_PANGOIncDir}
126 ${_PANGOIncDir}/pango-1.0/
127 /usr/include/pango-1.0
128 /opt/gnome/include/pango-1.0
129 /opt/include/pango-1.0
130 /sw/include/pango-1.0
131 )
132 gtk2_debug_message("GTK2_PANGO_INCLUDE_DIR is ${GTK2_PANGO_INCLUDE_DIR}")
133
134 pkgconfig(cairo _CAIROIncDir _CAIROLinkDir _CAIROLinkFlags _CAIROCflags)
135
136 find_path(GTK2_CAIRO_INCLUDE_DIR
137 NAMES
138 cairo.h
139 PATHS
140 ${_CAIROIncDir}
141 ${_CAIROIncDir}/cairo
142 /opt/gnome/include/cairo
143 /usr/include
144 /usr/include/cairo
145 /opt/include
146 /opt/include/cairo
147 /sw/include
148 /sw/include/cairo
149 )
150 gtk2_debug_message("GTK2_CAIRO_INCLUDE_DIR is ${GTK2_CAIRO_INCLUDE_DIR}")
151
152 pkgconfig(gdk-pixbuf-2.0 _GDKPIXBUFIncDir _GDKPIXBUFLinkDir _GDKPIXBUFLinkFlags _GDKPIXBUFCflags)
153
154 find_path(GTK2_GDKPIXBUF_INCLUDE_DIR
155 NAMES
156 gdk-pixbuf/gdk-pixbuf.h
157 PATHS
158 ${_GDKPIXBUFIncDir}
159 ${_GDKPIXBUFIncDir}/gdk-pixbuf-2.0
160 /opt/gnome/include/cairo
161 /usr/include
162 /usr/include/cairo
163 /opt/include
164 /opt/include/cairo
165 /sw/include
166 /sw/include/cairo
167 /sw/include/gdk-pixbuf-2.0
168 )
169 gtk2_debug_message("GTK2_CAIRO_INCLUDE_DIR is ${GTK2_CAIRO_INCLUDE_DIR}")
170
171 pkgconfig(atk _ATKIncDir _ATKLinkDir _ATKLinkFlags _ATKCflags)
172
173 find_path(GTK2_ATK_INCLUDE_DIR
174 NAMES
175 atk/atk.h
176 PATHS
177 ${_ATKIncDir}
178 ${_ATKIncDir}/atk-1.0
179 /opt/gnome/include/atk-1.0
180 /usr/include/atk-1.0
181 /opt/include/atk-1.0
182 /sw/include/atk-1.0
183 )
184 gtk2_debug_message("GTK2_ATK_INCLUDE_DIR is ${GTK2_ATK_INCLUDE_DIR}")
185 if (UNIX)
186 find_library(GTK2_GTK_LIBRARY
187 NAMES
188 gtk-x11-2.0
189 PATHS
190 ${_GTK2LinkDir}
191 /usr/lib
192 /usr/local/lib
193 /usr/openwin/lib
194 /usr/X11R6/lib
195 /opt/gnome/lib
196 /opt/lib
197 /sw/lib
198 )
199 gtk2_debug_message("GTK2_GTK_LIBRARY is ${GTK2_GTK_LIBRARY}")
200
201 find_library(GTK2_GDK_LIBRARY
202 NAMES
203 gdk-x11-2.0
204 PATHS
205 ${_GDK2LinkDir}
206 /usr/lib
207 /usr/local/lib
208 /usr/openwin/lib
209 /usr/X11R6/lib
210 /opt/gnome/lib
211 /opt/lib
212 /sw/lib
213 )
214 gtk2_debug_message("GTK2_GDK_LIBRARY is ${GTK2_GDK_LIBRARY}")
215 endif(UNIX)
216 if (WIN32)
217
218 find_library(GTK2_GTK_LIBRARY
219 NAMES
220 gtk-win32-2.0
221 PATHS
222 ${_GTK2LinkDir}
223 /usr/lib
224 /usr/local/lib
225 /usr/openwin/lib
226 /usr/X11R6/lib
227 /opt/gnome/lib
228 /opt/lib
229 /sw/lib
230 )
231 gtk2_debug_message("GTK2_GTK_LIBRARY is ${GTK2_GTK_LIBRARY}")
232
233 find_library(GTK2_GDK_LIBRARY
234 NAMES
235 gdk-win32-2.0
236 PATHS
237 ${_GDK2LinkDir}
238 /usr/lib
239 /usr/local/lib
240 /usr/openwin/lib
241 /usr/X11R6/lib
242 /opt/gnome/lib
243 /opt/lib
244 /sw/lib
245 )
246 endif (WIN32)
247 find_library(GTK2_GDK_PIXBUF_LIBRARY
248 NAMES
249 gdk_pixbuf-2.0
250 PATHS
251 ${_GDK2LinkDir}
252 /usr/lib
253 /usr/local/lib
254 /usr/openwin/lib
255 /usr/X11R6/lib
256 /opt/gnome/lib
257 /opt/lib
258 /sw/lib
259 )
260 gtk2_debug_message("GTK2_GDK_PIXBUF_LIBRARY is ${GTK2_GDK_PIXBUF_LIBRARY}")
261
262 find_library(GTK2_GMODULE_LIBRARY
263 NAMES
264 gmodule-2.0
265 PATHS
266 ${_GMODULE2LinkDir}
267 /usr/lib
268 /usr/local/lib
269 /usr/openwin/lib
270 /usr/X11R6/lib
271 /opt/gnome/lib
272 /opt/lib
273 /sw/lib
274 )
275 gtk2_debug_message("GTK2_GMODULE_LIBRARY is ${GTK2_GMODULE_LIBRARY}")
276
277 find_library(GTK2_GTHREAD_LIBRARY
278 NAMES
279 gthread-2.0
280 PATHS
281 ${_GTK2LinkDir}
282 /usr/lib
283 /usr/local/lib
284 /usr/openwin/lib
285 /usr/X11R6/lib
286 /opt/gnome/lib
287 /opt/lib
288 /sw/lib
289 )
290 gtk2_debug_message("GTK2_GTHREAD_LIBRARY is ${GTK2_GTHREAD_LIBRARY}")
291
292 find_library(GTK2_GOBJECT_LIBRARY
293 NAMES
294 gobject-2.0
295 PATHS
296 ${_GTK2LinkDir}
297 /usr/lib
298 /usr/local/lib
299 /usr/openwin/lib
300 /usr/X11R6/lib
301 /opt/gnome/lib
302 /opt/lib
303 /sw/lib
304 )
305 gtk2_debug_message("GTK2_GOBJECT_LIBRARY is ${GTK2_GOBJECT_LIBRARY}")
306
307 find_library(GTK2_GLIB_LIBRARY
308 NAMES
309 glib-2.0
310 PATHS
311 ${_GLIB2LinkDir}
312 /usr/lib
313 /usr/local/lib
314 /usr/openwin/lib
315 /usr/X11R6/lib
316 /opt/gnome/lib
317 /opt/lib
318 /sw/lib
319 )
320 gtk2_debug_message("GTK2_GLIB_LIBRARY is ${GTK2_GLIB_LIBRARY}")
321
322 find_library(GTK2_GTKGL_LIBRARY
323 NAMES
324 gtkgl
325 PATHS
326 ${_GTK2LinkDir}
327 /usr/lib
328 /usr/local/lib
329 /usr/openwin/lib
330 /usr/X11R6/lib
331 /opt/gnome/lib
332 /opt/lib
333 /sw/lib
334 )
335 gtk2_debug_message("GTK2_GTKGL_LIBRARY is ${GTK2_GTKGL_LIBRARY}")
336
337 find_library(GTK2_PANGO_LIBRARY
338 NAMES
339 pango-1.0
340 PATHS
341 ${_PANGOLinkDir}
342 /usr/lib
343 /usr/local/lib
344 /usr/openwin/lib
345 /usr/X11R6/lib
346 /opt/gnome/lib
347 /opt/lib
348 /sw/lib
349 )
350 gtk2_debug_message("GTK2_PANGO_LIBRARY is ${GTK2_PANGO_LIBRARY}")
351
352 find_library(GTK2_CAIRO_LIBRARY
353 NAMES
354 pangocairo-1.0
355 PATHS
356 ${_CAIROLinkDir}
357 /usr/lib
358 /usr/local/lib
359 /usr/openwin/lib
360 /usr/X11R6/lib
361 /opt/gnome/lib
362 /opt/lib
363 /sw/lib
364 )
365 gtk2_debug_message("GTK2_PANGO_LIBRARY is ${GTK2_CAIRO_LIBRARY}")
366
367 find_library(GTK2_ATK_LIBRARY
368 NAMES
369 atk-1.0
370 PATHS
371 ${_ATKinkDir}
372 /usr/lib
373 /usr/local/lib
374 /usr/openwin/lib
375 /usr/X11R6/lib
376 /opt/gnome/lib
377 /opt/lib
378 /sw/lib
379 )
380 gtk2_debug_message("GTK2_ATK_LIBRARY is ${GTK2_ATK_LIBRARY}")
381
382 set(GTK2_INCLUDE_DIRS
383 ${GTK2_GTK_INCLUDE_DIR}
384 ${GTK2_GLIBCONFIG_INCLUDE_DIR}
385 ${GTK2_GLIB_INCLUDE_DIR}
386 ${GTK2_GDK_INCLUDE_DIR}
387 ${GTK2_PANGO_INCLUDE_DIR}
388 ${GTK2_CAIRO_INCLUDE_DIR}
389 ${GTK2_ATK_INCLUDE_DIR}
390 )
391
392 if(GTK2_GDKPIXBUF_INCLUDE_DIR)
393 set(GTK2_INCLUDE_DIRS ${GTK2_INCLUDE_DIRS} ${GTK2_GDKPIXBUF_INCLUDE_DIR})
394 endif(GTK2_GDKPIXBUF_INCLUDE_DIR)
395
396 if (GTK2_GTK_LIBRARY AND GTK2_GTK_INCLUDE_DIR)
397 if (GTK2_GDK_LIBRARY AND GTK2_GDK_PIXBUF_LIBRARY AND GTK2_GDK_INCLUDE_DIR)
398 if (GTK2_GMODULE_LIBRARY)
399 if (GTK2_GTHREAD_LIBRARY)
400 if (GTK2_GOBJECT_LIBRARY)
401 if (GTK2_PANGO_LIBRARY AND GTK2_PANGO_INCLUDE_DIR)
402 if (GTK2_CAIRO_LIBRARY AND GTK2_CAIRO_INCLUDE_DIR)
403 if (GTK2_ATK_LIBRARY AND GTK2_ATK_INCLUDE_DIR)
404
405 # set GTK2 libraries
406 set (GTK2_LIBRARIES
407 ${GTK2_GTK_LIBRARY}
408 ${GTK2_GDK_LIBRARY}
409 ${GTK2_GDK_PIXBUF_LIBRARY}
410 ${GTK2_GMODULE_LIBRARY}
411 ${GTK2_GTHREAD_LIBRARY}
412 ${GTK2_GOBJECT_LIBRARY}
413 ${GTK2_PANGO_LIBRARY}
414 ${GTK2_CAIRO_LIBRARY}
415 ${GTK2_ATK_LIBRARY}
416 )
417
418 # check for gtkgl support
419 if (GTK2_GTKGL_LIBRARY AND GTK2_GTKGL_INCLUDE_DIR)
420 set(GTK2_GTKGL_FOUND TRUE)
421
422 # set(GTK2_INCLUDE_DIRS
423 # ${GTK2_INCLUDE_DIRS}
424 # ${GTK2_GTKGL_INCLUDE_DIR}
425 # )
426
427 # set(GTK2_LIBRARIES
428 # ${GTK2_LIBRARIES}
429 # ${GTK2_GTKGL_LIBRARY}
430 # )
431 endif (GTK2_GTKGL_LIBRARY AND GTK2_GTKGL_INCLUDE_DIR)
432
433 else (GTK2_ATK_LIBRARY AND GTK2_ATK_INCLUDE_DIR)
434 endif (GTK2_ATK_LIBRARY AND GTK2_ATK_INCLUDE_DIR)
435 else (GTK2_CAIRO_LIBRARY AND GTK2_CAIRO_INCLUDE_DIR)
436 endif (GTK2_CAIRO_LIBRARY AND GTK2_CAIRO_INCLUDE_DIR)
437 else (GTK2_PANGO_LIBRARY AND GTK2_PANGO_INCLUDE_DIR)
438 endif (GTK2_PANGO_LIBRARY AND GTK2_PANGO_INCLUDE_DIR)
439 else (GTK2_GOBJECT_LIBRARY)
440 endif (GTK2_GOBJECT_LIBRARY)
441 else (GTK2_GTHREAD_LIBRARY)
442 endif (GTK2_GTHREAD_LIBRARY)
443 else (GTK2_GMODULE_LIBRARY)
444 endif (GTK2_GMODULE_LIBRARY)
445 else (GTK2_GDK_LIBRARY AND GTK2_GDK_PIXBUF_LIBRARY AND GTK2_GDK_INCLUDE_DIR)
446 endif (GTK2_GDK_LIBRARY AND GTK2_GDK_PIXBUF_LIBRARY AND GTK2_GDK_INCLUDE_DIR)
447 else (GTK2_GTK_LIBRARY AND GTK2_GTK_INCLUDE_DIR)
448 endif (GTK2_GTK_LIBRARY AND GTK2_GTK_INCLUDE_DIR)
449
450
451 if (GTK2_INCLUDE_DIRS AND GTK2_LIBRARIES)
452 set(GTK2_FOUND TRUE)
453 endif (GTK2_INCLUDE_DIRS AND GTK2_LIBRARIES)
454
455 if (GTK2_FOUND)
456 if (NOT GTK2_FIND_QUIETLY)
457 message(STATUS "Found GTK2: ${GTK2_LIBRARIES}")
458 endif (NOT GTK2_FIND_QUIETLY)
459 else (GTK2_FOUND)
460 if (GTK2_FIND_REQUIRED)
461 message(FATAL_ERROR "Could not find GTK2")
462 endif (GTK2_FIND_REQUIRED)
463 endif (GTK2_FOUND)
464
465 # show the GTK2_INCLUDE_DIRS and GTK2_LIBRARIES variables only in the advanced view
466 mark_as_advanced(GTK2_INCLUDE_DIRS GTK2_LIBRARIES)
467
468
469 endif (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
470

   
Visit the ZANavi Wiki