FindX11.cmake 19 KB

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