1 #
2 # try to find GTK2 (and glib) and GTK2GLArea
3 #
4 # GTK2_INCLUDE_DIRS - Directories to include to use GTK2
5 # GTK2_LIBRARIES - Files to link against to use GTK2
6 # GTK2_FOUND - If false, don't try to use GTK2
7 # GTK2_GL_FOUND - If false, don't try to use GTK2's GL features
8 #
9 ###################################################################
10 #
11 # Copyright (c) 2004 Jan Woetzel
12 # Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
13 #
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License
16 # as published by the Free Software Foundation; either version 2
17 # of the License, or (at your option) any later version.
18 #
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 51 Franklin Street, Fifth Floor,
27 # Boston, MA 02110-1301, USA.
28 #
29 ###################################################################
30 #
31 # Copyright (c) 2004 Jan Woetzel
32 # Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
33 # All rights reserved.
34 #
35 # Redistribution and use in source and binary forms, with or without
36 # modification, are permitted provided that the following conditions
37 # are met:
38 #
39 # * Redistributions of source code must retain the above copyright
40 # notice, this list of conditions and the following disclaimer.
41 #
42 # * Redistributions in binary form must reproduce the above copyright
43 # notice, this list of conditions and the following disclaimer in
44 # the documentation and/or other materials provided with the
45 # distribution.
46 #
47 # * Neither the name of the <ORGANIZATION> nor the names of its
48 # contributors may be used to endorse or promote products derived
49 # from this software without specific prior written permission.
50 #
51 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
52 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
53 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
54 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
55 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
56 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
57 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
58 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
59 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
61 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
62 # POSSIBILITY OF SUCH DAMAGE.
63 #
65 IF (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
66 # in cache already
67 SET(GTK2_FOUND TRUE)
68 ELSE (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
69 IF(UNIX)
70 # use pkg-config to get the directories and then use these values
71 # in the FIND_PATH() and FIND_LIBRARY() calls
72 INCLUDE(UsePkgConfig)
74 PKGCONFIG(gtk+-2.0 _GTK22IncDir _GTK22LinkDir _GTK22LinkFlags _GTK22Cflags)
76 FIND_PATH(GTK2_GTK_INCLUDE_PATH gtk/gtk.h
77 $ENV{GTK2_HOME}
78 ${_GTK22IncDir}
79 /usr/include/gtk-2.0
80 /usr/local/include/gtk-2.0
81 /opt/gnome/include/gtk-2.0
82 )
84 # Some Linux distributions (e.g. Red Hat) have glibconfig.h
85 # and glib.h in different directories, so we need to look
86 # for both.
87 # - Atanas Georgiev <atanas@cs.columbia.edu>
88 PKGCONFIG(glib-2.0 _GLIB2IncDir _GLIB2inkDir _GLIB2LinkFlags _GLIB2Cflags)
89 PKGCONFIG(gmodule-2.0 _GMODULE2IncDir _GMODULE2inkDir _GMODULE2LinkFlags _GMODULE2Cflags)
90 SET(GDIR /opt/gnome/lib/glib-2.0/include)
91 FIND_PATH(GTK2_GLIBCONFIG_INCLUDE_PATH glibconfig.h
92 ${_GLIB2IncDir}
93 /opt/gnome/lib64/glib-2.0/include
94 /opt/gnome/lib/glib-2.0/include
95 /usr/lib64/glib-2.0/include
96 /usr/lib/glib-2.0/include
97 )
98 #MESSAGE(STATUS "DEBUG: GTK2_GLIBCONFIG_INCLUDE_PATH = ${GTK2_GLIBCONFIG_INCLUDE_PATH}")
100 FIND_PATH(GTK2_GLIB_INCLUDE_PATH glib.h
101 ${_GLIB2IncDir}
102 /opt/gnome/include/glib-2.0
103 /usr/include/glib-2.0
104 )
105 #MESSAGE(STATUS "DEBUG: GTK2_GLIBCONFIG_INCLUDE_PATH = ${GTK2_GLIBCONFIG_INCLUDE_PATH}")
107 FIND_PATH(GTK2_GTKGL_INCLUDE_PATH gtkgl/gtkglarea.h
108 ${_GLIB2IncDir}
109 /usr/include
110 /usr/local/include
111 /usr/openwin/share/include
112 /opt/gnome/include
113 )
115 PKGCONFIG(pango _PANGOIncDir _PANGOinkDir _PANGOLinkFlags _PANGOCflags)
117 FIND_PATH(GTK2_PANGO_INCLUDE_PATH pango/pango.h
118 ${_PANGOIncDir}
119 /opt/gnome/include/pango-1.0
120 /usr/include/pango-1.0
121 )
123 PKGCONFIG(gdk-2.0 _GDK2IncDir _GDK2inkDir _GDK2LinkFlags _GDK2Cflags)
125 FIND_PATH(GTK2_GDKCONFIG_INCLUDE_PATH gdkconfig.h
126 ${_GDK2IncDir}
127 /opt/gnome/lib/gtk-2.0/include
128 /opt/gnome/lib64/gtk-2.0/include
129 /usr/lib/gtk-2.0/include
130 /usr/lib64/gtk-2.0/include
131 )
133 PKGCONFIG(cairo _CAIROIncDir _CAIROinkDir _CAIROLinkFlags _CAIROCflags)
135 FIND_PATH(GTK2_CAIRO_INCLUDE_PATH cairo.h
136 ${_CAIROIncDir}
137 /opt/gnome/include/cairo
138 /usr/include
139 /usr/include/cairo
140 )
141 #MESSAGE(STATUS "DEBUG: GTK2_CAIRO_INCLUDE_PATH = ${GTK2_CAIRO_INCLUDE_PATH}")
143 PKGCONFIG(atk _ATKIncDir _ATKinkDir _ATKLinkFlags _ATKCflags)
145 FIND_PATH(GTK2_ATK_INCLUDE_PATH atk/atk.h
146 ${_ATKIncDir}
147 /opt/gnome/include/atk-1.0
148 /usr/include/atk-1.0
149 )
150 #MESSAGE(STATUS "DEBUG: GTK2_ATK_INCLUDE_PATH = ${GTK2_ATK_INCLUDE_PATH}")
152 FIND_LIBRARY(GTK2_GTKGL_LIBRARY
153 NAMES
154 gtkgl
155 PATHS
156 ${_GTK22IncDir}
157 /usr/lib
158 /usr/local/lib
159 /usr/openwin/lib
160 /usr/X11R6/lib
161 /opt/gnome/lib
162 )
164 FIND_LIBRARY(GTK2_GTK_LIBRARY
165 NAMES
166 gtk-x11-2.0
167 PATHS
168 ${_GTK22LinkDir}
169 /usr/lib
170 /usr/local/lib
171 /usr/openwin/lib
172 /usr/X11R6/lib
173 /opt/gnome/lib
174 )
176 FIND_LIBRARY(GTK2_GDK_LIBRARY
177 NAMES
178 gdk-x11-2.0
179 PATHS
180 ${_GDK2LinkDir}
181 /usr/lib
182 /usr/local/lib
183 /usr/openwin/lib
184 /usr/X11R6/lib
185 /opt/gnome/lib
186 )
188 FIND_LIBRARY(GTK2_GMODULE_LIBRARY
189 NAMES
190 gmodule-2.0
191 PATHS
192 ${_GMODULE2inkDir}
193 /usr/lib
194 /usr/local/lib
195 /usr/openwin/lib
196 /usr/X11R6/lib
197 /opt/gnome/lib
198 )
200 FIND_LIBRARY(GTK2_GLIB_LIBRARY
201 NAMES
202 glib-2.0
203 PATHS
204 ${_GLIB2inkDir}
205 /usr/lib
206 /usr/local/lib
207 /usr/openwin/lib
208 /usr/X11R6/lib
209 /opt/gnome/lib
210 )
212 FIND_LIBRARY(GTK2_Xi_LIBRARY
213 NAMES
214 Xi
215 PATHS
216 /usr/lib
217 /usr/local/lib
218 /usr/openwin/lib
219 /usr/X11R6/lib
220 /opt/gnome/lib
221 )
223 FIND_LIBRARY(GTK2_GTHREAD_LIBRARY
224 NAMES
225 gthread-2.0
226 PATHS
227 /usr/lib
228 /usr/local/lib
229 /usr/openwin/lib
230 /usr/X11R6/lib
231 /opt/gnome/lib
232 )
235 FIND_LIBRARY(GTK2_GOBJECT_LIBRARY
236 NAMES
237 gobject-2.0
238 PATHS
239 /usr/lib
240 /usr/local/lib
241 /usr/openwin/lib
242 /usr/X11R6/lib
243 /opt/gnome/lib
244 )
246 IF(GTK2_GTK_INCLUDE_PATH)
247 IF(GTK2_GLIBCONFIG_INCLUDE_PATH)
248 IF(GTK2_GLIB_INCLUDE_PATH)
249 IF(GTK2_GTK_LIBRARY)
250 IF(GTK2_GLIB_LIBRARY)
251 IF(GTK2_PANGO_INCLUDE_PATH)
252 IF(GTK2_ATK_INCLUDE_PATH)
253 IF(GTK2_CAIRO_INCLUDE_PATH)
254 # Assume that if gtk and glib were found, the other
255 # supporting libraries have also been found.
257 SET(GTK2_FOUND TRUE)
259 SET(GTK2_INCLUDE_DIRS
260 ${GTK2_GTK_INCLUDE_PATH}
261 ${GTK2_GLIBCONFIG_INCLUDE_PATH}
262 ${GTK2_GLIB_INCLUDE_PATH}
263 ${GTK2_PANGO_INCLUDE_PATH}
264 ${GTK2_GDKCONFIG_INCLUDE_PATH}
265 ${GTK2_ATK_INCLUDE_PATH}
266 ${GTK2_CAIRO_INCLUDE_PATH}
267 CACHE INTERNAL "The include directories for GTK2"
268 )
270 SET(GTK2_LIBRARIES
271 ${GTK2_GTK_LIBRARY}
272 ${GTK2_GDK_LIBRARY}
273 ${GTK2_GLIB_LIBRARY}
274 )
275 #${GTK2_GOBJECT_LIBRARY})
277 IF(GTK2_GMODULE_LIBRARY)
278 SET(GTK2_LIBRARIES
279 ${GTK2_LIBRARIES}
280 ${GTK2_GMODULE_LIBRARY}
281 )
282 ENDIF(GTK2_GMODULE_LIBRARY)
284 IF(GTK2_GTHREAD_LIBRARY)
285 SET(GTK2_LIBRARIES
286 ${GTK2_LIBRARIES}
287 ${GTK2_GTHREAD_LIBRARY}
288 )
289 SET(GTK2_LIBRARIES ${GTK2_LIBRARIES}
290 CACHE INTERNAL "The libraries for GTK2"
291 )
292 ENDIF(GTK2_GTHREAD_LIBRARY)
293 ELSE(GTK2_CAIRO_INCLUDE_PATH)
294 MESSAGE(STATUS "Can not find cairo")
295 ENDIF(GTK2_CAIRO_INCLUDE_PATH)
296 ELSE(GTK2_ATK_INCLUDE_PATH)
297 MESSAGE(STATUS "Can not find atk")
298 ENDIF(GTK2_ATK_INCLUDE_PATH)
299 ELSE(GTK2_PANGO_INCLUDE_PATH)
300 MESSAGE(STATUS "Can not find pango includes")
301 ENDIF(GTK2_PANGO_INCLUDE_PATH)
302 ELSE(GTK2_GLIB_LIBRARY)
303 MESSAGE(STATUS "Can not find glib lib")
304 ENDIF(GTK2_GLIB_LIBRARY)
305 ELSE(GTK2_GTK_LIBRARY)
306 MESSAGE(STATUS "Can not find gtk lib")
307 ENDIF(GTK2_GTK_LIBRARY)
308 ELSE(GTK2_GLIB_INCLUDE_PATH)
309 MESSAGE(STATUS "Can not find glib includes")
310 ENDIF(GTK2_GLIB_INCLUDE_PATH)
311 ELSE(GTK2_GLIBCONFIG_INCLUDE_PATH)
312 MESSAGE(STATUS "Can not find glibconfig")
313 ENDIF(GTK2_GLIBCONFIG_INCLUDE_PATH)
314 ELSE (GTK2_GTK_INCLUDE_PATH)
315 MESSAGE(STATUS "Can not find gtk includes")
316 ENDIF (GTK2_GTK_INCLUDE_PATH)
318 IF (GTK2_FOUND)
319 IF (NOT GTK2_FIND_QUIETLY)
320 MESSAGE(STATUS "Found GTK2: ${GTK2_LIBRARIES}")
321 ENDIF (NOT GTK2_FIND_QUIETLY)
322 ELSE (GTK2_FOUND)
323 IF (GTK2_FIND_REQUIRED)
324 MESSAGE(SEND_ERROR "Could NOT find GTK2")
325 ENDIF (GTK2_FIND_REQUIRED)
326 ENDIF (GTK2_FOUND)
328 MARK_AS_ADVANCED(
329 GTK2_GDK_LIBRARY
330 GTK2_GLIB_INCLUDE_PATH
331 GTK2_GLIB_LIBRARY
332 GTK2_GLIBCONFIG_INCLUDE_PATH
333 GTK2_GMODULE_LIBRARY
334 GTK2_GTHREAD_LIBRARY
335 GTK2_Xi_LIBRARY
336 GTK2_GTK_INCLUDE_PATH
337 GTK2_GTK_LIBRARY
338 GTK2_GTKGL_INCLUDE_PATH
339 GTK2_GTKGL_LIBRARY
340 GTK2_ATK_INCLUDE_PATH
341 GTK2_GDKCONFIG_INCLUDE_PATH
342 #GTK2_GOBJECT_LIBRARY
343 GTK2_PANGO_INCLUDE_PATH
344 )
345 ENDIF(UNIX)
346 ENDIF (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
348 # vim:et ts=2 sw=2 comments=\:\#