FindX11.cmake 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. # - Find X11 installation
  2. # Try to find X11 on UNIX systems. The following values are defined
  3. # X11_FOUND - True if X11 is available
  4. # X11_INCLUDE_DIR - include directories to use X11
  5. # X11_LIBRARIES - link against these to use X11
  6. #
  7. # and also the following more fine grained variables:
  8. # Include paths: X11_ICE_INCLUDE_PATH, X11_ICE_LIB, X11_ICE_FOUND
  9. # X11_Xaccessrules_INCLUDE_PATH, X11_Xaccess_FOUND
  10. # X11_Xaccessstr_INCLUDE_PATH, X11_Xaccess_FOUND
  11. # X11_Xau_INCLUDE_PATH, X11_Xau_LIB, X11_Xau_FOUND
  12. # X11_Xcomposite_INCLUDE_PATH, X11_Xcomposite_LIB, X11_Xcomposite_FOUND
  13. # X11_Xcursor_INCLUDE_PATH, X11_Xcursor_LIB, X11_Xcursor_FOUND
  14. # X11_Xdamage_INCLUDE_PATH, X11_Xdamage_LIB, X11_Xdamage_FOUND
  15. # X11_Xdmcp_INCLUDE_PATH, X11_Xdmcp_LIB, X11_Xdmcp_FOUND
  16. # X11_Xext_LIB, X11_Xext_FOUND
  17. # X11_dpms_INCLUDE_PATH, (in X11_Xext_LIB), X11_dpms_FOUND
  18. # X11_XShm_INCLUDE_PATH, (in X11_Xext_LIB), X11_XShm_FOUND
  19. # X11_Xshape_INCLUDE_PATH, (in X11_Xext_LIB), X11_Xshape_FOUND
  20. # X11_Xf86misc_INCLUDE_PATH, X11_Xxf86misc_LIB, X11_Xf86misc_FOUND
  21. # X11_xf86vmode_INCLUDE_PATH, X11_Xf86vmode_FOUND
  22. # X11_Xfixes_INCLUDE_PATH, X11_Xfixes_LIB, X11_Xfixes_FOUND
  23. # X11_Xft_INCLUDE_PATH, X11_Xft_LIB, X11_Xft_FOUND
  24. # X11_Xinerama_INCLUDE_PATH, X11_Xinerama_LIB, X11_Xinerama_FOUND
  25. # X11_Xinput_INCLUDE_PATH, X11_Xinput_LIB, X11_Xinput_FOUND
  26. # X11_Xkb_INCLUDE_PATH, X11_Xkb_FOUND
  27. # X11_Xkblib_INCLUDE_PATH, X11_Xkb_FOUND
  28. # X11_Xpm_INCLUDE_PATH, X11_Xpm_LIB, X11_Xpm_FOUND
  29. # X11_XTest_INCLUDE_PATH, X11_XTest_LIB, X11_XTest_FOUND
  30. # X11_Xrandr_INCLUDE_PATH, X11_Xrandr_LIB, X11_Xrandr_FOUND
  31. # X11_Xrender_INCLUDE_PATH, X11_Xrender_LIB, X11_Xrender_FOUND
  32. # X11_Xscreensaver_INCLUDE_PATH, X11_Xscreensaver_LIB, X11_Xscreensaver_FOUND
  33. # X11_Xt_INCLUDE_PATH, X11_Xt_LIB, X11_Xt_FOUND
  34. # X11_Xutil_INCLUDE_PATH, X11_Xutil_FOUND
  35. # X11_Xv_INCLUDE_PATH, X11_Xv_LIB, X11_Xv_FOUND
  36. # Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  37. # See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  38. IF (UNIX)
  39. SET(X11_FOUND 0)
  40. # X11 is never a framework and some header files may be
  41. # found in tcl on the mac
  42. SET(CMAKE_FIND_FRAMEWORK_SAVE ${CMAKE_FIND_FRAMEWORK})
  43. SET(CMAKE_FIND_FRAMEWORK NEVER)
  44. SET(X11_INC_SEARCH_PATH
  45. /usr/pkg/xorg/include
  46. /usr/X11R6/include
  47. /usr/local/include
  48. /usr/include/X11
  49. /usr/openwin/include
  50. /usr/openwin/share/include
  51. /opt/graphics/OpenGL/include
  52. /usr/include
  53. )
  54. SET(X11_LIB_SEARCH_PATH
  55. /usr/pkg/xorg/lib
  56. /usr/X11R6/lib
  57. /usr/local/lib
  58. /usr/openwin/lib
  59. /usr/lib
  60. )
  61. FIND_PATH(X11_X11_INCLUDE_PATH X11/X.h ${X11_INC_SEARCH_PATH})
  62. FIND_PATH(X11_Xlib_INCLUDE_PATH X11/Xlib.h ${X11_INC_SEARCH_PATH})
  63. # Look for includes; keep the list sorted by name of the cmake *_INCLUDE_PATH
  64. # variable (which doesn't need to match the include file name).
  65. # Solaris lacks XKBrules.h, so we should skip kxkbd there.
  66. FIND_PATH(X11_ICE_INCLUDE_PATH X11/ICE/ICE.h ${X11_INC_SEARCH_PATH})
  67. FIND_PATH(X11_Xaccessrules_INCLUDE_PATH X11/extensions/XKBrules.h ${X11_INC_SEARCH_PATH})
  68. FIND_PATH(X11_Xaccessstr_INCLUDE_PATH X11/extensions/XKBstr.h ${X11_INC_SEARCH_PATH})
  69. FIND_PATH(X11_Xau_INCLUDE_PATH X11/Xauth.h ${X11_INC_SEARCH_PATH})
  70. FIND_PATH(X11_Xcomposite_INCLUDE_PATH X11/extensions/Xcomposite.h ${X11_INC_SEARCH_PATH})
  71. FIND_PATH(X11_Xcursor_INCLUDE_PATH X11/Xcursor/Xcursor.h ${X11_INC_SEARCH_PATH})
  72. FIND_PATH(X11_Xdamage_INCLUDE_PATH X11/extensions/Xdamage.h ${X11_INC_SEARCH_PATH})
  73. FIND_PATH(X11_Xdmcp_INCLUDE_PATH X11/Xdmcp.h ${X11_INC_SEARCH_PATH})
  74. FIND_PATH(X11_dpms_INCLUDE_PATH X11/extensions/dpms.h ${X11_INC_SEARCH_PATH})
  75. FIND_PATH(X11_Xf86misc_INCLUDE_PATH X11/extensions/xf86misc.h ${X11_INC_SEARCH_PATH})
  76. FIND_PATH(X11_xf86vmode_INCLUDE_PATH X11/extensions/xf86vmode.h ${X11_INC_SEARCH_PATH})
  77. FIND_PATH(X11_Xfixes_INCLUDE_PATH X11/extensions/Xfixes.h ${X11_INC_SEARCH_PATH})
  78. FIND_PATH(X11_Xft_INCLUDE_PATH X11/Xft/Xft.h ${X11_INC_SEARCH_PATH})
  79. FIND_PATH(X11_Xinerama_INCLUDE_PATH X11/extensions/Xinerama.h ${X11_INC_SEARCH_PATH})
  80. FIND_PATH(X11_Xinput_INCLUDE_PATH X11/extensions/XInput.h ${X11_INC_SEARCH_PATH})
  81. FIND_PATH(X11_Xkb_INCLUDE_PATH X11/extensions/XKB.h ${X11_INC_SEARCH_PATH})
  82. FIND_PATH(X11_Xkblib_INCLUDE_PATH X11/XKBlib.h ${X11_INC_SEARCH_PATH})
  83. FIND_PATH(X11_Xpm_INCLUDE_PATH X11/xpm.h ${X11_INC_SEARCH_PATH})
  84. FIND_PATH(X11_XTest_INCLUDE_PATH X11/extensions/XTest.h ${X11_INC_SEARCH_PATH})
  85. FIND_PATH(X11_XShm_INCLUDE_PATH X11/extensions/XShm.h ${X11_INC_SEARCH_PATH})
  86. FIND_PATH(X11_Xrandr_INCLUDE_PATH X11/extensions/Xrandr.h ${X11_INC_SEARCH_PATH})
  87. FIND_PATH(X11_Xrender_INCLUDE_PATH X11/extensions/Xrender.h ${X11_INC_SEARCH_PATH})
  88. FIND_PATH(X11_Xscreensaver_INCLUDE_PATH X11/extensions/scrnsaver.h ${X11_INC_SEARCH_PATH})
  89. FIND_PATH(X11_Xshape_INCLUDE_PATH X11/extensions/shape.h ${X11_INC_SEARCH_PATH})
  90. FIND_PATH(X11_Xutil_INCLUDE_PATH X11/Xutil.h ${X11_INC_SEARCH_PATH})
  91. FIND_PATH(X11_Xt_INCLUDE_PATH X11/Intrinsic.h ${X11_INC_SEARCH_PATH})
  92. FIND_PATH(X11_Xv_INCLUDE_PATH X11/extensions/Xvlib.h ${X11_INC_SEARCH_PATH})
  93. FIND_LIBRARY(X11_X11_LIB X11 ${X11_LIB_SEARCH_PATH})
  94. # Find additional X libraries. Keep list sorted by library name.
  95. FIND_LIBRARY(X11_ICE_LIB ICE ${X11_LIB_SEARCH_PATH})
  96. FIND_LIBRARY(X11_Xau_LIB Xau ${X11_LIB_SEARCH_PATH})
  97. FIND_LIBRARY(X11_Xcomposite_LIB Xcomposite ${X11_LIB_SEARCH_PATH})
  98. FIND_LIBRARY(X11_Xcursor_LIB Xcursor ${X11_LIB_SEARCH_PATH})
  99. FIND_LIBRARY(X11_Xdamage_LIB Xdamage ${X11_LIB_SEARCH_PATH})
  100. FIND_LIBRARY(X11_Xdmcp_LIB Xdmcp ${X11_LIB_SEARCH_PATH})
  101. FIND_LIBRARY(X11_Xext_LIB Xext ${X11_LIB_SEARCH_PATH})
  102. FIND_LIBRARY(X11_Xfixes_LIB Xfixes ${X11_LIB_SEARCH_PATH})
  103. FIND_LIBRARY(X11_Xft_LIB Xft ${X11_LIB_SEARCH_PATH})
  104. FIND_LIBRARY(X11_Xinerama_LIB Xinerama ${X11_LIB_SEARCH_PATH})
  105. FIND_LIBRARY(X11_Xinput_LIB Xi ${X11_LIB_SEARCH_PATH})
  106. FIND_LIBRARY(X11_Xpm_LIB Xpm ${X11_LIB_SEARCH_PATH})
  107. FIND_LIBRARY(X11_Xrandr_LIB Xrandr ${X11_LIB_SEARCH_PATH})
  108. FIND_LIBRARY(X11_Xrender_LIB Xrender ${X11_LIB_SEARCH_PATH})
  109. FIND_LIBRARY(X11_Xscreensaver_LIB Xss ${X11_LIB_SEARCH_PATH})
  110. FIND_LIBRARY(X11_Xt_LIB Xt ${X11_LIB_SEARCH_PATH})
  111. FIND_LIBRARY(X11_XTest_LIB Xtst ${X11_LIB_SEARCH_PATH})
  112. FIND_LIBRARY(X11_Xv_LIB Xv ${X11_LIB_SEARCH_PATH})
  113. FIND_LIBRARY(X11_Xxf86misc_LIB Xxf86misc ${X11_LIB_SEARCH_PATH})
  114. SET(X11_LIBRARY_DIR "")
  115. IF(X11_X11_LIB)
  116. GET_FILENAME_COMPONENT(X11_LIBRARY_DIR ${X11_X11_LIB} PATH)
  117. ENDIF(X11_X11_LIB)
  118. IF(X11_X11_INCLUDE_PATH)
  119. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_X11_INCLUDE_PATH})
  120. ENDIF(X11_X11_INCLUDE_PATH)
  121. IF(X11_Xlib_INCLUDE_PATH)
  122. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xlib_INCLUDE_PATH})
  123. ENDIF(X11_Xlib_INCLUDE_PATH)
  124. IF(X11_Xutil_INCLUDE_PATH)
  125. SET(X11_Xutil_FOUND TRUE)
  126. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xutil_INCLUDE_PATH})
  127. ENDIF(X11_Xutil_INCLUDE_PATH)
  128. IF(X11_Xshape_INCLUDE_PATH)
  129. SET(X11_Xshape_FOUND TRUE)
  130. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xshape_INCLUDE_PATH})
  131. ENDIF(X11_Xshape_INCLUDE_PATH)
  132. IF(X11_X11_LIB)
  133. SET(X11_LIBRARIES ${X11_LIBRARIES} ${X11_X11_LIB})
  134. ENDIF(X11_X11_LIB)
  135. IF(X11_Xext_LIB)
  136. SET(X11_Xext_FOUND TRUE)
  137. SET(X11_LIBRARIES ${X11_LIBRARIES} ${X11_Xext_LIB})
  138. ENDIF(X11_Xext_LIB)
  139. IF(X11_Xt_LIB AND X11_Xt_INCLUDE_PATH)
  140. SET(X11_Xt_FOUND TRUE)
  141. ENDIF(X11_Xt_LIB AND X11_Xt_INCLUDE_PATH)
  142. IF(X11_Xft_LIB AND X11_Xft_INCLUDE_PATH)
  143. SET(X11_Xft_FOUND TRUE)
  144. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xft_INCLUDE_PATH})
  145. ENDIF(X11_Xft_LIB AND X11_Xft_INCLUDE_PATH)
  146. IF(X11_Xv_LIB AND X11_Xv_INCLUDE_PATH)
  147. SET(X11_Xv_FOUND TRUE)
  148. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xv_INCLUDE_PATH})
  149. ENDIF(X11_Xv_LIB AND X11_Xv_INCLUDE_PATH)
  150. IF (X11_Xau_LIB AND X11_Xau_INCLUDE_PATH)
  151. SET(X11_Xau_FOUND TRUE)
  152. ENDIF (X11_Xau_LIB AND X11_Xau_INCLUDE_PATH)
  153. IF (X11_Xdmcp_INCLUDE_PATH AND X11_Xdmcp_LIB)
  154. SET(X11_Xdmcp_FOUND TRUE)
  155. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xdmcp_INCLUDE_PATH})
  156. ENDIF (X11_Xdmcp_INCLUDE_PATH AND X11_Xdmcp_LIB)
  157. IF (X11_Xaccessrules_INCLUDE_PATH AND X11_Xaccessstr_INCLUDE_PATH)
  158. SET(X11_Xaccess_FOUND TRUE)
  159. SET(X11_Xaccess_INCLUDE_PATH ${X11_Xaccessstr_INCLUDE_PATH})
  160. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xaccess_INCLUDE_PATH})
  161. ENDIF (X11_Xaccessrules_INCLUDE_PATH AND X11_Xaccessstr_INCLUDE_PATH)
  162. IF (X11_Xpm_INCLUDE_PATH AND X11_Xpm_LIB)
  163. SET(X11_Xpm_FOUND TRUE)
  164. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xpm_INCLUDE_PATH})
  165. ENDIF (X11_Xpm_INCLUDE_PATH AND X11_Xpm_LIB)
  166. IF (X11_Xcomposite_INCLUDE_PATH AND X11_Xcomposite_LIB)
  167. SET(X11_Xcomposite_FOUND TRUE)
  168. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xcomposite_INCLUDE_PATH})
  169. ENDIF (X11_Xcomposite_INCLUDE_PATH AND X11_Xcomposite_LIB)
  170. IF (X11_Xdamage_INCLUDE_PATH AND X11_Xdamage_LIB)
  171. SET(X11_Xdamage_FOUND TRUE)
  172. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xdamage_INCLUDE_PATH})
  173. ENDIF (X11_Xdamage_INCLUDE_PATH AND X11_Xdamage_LIB)
  174. IF (X11_XShm_INCLUDE_PATH)
  175. SET(X11_XShm_FOUND TRUE)
  176. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_XShm_INCLUDE_PATH})
  177. ENDIF (X11_XShm_INCLUDE_PATH)
  178. IF (X11_XTest_INCLUDE_PATH AND X11_XTest_LIB)
  179. SET(X11_XTest_FOUND TRUE)
  180. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_XTest_INCLUDE_PATH})
  181. ENDIF (X11_XTest_INCLUDE_PATH AND X11_XTest_LIB)
  182. IF (X11_Xinerama_INCLUDE_PATH AND X11_Xinerama_LIB)
  183. SET(X11_Xinerama_FOUND TRUE)
  184. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xinerama_INCLUDE_PATH})
  185. ENDIF (X11_Xinerama_INCLUDE_PATH AND X11_Xinerama_LIB)
  186. IF (X11_Xfixes_INCLUDE_PATH AND X11_Xfixes_LIB)
  187. SET(X11_Xfixes_FOUND TRUE)
  188. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xfixes_INCLUDE_PATH})
  189. ENDIF (X11_Xfixes_INCLUDE_PATH AND X11_Xfixes_LIB)
  190. IF (X11_Xrender_INCLUDE_PATH AND X11_Xrender_LIB)
  191. SET(X11_Xrender_FOUND TRUE)
  192. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xrender_INCLUDE_PATH})
  193. ENDIF (X11_Xrender_INCLUDE_PATH AND X11_Xrender_LIB)
  194. IF (X11_Xrandr_INCLUDE_PATH AND X11_Xrandr_LIB)
  195. SET(X11_Xrandr_FOUND TRUE)
  196. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xrandr_INCLUDE_PATH})
  197. ENDIF (X11_Xrandr_INCLUDE_PATH AND X11_Xrandr_LIB)
  198. IF (X11_Xxf86misc_INCLUDE_PATH AND X11_Xxf86misc_LIB)
  199. SET(X11_Xxf86misc_FOUND TRUE)
  200. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xxf86misc_INCLUDE_PATH})
  201. ENDIF (X11_Xxf86misc_INCLUDE_PATH AND X11_Xxf86misc_LIB)
  202. IF (X11_xf86vmode_INCLUDE_PATH)
  203. SET(X11_xf86vmode_FOUND TRUE)
  204. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_xf86vmode_INCLUDE_PATH})
  205. ENDIF (X11_xf86vmode_INCLUDE_PATH)
  206. IF (X11_Xcursor_INCLUDE_PATH AND X11_Xcursor_LIB)
  207. SET(X11_Xcursor_FOUND TRUE)
  208. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xcursor_INCLUDE_PATH})
  209. ENDIF (X11_Xcursor_INCLUDE_PATH AND X11_Xcursor_LIB)
  210. IF (X11_Xscreensaver_INCLUDE_PATH AND X11_Xscreensaver_LIB)
  211. SET(X11_Xscreensaver_FOUND TRUE)
  212. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xscreensaver_INCLUDE_PATH})
  213. ENDIF (X11_Xscreensaver_INCLUDE_PATH AND X11_Xscreensaver_LIB)
  214. IF (X11_dpms_INCLUDE_PATH)
  215. SET(X11_dpms_FOUND TRUE)
  216. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_dpms_INCLUDE_PATH})
  217. ENDIF (X11_dpms_INCLUDE_PATH)
  218. IF (X11_Xkb_INCLUDE_PATH AND X11_Xkblib_INCLUDE_PATH AND X11_Xlib_INCLUDE_PATH)
  219. SET(X11_Xkb_FOUND TRUE)
  220. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xkb_INCLUDE_PATH} )
  221. ENDIF (X11_Xkb_INCLUDE_PATH AND X11_Xkblib_INCLUDE_PATH AND X11_Xlib_INCLUDE_PATH)
  222. IF (X11_Xinput_INCLUDE_PATH AND X11_Xinput_LIB)
  223. SET(X11_Xinput_FOUND TRUE)
  224. SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xinput_INCLUDE_PATH})
  225. ENDIF (X11_Xinput_INCLUDE_PATH AND X11_Xinput_LIB)
  226. IF(X11_ICE_LIB AND X11_ICE_INCLUDE_PATH)
  227. SET(X11_ICE_FOUND TRUE)
  228. ENDIF(X11_ICE_LIB AND X11_ICE_INCLUDE_PATH)
  229. # Deprecated variable for backwards compatibility with CMake 1.4
  230. IF (X11_X11_INCLUDE_PATH AND X11_LIBRARIES)
  231. SET(X11_FOUND 1)
  232. ENDIF (X11_X11_INCLUDE_PATH AND X11_LIBRARIES)
  233. IF(X11_FOUND)
  234. INCLUDE(CheckFunctionExists)
  235. INCLUDE(CheckLibraryExists)
  236. # Translated from an autoconf-generated configure script.
  237. # See libs.m4 in autoconf's m4 directory.
  238. IF($ENV{ISC} MATCHES "^yes$")
  239. SET(X11_X_EXTRA_LIBS -lnsl_s -linet)
  240. ELSE($ENV{ISC} MATCHES "^yes$")
  241. SET(X11_X_EXTRA_LIBS "")
  242. # See if XOpenDisplay in X11 works by itself.
  243. CHECK_LIBRARY_EXISTS("${X11_LIBRARIES}" "XOpenDisplay" "${X11_LIBRARY_DIR}" X11_LIB_X11_SOLO)
  244. IF(NOT X11_LIB_X11_SOLO)
  245. # Find library needed for dnet_ntoa.
  246. CHECK_LIBRARY_EXISTS("dnet" "dnet_ntoa" "" X11_LIB_DNET_HAS_DNET_NTOA)
  247. IF (X11_LIB_DNET_HAS_DNET_NTOA)
  248. SET (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -ldnet)
  249. ELSE (X11_LIB_DNET_HAS_DNET_NTOA)
  250. CHECK_LIBRARY_EXISTS("dnet_stub" "dnet_ntoa" "" X11_LIB_DNET_STUB_HAS_DNET_NTOA)
  251. IF (X11_LIB_DNET_STUB_HAS_DNET_NTOA)
  252. SET (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -ldnet_stub)
  253. ENDIF (X11_LIB_DNET_STUB_HAS_DNET_NTOA)
  254. ENDIF (X11_LIB_DNET_HAS_DNET_NTOA)
  255. ENDIF(NOT X11_LIB_X11_SOLO)
  256. # Find library needed for gethostbyname.
  257. CHECK_FUNCTION_EXISTS("gethostbyname" CMAKE_HAVE_GETHOSTBYNAME)
  258. IF(NOT CMAKE_HAVE_GETHOSTBYNAME)
  259. CHECK_LIBRARY_EXISTS("nsl" "gethostbyname" "" CMAKE_LIB_NSL_HAS_GETHOSTBYNAME)
  260. IF (CMAKE_LIB_NSL_HAS_GETHOSTBYNAME)
  261. SET (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -lnsl)
  262. ELSE (CMAKE_LIB_NSL_HAS_GETHOSTBYNAME)
  263. CHECK_LIBRARY_EXISTS("bsd" "gethostbyname" "" CMAKE_LIB_BSD_HAS_GETHOSTBYNAME)
  264. IF (CMAKE_LIB_BSD_HAS_GETHOSTBYNAME)
  265. SET (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -lbsd)
  266. ENDIF (CMAKE_LIB_BSD_HAS_GETHOSTBYNAME)
  267. ENDIF (CMAKE_LIB_NSL_HAS_GETHOSTBYNAME)
  268. ENDIF(NOT CMAKE_HAVE_GETHOSTBYNAME)
  269. # Find library needed for connect.
  270. CHECK_FUNCTION_EXISTS("connect" CMAKE_HAVE_CONNECT)
  271. IF(NOT CMAKE_HAVE_CONNECT)
  272. CHECK_LIBRARY_EXISTS("socket" "connect" "" CMAKE_LIB_SOCKET_HAS_CONNECT)
  273. IF (CMAKE_LIB_SOCKET_HAS_CONNECT)
  274. SET (X11_X_EXTRA_LIBS -lsocket ${X11_X_EXTRA_LIBS})
  275. ENDIF (CMAKE_LIB_SOCKET_HAS_CONNECT)
  276. ENDIF(NOT CMAKE_HAVE_CONNECT)
  277. # Find library needed for remove.
  278. CHECK_FUNCTION_EXISTS("remove" CMAKE_HAVE_REMOVE)
  279. IF(NOT CMAKE_HAVE_REMOVE)
  280. CHECK_LIBRARY_EXISTS("posix" "remove" "" CMAKE_LIB_POSIX_HAS_REMOVE)
  281. IF (CMAKE_LIB_POSIX_HAS_REMOVE)
  282. SET (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -lposix)
  283. ENDIF (CMAKE_LIB_POSIX_HAS_REMOVE)
  284. ENDIF(NOT CMAKE_HAVE_REMOVE)
  285. # Find library needed for shmat.
  286. CHECK_FUNCTION_EXISTS("shmat" CMAKE_HAVE_SHMAT)
  287. IF(NOT CMAKE_HAVE_SHMAT)
  288. CHECK_LIBRARY_EXISTS("ipc" "shmat" "" CMAKE_LIB_IPS_HAS_SHMAT)
  289. IF (CMAKE_LIB_IPS_HAS_SHMAT)
  290. SET (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -lipc)
  291. ENDIF (CMAKE_LIB_IPS_HAS_SHMAT)
  292. ENDIF(NOT CMAKE_HAVE_SHMAT)
  293. ENDIF($ENV{ISC} MATCHES "^yes$")
  294. IF (X11_ICE_FOUND)
  295. CHECK_LIBRARY_EXISTS("ICE" "IceConnectionNumber" "${X11_LIBRARY_DIR}"
  296. CMAKE_LIB_ICE_HAS_ICECONNECTIONNUMBER)
  297. IF(CMAKE_LIB_ICE_HAS_ICECONNECTIONNUMBER)
  298. SET (X11_X_PRE_LIBS -lSM ${X11_ICE_LIB})
  299. ENDIF(CMAKE_LIB_ICE_HAS_ICECONNECTIONNUMBER)
  300. ENDIF (X11_ICE_FOUND)
  301. # Build the final list of libraries.
  302. SET(X11_LIBRARIES ${X11_X_PRE_LIBS} ${X11_LIBRARIES} ${X11_X_EXTRA_LIBS})
  303. MESSAGE(STATUS "Found X11: ${X11_X11_LIB}")
  304. ELSE (X11_FOUND)
  305. IF (X11_FIND_REQUIRED)
  306. MESSAGE(FATAL_ERROR "Could not find X11")
  307. ENDIF (X11_FIND_REQUIRED)
  308. ENDIF (X11_FOUND)
  309. MARK_AS_ADVANCED(
  310. X11_X11_INCLUDE_PATH
  311. X11_X11_LIB
  312. X11_Xext_LIB
  313. X11_Xau_LIB
  314. X11_Xau_INCLUDE_PATH
  315. X11_Xlib_INCLUDE_PATH
  316. X11_Xutil_INCLUDE_PATH
  317. X11_Xcomposite_INCLUDE_PATH
  318. X11_Xcomposite_LIB
  319. X11_Xaccess_INCLUDE_PATH
  320. X11_Xfixes_LIB
  321. X11_Xfixes_INCLUDE_PATH
  322. X11_Xrandr_LIB
  323. X11_Xrandr_INCLUDE_PATH
  324. X11_Xdamage_LIB
  325. X11_Xdamage_INCLUDE_PATH
  326. X11_Xrender_LIB
  327. X11_Xrender_INCLUDE_PATH
  328. X11_Xxf86misc_LIB
  329. X11_Xxf86misc_INCLUDE_PATH
  330. X11_xf86vmode_INCLUDE_PATH
  331. X11_Xinerama_LIB
  332. X11_Xinerama_INCLUDE_PATH
  333. X11_XTest_LIB
  334. X11_XTest_INCLUDE_PATH
  335. X11_Xcursor_LIB
  336. X11_Xcursor_INCLUDE_PATH
  337. X11_dpms_INCLUDE_PATH
  338. X11_Xt_LIB
  339. X11_Xt_INCLUDE_PATH
  340. X11_Xdmcp_LIB
  341. X11_LIBRARIES
  342. X11_Xaccessrules_INCLUDE_PATH
  343. X11_Xaccessstr_INCLUDE_PATH
  344. X11_Xdmcp_INCLUDE_PATH
  345. X11_Xf86misc_INCLUDE_PATH
  346. X11_Xkb_INCLUDE_PATH
  347. X11_Xkblib_INCLUDE_PATH
  348. X11_Xscreensaver_INCLUDE_PATH
  349. X11_Xscreensaver_LIB
  350. X11_Xpm_INCLUDE_PATH
  351. X11_Xpm_LIB
  352. X11_Xinput_LIB
  353. X11_Xinput_INCLUDE_PATH
  354. X11_Xft_LIB
  355. X11_Xft_INCLUDE_PATH
  356. X11_Xshape_INCLUDE_PATH
  357. X11_Xv_LIB
  358. X11_Xv_INCLUDE_PATH
  359. X11_XShm_INCLUDE_PATH
  360. X11_ICE_LIB
  361. X11_ICE_INCLUDE_PATH
  362. )
  363. SET(CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_SAVE})
  364. ENDIF (UNIX)
  365. # X11_FIND_REQUIRED_<component> could be checked too