FindGTK.cmake 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #.rst:
  2. # FindGTK
  3. # -------
  4. #
  5. # try to find GTK (and glib) and GTKGLArea
  6. #
  7. # ::
  8. #
  9. # GTK_INCLUDE_DIR - Directories to include to use GTK
  10. # GTK_LIBRARIES - Files to link against to use GTK
  11. # GTK_FOUND - GTK was found
  12. # GTK_GL_FOUND - GTK's GL features were found
  13. #=============================================================================
  14. # Copyright 2001-2009 Kitware, Inc.
  15. #
  16. # Distributed under the OSI-approved BSD License (the "License");
  17. # see accompanying file Copyright.txt for details.
  18. #
  19. # This software is distributed WITHOUT ANY WARRANTY; without even the
  20. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  21. # See the License for more information.
  22. #=============================================================================
  23. # (To distribute this file outside of CMake, substitute the full
  24. # License text for the above reference.)
  25. # don't even bother under WIN32
  26. if(UNIX)
  27. find_path( GTK_gtk_INCLUDE_PATH NAMES gtk/gtk.h
  28. PATH_SUFFIXES gtk-1.2 gtk12
  29. PATHS
  30. /usr/openwin/share/include
  31. /usr/openwin/include
  32. /opt/gnome/include
  33. )
  34. # Some Linux distributions (e.g. Red Hat) have glibconfig.h
  35. # and glib.h in different directories, so we need to look
  36. # for both.
  37. # - Atanas Georgiev <atanas@cs.columbia.edu>
  38. find_path( GTK_glibconfig_INCLUDE_PATH NAMES glibconfig.h
  39. PATHS
  40. /usr/openwin/share/include
  41. /usr/local/include/glib12
  42. /usr/lib/glib/include
  43. /usr/local/lib/glib/include
  44. /opt/gnome/include
  45. /opt/gnome/lib/glib/include
  46. )
  47. find_path( GTK_glib_INCLUDE_PATH NAMES glib.h
  48. PATH_SUFFIXES gtk-1.2 glib-1.2 glib12
  49. PATHS
  50. /usr/openwin/share/include
  51. /usr/lib/glib/include
  52. /opt/gnome/include
  53. )
  54. find_path( GTK_gtkgl_INCLUDE_PATH NAMES gtkgl/gtkglarea.h
  55. PATHS /usr/openwin/share/include
  56. /opt/gnome/include
  57. )
  58. find_library( GTK_gtkgl_LIBRARY gtkgl
  59. /usr/openwin/lib
  60. /opt/gnome/lib
  61. )
  62. #
  63. # The 12 suffix is thanks to the FreeBSD ports collection
  64. #
  65. find_library( GTK_gtk_LIBRARY
  66. NAMES gtk gtk12
  67. PATHS /usr/openwin/lib
  68. /opt/gnome/lib
  69. )
  70. find_library( GTK_gdk_LIBRARY
  71. NAMES gdk gdk12
  72. PATHS /usr/openwin/lib
  73. /opt/gnome/lib
  74. )
  75. find_library( GTK_gmodule_LIBRARY
  76. NAMES gmodule gmodule12
  77. PATHS /usr/openwin/lib
  78. /opt/gnome/lib
  79. )
  80. find_library( GTK_glib_LIBRARY
  81. NAMES glib glib12
  82. PATHS /usr/openwin/lib
  83. /opt/gnome/lib
  84. )
  85. find_library( GTK_Xi_LIBRARY
  86. NAMES Xi
  87. PATHS /usr/openwin/lib
  88. /opt/gnome/lib
  89. )
  90. find_library( GTK_gthread_LIBRARY
  91. NAMES gthread gthread12
  92. PATHS /usr/openwin/lib
  93. /opt/gnome/lib
  94. )
  95. if(GTK_gtk_INCLUDE_PATH
  96. AND GTK_glibconfig_INCLUDE_PATH
  97. AND GTK_glib_INCLUDE_PATH
  98. AND GTK_gtk_LIBRARY
  99. AND GTK_glib_LIBRARY)
  100. # Assume that if gtk and glib were found, the other
  101. # supporting libraries have also been found.
  102. set( GTK_FOUND "YES" )
  103. set( GTK_INCLUDE_DIR ${GTK_gtk_INCLUDE_PATH}
  104. ${GTK_glibconfig_INCLUDE_PATH}
  105. ${GTK_glib_INCLUDE_PATH} )
  106. set( GTK_LIBRARIES ${GTK_gtk_LIBRARY}
  107. ${GTK_gdk_LIBRARY}
  108. ${GTK_glib_LIBRARY} )
  109. if(GTK_gmodule_LIBRARY)
  110. set(GTK_LIBRARIES ${GTK_LIBRARIES} ${GTK_gmodule_LIBRARY})
  111. endif()
  112. if(GTK_gthread_LIBRARY)
  113. set(GTK_LIBRARIES ${GTK_LIBRARIES} ${GTK_gthread_LIBRARY})
  114. endif()
  115. if(GTK_Xi_LIBRARY)
  116. set(GTK_LIBRARIES ${GTK_LIBRARIES} ${GTK_Xi_LIBRARY})
  117. endif()
  118. if(GTK_gtkgl_INCLUDE_PATH AND GTK_gtkgl_LIBRARY)
  119. set( GTK_GL_FOUND "YES" )
  120. set( GTK_INCLUDE_DIR ${GTK_INCLUDE_DIR}
  121. ${GTK_gtkgl_INCLUDE_PATH} )
  122. set( GTK_LIBRARIES ${GTK_gtkgl_LIBRARY} ${GTK_LIBRARIES} )
  123. mark_as_advanced(
  124. GTK_gtkgl_LIBRARY
  125. GTK_gtkgl_INCLUDE_PATH
  126. )
  127. endif()
  128. endif()
  129. mark_as_advanced(
  130. GTK_gdk_LIBRARY
  131. GTK_glib_INCLUDE_PATH
  132. GTK_glib_LIBRARY
  133. GTK_glibconfig_INCLUDE_PATH
  134. GTK_gmodule_LIBRARY
  135. GTK_gthread_LIBRARY
  136. GTK_Xi_LIBRARY
  137. GTK_gtk_INCLUDE_PATH
  138. GTK_gtk_LIBRARY
  139. GTK_gtkgl_INCLUDE_PATH
  140. GTK_gtkgl_LIBRARY
  141. )
  142. endif()