Linux multi-monitor fullscreen support
[ryzomcore.git] / CMakeModules / FindGTK2.cmake
blobe3e91ed21927a96ad0ab52d727412bcde7bb5c62
1 # - Try to find GTK2
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
13 #  BSD license.
14 #  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
17 set(GTK2_DEBUG ON)
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)
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   if (UNIX)
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)
34     pkgconfig(gtk+-2.0 _GTK2IncDir _GTK2LinkDir _GTK2LinkFlags _GTK2Cflags)
36     find_path(GTK2_GTK_INCLUDE_DIR
37       NAMES
38         gtk/gtk.h
39       PATHS
40         $ENV{GTK2_HOME}
41         ${_GTK2IncDir}
42         /usr/include/gtk-2.0
43         /usr/local/include/gtk-2.0
44         /opt/include/gtk-2.0
45         /opt/gnome/include/gtk-2.0
46         /sw/include/gtk-2.0
47     )
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
52     # for both.
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
58       NAMES
59         glibconfig.h
60       PATHS
61         ${_GLIB2IncDir}
62         ${_GMODULE2IncDir}
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
70     )
71     gtk2_debug_message("GTK2_GLIBCONFIG_INCLUDE_DIR is ${GTK2_GLIBCONFIG_INCLUDE_DIR}")
73     find_path(GTK2_GLIB_INCLUDE_DIR
74       NAMES
75         glib.h
76       PATHS
77         ${_GLIB2IncDir}
78         ${_GMODULE2IncDir}
79         /opt/include/glib-2.0
80         /opt/gnome/include/glib-2.0
81         /usr/include/glib-2.0
82         /sw/include/glib-2.0
83     )
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
89       NAMES
90         gdkconfig.h
91       PATHS
92         ${_GDK2IncDir}
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
100     )
101     gtk2_debug_message("GTK2_GDK_INCLUDE_DIR is ${GTK2_GDK_INCLUDE_DIR}")
103     find_path(GTK2_GDK_PIXBUF_INCLUDE_DIR
104       NAMES
105         gdk-pixbuf/gdk-pixbuf.h
106       PATHS
107         ${_GDK2IncDir}
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
115     )
116     gtk2_debug_message("GTK2_GDK_PIXBUF_INCLUDE_DIR is ${GTK2_GDK_PIXBUF_INCLUDE_DIR}")
118     find_path(GTK2_GTKGL_INCLUDE_DIR
119       NAMES
120         gtkgl/gtkglarea.h
121       PATHS
122         ${_GLIB2IncDir}
123         /usr/include
124         /usr/include/gtkgl-2.0
125         /usr/local/include
126         /usr/openwin/share/include
127         /opt/gnome/include
128         /opt/include
129         /sw/include
130     )
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
136       NAMES
137         glade/glade.h
138       PATHS
139         ${_GLADEIncDir}
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
144     )
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
150       NAMES
151         pango/pango.h
152       PATHS
153         ${_PANGOIncDir}
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
158     )
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
164       NAMES
165         cairo.h
166       PATHS
167         ${_CAIROIncDir}
168         /opt/gnome/include/cairo
169         /usr/include
170         /usr/include/cairo
171         /opt/include
172         /opt/include/cairo
173         /sw/include
174         /sw/include/cairo
175     )
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
181       NAMES
182         atk/atk.h
183       PATHS
184         ${_ATKIncDir}
185         /opt/gnome/include/atk-1.0
186         /usr/include/atk-1.0
187         /opt/include/atk-1.0
188         /sw/include/atk-1.0
189     )
190     gtk2_debug_message("GTK2_ATK_INCLUDE_DIR is ${GTK2_ATK_INCLUDE_DIR}")
192     find_library(GTK2_GTK_LIBRARY
193       NAMES
194         gtk-x11-2.0
195       PATHS
196         ${_GTK2LinkDir}
197         /usr/lib
198         /usr/local/lib
199         /usr/openwin/lib
200         /usr/X11R6/lib
201         /opt/gnome/lib
202         /opt/lib
203         /sw/lib
204     )
205     gtk2_debug_message("GTK2_GTK_LIBRARY is ${GTK2_GTK_LIBRARY}")
207     find_library(GTK2_GDK_LIBRARY
208       NAMES
209         gdk-x11-2.0
210       PATHS
211         ${_GDK2LinkDir}
212         /usr/lib
213         /usr/local/lib
214         /usr/openwin/lib
215         /usr/X11R6/lib
216         /opt/gnome/lib
217         /opt/lib
218         /sw/lib
219     )
220     gtk2_debug_message("GTK2_GDK_LIBRARY is ${GTK2_GDK_LIBRARY}")
222     find_library(GTK2_GDK_PIXBUF_LIBRARY
223       NAMES
224         gdk_pixbuf-2.0
225       PATHS
226         ${_GDK2LinkDir}
227         /usr/lib
228         /usr/local/lib
229         /usr/openwin/lib
230         /usr/X11R6/lib
231         /opt/gnome/lib
232         /opt/lib
233         /sw/lib
234     )
235     gtk2_debug_message("GTK2_GDK_PIXBUF_LIBRARY is ${GTK2_GDK_PIXBUF_LIBRARY}")
237     find_library(GTK2_GMODULE_LIBRARY
238       NAMES
239         gmodule-2.0
240       PATHS
241         ${_GMODULE2LinkDir}
242         /usr/lib
243         /usr/local/lib
244         /usr/openwin/lib
245         /usr/X11R6/lib
246         /opt/gnome/lib
247         /opt/lib
248         /sw/lib
249     )
250     gtk2_debug_message("GTK2_GMODULE_LIBRARY is ${GTK2_GMODULE_LIBRARY}")
252     find_library(GTK2_GTHREAD_LIBRARY
253       NAMES
254         gthread-2.0
255       PATHS
256         ${_GTK2LinkDir}
257         /usr/lib
258         /usr/local/lib
259         /usr/openwin/lib
260         /usr/X11R6/lib
261         /opt/gnome/lib
262         /opt/lib
263         /sw/lib
264     )
265     gtk2_debug_message("GTK2_GTHREAD_LIBRARY is ${GTK2_GTHREAD_LIBRARY}")
267     find_library(GTK2_GOBJECT_LIBRARY
268       NAMES
269         gobject-2.0
270       PATHS
271         ${_GTK2LinkDir}
272         /usr/lib
273         /usr/local/lib
274         /usr/openwin/lib
275         /usr/X11R6/lib
276         /opt/gnome/lib
277         /opt/lib
278         /sw/lib
279     )
280     gtk2_debug_message("GTK2_GOBJECT_LIBRARY is ${GTK2_GOBJECT_LIBRARY}")
282     find_library(GTK2_GLIB_LIBRARY
283       NAMES
284         glib-2.0
285       PATHS
286         ${_GLIB2LinkDir}
287         /usr/lib
288         /usr/local/lib
289         /usr/openwin/lib
290         /usr/X11R6/lib
291         /opt/gnome/lib
292         /opt/lib
293         /sw/lib
294     )
295     gtk2_debug_message("GTK2_GLIB_LIBRARY is ${GTK2_GLIB_LIBRARY}")
297     find_library(GTK2_GTKGL_LIBRARY
298       NAMES
299         gtkgl-2.0
300       PATHS
301         ${_GTK2LinkDir}
302         /usr/lib
303         /usr/local/lib
304         /usr/openwin/lib
305         /usr/X11R6/lib
306         /opt/gnome/lib
307         /opt/lib
308         /sw/lib
309     )
310     gtk2_debug_message("GTK2_GTKGL_LIBRARY is ${GTK2_GTKGL_LIBRARY}")
312     find_library(GTK2_GLADE_LIBRARY
313       NAMES
314         glade-2.0
315       PATHS
316         ${_GLADELinkDir}
317         /usr/lib
318         /usr/local/lib
319         /usr/openwin/lib
320         /usr/X11R6/lib
321         /opt/gnome/lib
322         /opt/lib
323         /sw/lib
324     )
325     gtk2_debug_message("GTK2_GLADE_LIBRARY is ${GTK2_GLADE_LIBRARY}")
327     find_library(GTK2_PANGO_LIBRARY
328       NAMES
329         pango-1.0
330       PATHS
331         ${_PANGOLinkDir}
332         /usr/lib
333         /usr/local/lib
334         /usr/openwin/lib
335         /usr/X11R6/lib
336         /opt/gnome/lib
337         /opt/lib
338         /sw/lib
339     )
340     gtk2_debug_message("GTK2_PANGO_LIBRARY is ${GTK2_PANGO_LIBRARY}")
342     find_library(GTK2_CAIRO_LIBRARY
343       NAMES
344         pangocairo-1.0
345       PATHS
346         ${_CAIROLinkDir}
347         /usr/lib
348         /usr/local/lib
349         /usr/openwin/lib
350         /usr/X11R6/lib
351         /opt/gnome/lib
352         /opt/lib
353         /sw/lib
354     )
355     gtk2_debug_message("GTK2_PANGO_LIBRARY is ${GTK2_CAIRO_LIBRARY}")
357     find_library(GTK2_ATK_LIBRARY
358       NAMES
359         atk-1.0
360       PATHS
361         ${_ATKinkDir}
362         /usr/lib
363         /usr/local/lib
364         /usr/openwin/lib
365         /usr/X11R6/lib
366         /opt/gnome/lib
367         /opt/lib
368         /sw/lib
369     )
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}
382     )
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)
394                       # set GTK2 libraries
395                       set (GTK2_LIBRARIES
396                         ${GTK2_GTK_LIBRARY}
397                         ${GTK2_GDK_LIBRARY}
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}
405                         ${GTK2_ATK_LIBRARY}
406                       )
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
413                           ${GTK2_INCLUDE_DIRS}
414                           ${GTK2_GTKGL_INCLUDE_DIR}
415                         )
417                         set(GTK2_LIBRARIES
418                           ${GTK2_LIBRARIES}
419                           ${GTK2_GTKGL_LIBRARY}
420                         )
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)
452        set(GTK2_FOUND TRUE)
453     endif (GTK2_INCLUDE_DIRS AND GTK2_LIBRARIES)
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)
465     # show the GTK2_INCLUDE_DIRS and GTK2_LIBRARIES variables only in the advanced view
466     mark_as_advanced(GTK2_INCLUDE_DIRS GTK2_LIBRARIES)
468   endif (UNIX)
469 endif (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)