2 # Once done this will define
4 # GTK2_FOUND - System has GTK2
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
10 # Copyright (c) 2007 Andreas Schneider <mail@cynapses.org>
12 # Redistribution and use is allowed according to the terms of the New
14 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
19 macro(GTK2_DEBUG_MESSAGE _message)
21 message(STATUS "(DEBUG) ${_message}")
23 endmacro(GTK2_DEBUG_MESSAGE _message)
25 if (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
28 else (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
30 # use pkg-config to get the directories and then use these values
31 # in the FIND_PATH() and FIND_LIBRARY() calls
34 pkgconfig(gtk+-2.0 _GTK2IncDir _GTK2LinkDir _GTK2LinkFlags _GTK2Cflags)
36 find_path(GTK2_GTK_INCLUDE_DIR
43 /usr/local/include/gtk-2.0
45 /opt/gnome/include/gtk-2.0
48 gtk2_debug_message("GTK2_GTK_INCLUDE_DIR is ${GTK2_GTK_INCLUDE_DIR}")
50 # Some Linux distributions (e.g. Red Hat) have glibconfig.h
51 # and glib.h in different directories, so we need to look
53 # - Atanas Georgiev <atanas@cs.columbia.edu>
54 pkgconfig(glib-2.0 _GLIB2IncDir _GLIB2LinkDir _GLIB2LinkFlags _GLIB2Cflags)
55 pkgconfig(gmodule-2.0 _GMODULE2IncDir _GMODULE2LinkDir _GMODULE2LinkFlags _GMODULE2Cflags)
57 find_path(GTK2_GLIBCONFIG_INCLUDE_DIR
63 /opt/gnome/lib64/glib-2.0/include
64 /opt/gnome/lib/glib-2.0/include
65 /opt/lib/glib-2.0/include
66 /usr/lib64/glib-2.0/include
67 /usr/lib/glib-2.0/include
68 /sw/lib/glib-2.0/include
69 /usr/lib/x86_64-linux-gnu/glib-2.0/include
71 gtk2_debug_message("GTK2_GLIBCONFIG_INCLUDE_DIR is ${GTK2_GLIBCONFIG_INCLUDE_DIR}")
73 find_path(GTK2_GLIB_INCLUDE_DIR
80 /opt/gnome/include/glib-2.0
84 gtk2_debug_message("GTK2_GLIB_INCLUDE_DIR is ${GTK2_GLIB_INCLUDE_DIR}")
86 pkgconfig(gdk-2.0 _GDK2IncDir _GDK2LinkDir _GDK2LinkFlags _GDK2Cflags)
88 find_path(GTK2_GDK_INCLUDE_DIR
93 /opt/gnome/lib/gtk-2.0/include
94 /opt/gnome/lib64/gtk-2.0/include
95 /opt/lib/gtk-2.0/include
96 /usr/lib/gtk-2.0/include
97 /usr/lib64/gtk-2.0/include
98 /sw/lib/gtk-2.0/include
99 /usr/lib/x86_64-linux-gnu/gtk-2.0/include
101 gtk2_debug_message("GTK2_GDK_INCLUDE_DIR is ${GTK2_GDK_INCLUDE_DIR}")
103 find_path(GTK2_GDK_PIXBUF_INCLUDE_DIR
105 gdk-pixbuf/gdk-pixbuf.h
108 /opt/gnome/lib/gtk-2.0/include
109 /opt/gnome/lib64/gtk-2.0/include
110 /opt/lib/gtk-2.0/include
111 /usr/lib/gtk-2.0/include
112 /usr/lib64/gtk-2.0/include
113 /sw/lib/gtk-2.0/include
114 /usr/include/gdk-pixbuf-2.0
116 gtk2_debug_message("GTK2_GDK_PIXBUF_INCLUDE_DIR is ${GTK2_GDK_PIXBUF_INCLUDE_DIR}")
118 find_path(GTK2_GTKGL_INCLUDE_DIR
124 /usr/include/gtkgl-2.0
126 /usr/openwin/share/include
131 gtk2_debug_message("GTK2_GTKGL_INCLUDE_DIR is ${GTK2_GTKGL_INCLUDE_DIR}")
133 pkgconfig(libglade-2.0 _GLADEIncDir _GLADELinkDir _GLADELinkFlags _GLADECflags)
135 find_path(GTK2_GLADE_INCLUDE_DIR
140 /opt/gnome/include/libglade-2.0
141 /usr/include/libglade-2.0
142 /opt/include/libglade-2.0
143 /sw/include/libglade-2.0
145 gtk2_debug_message("GTK2_GLADE_INCLUDE_DIR is ${GTK2_GLADE_INCLUDE_DIR}")
147 pkgconfig(pango _PANGOIncDir _PANGOLinkDir _PANGOLinkFlags _PANGOCflags)
149 find_path(GTK2_PANGO_INCLUDE_DIR
154 /usr/include/pango-1.0
155 /opt/gnome/include/pango-1.0
156 /opt/include/pango-1.0
157 /sw/include/pango-1.0
159 gtk2_debug_message("GTK2_PANGO_INCLUDE_DIR is ${GTK2_PANGO_INCLUDE_DIR}")
161 pkgconfig(cairo _CAIROIncDir _CAIROLinkDir _CAIROLinkFlags _CAIROCflags)
163 find_path(GTK2_CAIRO_INCLUDE_DIR
168 /opt/gnome/include/cairo
176 gtk2_debug_message("GTK2_CAIRO_INCLUDE_DIR is ${GTK2_CAIRO_INCLUDE_DIR}")
178 pkgconfig(atk _ATKIncDir _ATKLinkDir _ATKLinkFlags _ATKCflags)
180 find_path(GTK2_ATK_INCLUDE_DIR
185 /opt/gnome/include/atk-1.0
190 gtk2_debug_message("GTK2_ATK_INCLUDE_DIR is ${GTK2_ATK_INCLUDE_DIR}")
192 find_library(GTK2_GTK_LIBRARY
205 gtk2_debug_message("GTK2_GTK_LIBRARY is ${GTK2_GTK_LIBRARY}")
207 find_library(GTK2_GDK_LIBRARY
220 gtk2_debug_message("GTK2_GDK_LIBRARY is ${GTK2_GDK_LIBRARY}")
222 find_library(GTK2_GDK_PIXBUF_LIBRARY
235 gtk2_debug_message("GTK2_GDK_PIXBUF_LIBRARY is ${GTK2_GDK_PIXBUF_LIBRARY}")
237 find_library(GTK2_GMODULE_LIBRARY
250 gtk2_debug_message("GTK2_GMODULE_LIBRARY is ${GTK2_GMODULE_LIBRARY}")
252 find_library(GTK2_GTHREAD_LIBRARY
265 gtk2_debug_message("GTK2_GTHREAD_LIBRARY is ${GTK2_GTHREAD_LIBRARY}")
267 find_library(GTK2_GOBJECT_LIBRARY
280 gtk2_debug_message("GTK2_GOBJECT_LIBRARY is ${GTK2_GOBJECT_LIBRARY}")
282 find_library(GTK2_GLIB_LIBRARY
295 gtk2_debug_message("GTK2_GLIB_LIBRARY is ${GTK2_GLIB_LIBRARY}")
297 find_library(GTK2_GTKGL_LIBRARY
310 gtk2_debug_message("GTK2_GTKGL_LIBRARY is ${GTK2_GTKGL_LIBRARY}")
312 find_library(GTK2_GLADE_LIBRARY
325 gtk2_debug_message("GTK2_GLADE_LIBRARY is ${GTK2_GLADE_LIBRARY}")
327 find_library(GTK2_PANGO_LIBRARY
340 gtk2_debug_message("GTK2_PANGO_LIBRARY is ${GTK2_PANGO_LIBRARY}")
342 find_library(GTK2_CAIRO_LIBRARY
355 gtk2_debug_message("GTK2_PANGO_LIBRARY is ${GTK2_CAIRO_LIBRARY}")
357 find_library(GTK2_ATK_LIBRARY
370 gtk2_debug_message("GTK2_ATK_LIBRARY is ${GTK2_ATK_LIBRARY}")
372 set(GTK2_INCLUDE_DIRS
373 ${GTK2_GTK_INCLUDE_DIR}
374 ${GTK2_GLIBCONFIG_INCLUDE_DIR}
375 ${GTK2_GLIB_INCLUDE_DIR}
376 ${GTK2_GDK_INCLUDE_DIR}
377 ${GTK2_GDK_PIXBUF_INCLUDE_DIR}
378 ${GTK2_GLADE_INCLUDE_DIR}
379 ${GTK2_PANGO_INCLUDE_DIR}
380 ${GTK2_CAIRO_INCLUDE_DIR}
381 ${GTK2_ATK_INCLUDE_DIR}
384 if (GTK2_GTK_LIBRARY AND GTK2_GTK_INCLUDE_DIR)
385 if (GTK2_GDK_LIBRARY AND GTK2_GDK_PIXBUF_LIBRARY AND GTK2_GDK_INCLUDE_DIR AND GTK2_GDK_PIXBUF_INCLUDE_DIR)
386 if (GTK2_GMODULE_LIBRARY)
387 if (GTK2_GTHREAD_LIBRARY)
388 if (GTK2_GOBJECT_LIBRARY)
389 if (GTK2_GLADE_LIBRARY AND GTK2_GLADE_INCLUDE_DIR)
390 if (GTK2_PANGO_LIBRARY AND GTK2_PANGO_INCLUDE_DIR)
391 if (GTK2_CAIRO_LIBRARY AND GTK2_CAIRO_INCLUDE_DIR)
392 if (GTK2_ATK_LIBRARY AND GTK2_ATK_INCLUDE_DIR)
398 ${GTK2_GDK_PIXBUF_LIBRARY}
399 ${GTK2_GMODULE_LIBRARY}
400 ${GTK2_GTHREAD_LIBRARY}
401 ${GTK2_GOBJECT_LIBRARY}
402 ${GTK2_GLADE_LIBRARY}
403 ${GTK2_PANGO_LIBRARY}
404 ${GTK2_CAIRO_LIBRARY}
408 # check for gtkgl support
409 if (GTK2_GTKGL_LIBRARY AND GTK2_GTKGL_INCLUDE_DIR)
410 set(GTK2_GTKGL_FOUND TRUE)
412 set(GTK2_INCLUDE_DIRS
414 ${GTK2_GTKGL_INCLUDE_DIR}
419 ${GTK2_GTKGL_LIBRARY}
421 endif (GTK2_GTKGL_LIBRARY AND GTK2_GTKGL_INCLUDE_DIR)
423 else (GTK2_ATK_LIBRARY AND GTK2_ATK_INCLUDE_DIR)
424 message(SEND_ERROR "Could not find ATK")
425 endif (GTK2_ATK_LIBRARY AND GTK2_ATK_INCLUDE_DIR)
426 else (GTK2_CAIRO_LIBRARY AND GTK2_CAIRO_INCLUDE_DIR)
427 message(SEND_ERROR "Could not find CAIRO")
428 endif (GTK2_CAIRO_LIBRARY AND GTK2_CAIRO_INCLUDE_DIR)
429 else (GTK2_PANGO_LIBRARY AND GTK2_PANGO_INCLUDE_DIR)
430 message(SEND_ERROR "Could not find PANGO")
431 endif (GTK2_PANGO_LIBRARY AND GTK2_PANGO_INCLUDE_DIR)
432 else (GTK2_GLADE_LIBRARY AND GTK2_GLADE_INCLUDE_DIR)
433 message(SEND_ERROR "Could not find GLADE")
434 endif (GTK2_GLADE_LIBRARY AND GTK2_GLADE_INCLUDE_DIR)
435 else (GTK2_GOBJECT_LIBRARY)
436 message(SEND_ERROR "Could not find GOBJECT")
437 endif (GTK2_GOBJECT_LIBRARY)
438 else (GTK2_GTHREAD_LIBRARY)
439 message(SEND_ERROR "Could not find GTHREAD")
440 endif (GTK2_GTHREAD_LIBRARY)
441 else (GTK2_GMODULE_LIBRARY)
442 message(SEND_ERROR "Could not find GMODULE")
443 endif (GTK2_GMODULE_LIBRARY)
444 else (GTK2_GDK_LIBRARY AND GTK2_GDK_PIXBUF_LIBRARY AND GTK2_GDK_INCLUDE_DIR AND GTK2_GDK_PIXBUF_INCLUDE_DIR)
445 message(SEND_ERROR "Could not find GDK (GDK_PIXBUF)")
446 endif (GTK2_GDK_LIBRARY AND GTK2_GDK_PIXBUF_LIBRARY AND GTK2_GDK_INCLUDE_DIR AND GTK2_GDK_PIXBUF_INCLUDE_DIR)
447 else (GTK2_GTK_LIBRARY AND GTK2_GTK_INCLUDE_DIR)
448 message(SEND_ERROR "Could not find GTK2-X11")
449 endif (GTK2_GTK_LIBRARY AND GTK2_GTK_INCLUDE_DIR)
451 if (GTK2_INCLUDE_DIRS AND GTK2_LIBRARIES)
453 endif (GTK2_INCLUDE_DIRS AND GTK2_LIBRARIES)
456 if (NOT GTK2_FIND_QUIETLY)
457 message(STATUS "Found GTK2: ${GTK2_LIBRARIES}")
458 endif (NOT GTK2_FIND_QUIETLY)
460 if (GTK2_FIND_REQUIRED)
461 message(FATAL_ERROR "Could not find GTK2")
462 endif (GTK2_FIND_REQUIRED)
465 # show the GTK2_INCLUDE_DIRS and GTK2_LIBRARIES variables only in the advanced view
466 mark_as_advanced(GTK2_INCLUDE_DIRS GTK2_LIBRARIES)
469 endif (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)