summaryrefslogtreecommitdiff
path: root/cmake/modules/FindGTK.cmake
blob: 799bef6bb051060afcee4957ccf0aaf3a6c81d0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# - try to find GTK (and glib)
# Once done this will define
#
#  GLIB_FOUND - system has GLib
#  GLIB_CFLAGS - the GLib CFlags
#  GLIB_LIBRARIES - Link these to use GLib
#
# Copyright 2008 Pino Toscano, <pino@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

include(FindPackageHandleStandardArgs)

if (NOT WIN32)
  include(UsePkgConfig)

  pkgconfig(glib-2.0 _LibGLIB2IncDir _LibGLIB2LinkDir GLIB2LinkFlags GLIB2Cflags)
  pkgconfig(gdk-2.0 _LibGDK2IncDir _LibGDK2LinkDir GDK2LinkFlags GDK2Cflags)
  set (GLIB_FOUND FALSE)
  if (_LibGLIB2IncDir AND _LibGDK2IncDir)

    exec_program(${PKGCONFIG_EXECUTABLE} ARGS --atleast-version=2.6 glib-2.0 RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull)
    if(_return_VALUE STREQUAL "0")
      set(_glib_FOUND TRUE)
    endif(_return_VALUE STREQUAL "0")

    exec_program(${PKGCONFIG_EXECUTABLE} ARGS --atleast-version=2.4.0 gdk-2.0 RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull)
    if(_return_VALUE STREQUAL "0")
      set(_gdk_FOUND TRUE)
    endif(_return_VALUE STREQUAL "0")

    if (_glib_FOUND AND _gdk_FOUND)
      set (GLIB2_CFLAGS ${GLIB2Cflags} ${GDK2Cflags})
      set (GLIB2_LIBRARIES ${GLIB2LinkFlags} ${GDK2LinkFlags})
    endif (_glib_FOUND AND _gdk_FOUND)

    find_package_handle_standard_args(GLib DEFAULT_MSG GLIB2_LIBRARIES GLIB2_CFLAGS)

  endif (_LibGLIB2IncDir AND _LibGDK2IncDir)

  pkgconfig(gtk+-2.0 _LibGTK2IncDir _LibGTK2LinkDir GTK2LinkFlags GTK2Cflags)
  pkgconfig(gdk-pixbuf-2.0 _LibGDK2PixbufIncDir _LibGDK2PixbufLinkDir GDK2PixbufLinkFlags GDK2PixbufCflags)
  pkgconfig(libglade-2.0 _LibGLADE2IncDir _LibGLADE2LinkDir GLADE2LinkFlags GLADE2Cflags)

  if (_LibGTK2IncDir AND _LibGDK2PixbufIncDir AND _LibGLADE2IncDir)

    exec_program(${PKGCONFIG_EXECUTABLE} ARGS --atleast-version=2.8.0 gtk+-2.0 RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull)
    if(_return_VALUE STREQUAL "0")
      set(_gtk_FOUND TRUE)
    endif(_return_VALUE STREQUAL "0")

    if (_gtk_FOUND)
      set (GTK2_CFLAGS ${GTK2Cflags} ${GDK2PixbufCflags} ${GLADE2Cflags})
      set (GTK2_LIBRARIES ${GTK2LinkFlags} ${GDK2PixbufLinkFlags} ${GLADE2LinkFlags})
    endif (_gtk_FOUND)

    find_package_handle_standard_args(GTK DEFAULT_MSG GTK2_LIBRARIES GTK2_CFLAGS)

  endif (_LibGTK2IncDir AND _LibGDK2PixbufIncDir AND _LibGLADE2IncDir)

endif(NOT WIN32)

mark_as_advanced(
  GLIB2_CFLAGS
  GLIB2_LIBRARIES
  GTK2_CFLAGS
  GTK2_LIBRARIES
)