FindGTK.cmake 3.8 KB

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