🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1338 lines
45 KiB

  1. include(CMakeParseArguments)
  2. include(${SDL2_SOURCE_DIR}/cmake/sdlfind.cmake)
  3. macro(FindLibraryAndSONAME _LIB)
  4. cmake_parse_arguments(FLAS "" "" "LIBDIRS" ${ARGN})
  5. string(TOUPPER ${_LIB} _UPPERLNAME)
  6. string(REGEX REPLACE "\\-" "_" _LNAME "${_UPPERLNAME}")
  7. find_library(${_LNAME}_LIB ${_LIB} PATHS ${FLAS_LIBDIRS})
  8. if(${_LNAME}_LIB MATCHES ".*\\${CMAKE_SHARED_LIBRARY_SUFFIX}.*" AND NOT ${_LNAME}_LIB MATCHES ".*\\${CMAKE_STATIC_LIBRARY_SUFFIX}.*")
  9. set(${_LNAME}_SHARED TRUE)
  10. else()
  11. set(${_LNAME}_SHARED FALSE)
  12. endif()
  13. if(${_LNAME}_LIB)
  14. # reduce the library name for shared linking
  15. get_filename_component(_LIB_REALPATH ${${_LNAME}_LIB} REALPATH) # resolves symlinks
  16. get_filename_component(_LIB_JUSTNAME ${_LIB_REALPATH} NAME)
  17. if(APPLE)
  18. string(REGEX REPLACE "(\\.[0-9]*)\\.[0-9\\.]*dylib$" "\\1.dylib" _LIB_REGEXD "${_LIB_JUSTNAME}")
  19. else()
  20. string(REGEX REPLACE "(\\.[0-9]*)\\.[0-9\\.]*$" "\\1" _LIB_REGEXD "${_LIB_JUSTNAME}")
  21. endif()
  22. SET(_DEBUG_FindSONAME FALSE)
  23. if(_DEBUG_FindSONAME)
  24. message_warn("DYNLIB OUTPUTVAR: ${_LIB} ... ${_LNAME}_LIB")
  25. message_warn("DYNLIB ORIGINAL LIB: ${_LIB} ... ${${_LNAME}_LIB}")
  26. message_warn("DYNLIB REALPATH LIB: ${_LIB} ... ${_LIB_REALPATH}")
  27. message_warn("DYNLIB JUSTNAME LIB: ${_LIB} ... ${_LIB_JUSTNAME}")
  28. message_warn("DYNLIB REGEX'd LIB: ${_LIB} ... ${_LIB_REGEXD}")
  29. endif()
  30. message(STATUS "dynamic lib${_LIB} -> ${_LIB_REGEXD}")
  31. set(${_LNAME}_LIB_SONAME ${_LIB_REGEXD})
  32. endif()
  33. endmacro()
  34. macro(CheckDLOPEN)
  35. cmake_push_check_state(RESET)
  36. check_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN_IN_LIBC)
  37. if(NOT HAVE_DLOPEN_IN_LIBC)
  38. set(CMAKE_REQUIRED_LIBRARIES dl)
  39. check_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN_IN_LIBDL)
  40. if(HAVE_DLOPEN_IN_LIBDL)
  41. list(APPEND EXTRA_LIBS dl)
  42. endif()
  43. endif()
  44. if(HAVE_DLOPEN_IN_LIBC OR HAVE_DLOPEN_IN_LIBDL)
  45. set(HAVE_DLOPEN TRUE)
  46. endif()
  47. cmake_pop_check_state()
  48. endmacro()
  49. macro(CheckO_CLOEXEC)
  50. check_c_source_compiles("
  51. #include <fcntl.h>
  52. int flag = O_CLOEXEC;
  53. int main(int argc, char **argv) { return 0; }" HAVE_O_CLOEXEC)
  54. endmacro()
  55. # Requires:
  56. # - n/a
  57. macro(CheckOSS)
  58. if(SDL_OSS)
  59. check_c_source_compiles("
  60. #include <sys/soundcard.h>
  61. int main(int argc, char **argv) { int arg = SNDCTL_DSP_SETFRAGMENT; return 0; }" HAVE_OSS_SYS_SOUNDCARD_H)
  62. if(HAVE_OSS_SYS_SOUNDCARD_H)
  63. set(HAVE_OSS TRUE)
  64. file(GLOB OSS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/dsp/*.c)
  65. set(SDL_AUDIO_DRIVER_OSS 1)
  66. list(APPEND SOURCE_FILES ${OSS_SOURCES})
  67. if(NETBSD)
  68. list(APPEND EXTRA_LIBS ossaudio)
  69. endif()
  70. set(HAVE_SDL_AUDIO TRUE)
  71. endif()
  72. endif()
  73. endmacro()
  74. # Requires:
  75. # - n/a
  76. # Optional:
  77. # - SDL_ALSA_SHARED opt
  78. # - HAVE_SDL_LOADSO opt
  79. macro(CheckALSA)
  80. if(SDL_ALSA)
  81. sdlFindALSA()
  82. if(ALSA_FOUND)
  83. file(GLOB ALSA_SOURCES "${SDL2_SOURCE_DIR}/src/audio/alsa/*.c")
  84. list(APPEND SOURCE_FILES ${ALSA_SOURCES})
  85. set(SDL_AUDIO_DRIVER_ALSA 1)
  86. set(HAVE_ALSA TRUE)
  87. set(HAVE_ALSA_SHARED FALSE)
  88. if(SDL_ALSA_SHARED)
  89. if(HAVE_SDL_LOADSO)
  90. FindLibraryAndSONAME("asound")
  91. if(ASOUND_LIB AND ASOUND_SHARED)
  92. target_include_directories(sdl-build-options INTERFACE $<TARGET_PROPERTY:ALSA::ALSA,INTERFACE_INCLUDE_DIRECTORIES>)
  93. set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"")
  94. set(HAVE_ALSA_SHARED TRUE)
  95. else()
  96. message(WARNING "Unable to find asound shared object")
  97. endif()
  98. else()
  99. message(WARNING "You must have SDL_LoadObject() support for dynamic ALSA loading")
  100. endif()
  101. endif()
  102. if(NOT HAVE_ALSA_SHARED)
  103. list(APPEND CMAKE_DEPENDS ALSA::ALSA)
  104. list(APPEND PKGCONFIG_DEPENDS alsa)
  105. endif()
  106. set(HAVE_SDL_AUDIO TRUE)
  107. else()
  108. set(HAVE_ALSA FALSE)
  109. message(WARNING "Unable to found the alsa development library")
  110. endif()
  111. endif()
  112. endmacro()
  113. # Requires:
  114. # - PkgCheckModules
  115. # Optional:
  116. # - SDL_PIPEWIRE_SHARED opt
  117. # - HAVE_SDL_LOADSO opt
  118. macro(CheckPipewire)
  119. if(SDL_PIPEWIRE)
  120. pkg_check_modules(PKG_PIPEWIRE libpipewire-0.3>=0.3.20)
  121. if(PKG_PIPEWIRE_FOUND)
  122. set(HAVE_PIPEWIRE TRUE)
  123. file(GLOB PIPEWIRE_SOURCES ${SDL2_SOURCE_DIR}/src/audio/pipewire/*.c)
  124. list(APPEND SOURCE_FILES ${PIPEWIRE_SOURCES})
  125. set(SDL_AUDIO_DRIVER_PIPEWIRE 1)
  126. list(APPEND EXTRA_CFLAGS ${PKG_PIPEWIRE_CFLAGS})
  127. if(SDL_PIPEWIRE_SHARED AND NOT HAVE_SDL_LOADSO)
  128. message_warn("You must have SDL_LoadObject() support for dynamic Pipewire loading")
  129. endif()
  130. FindLibraryAndSONAME("pipewire-0.3" LIBDIRS ${PKG_PIPEWIRE_LIBRARY_DIRS})
  131. if(SDL_PIPEWIRE_SHARED AND PIPEWIRE_0.3_LIB AND HAVE_SDL_LOADSO)
  132. set(SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC "\"${PIPEWIRE_0.3_LIB_SONAME}\"")
  133. set(HAVE_PIPEWIRE_SHARED TRUE)
  134. else()
  135. list(APPEND EXTRA_LDFLAGS ${PKG_PIPEWIRE_LDFLAGS})
  136. endif()
  137. set(HAVE_SDL_AUDIO TRUE)
  138. endif()
  139. endif()
  140. endmacro()
  141. # Requires:
  142. # - PkgCheckModules
  143. # Optional:
  144. # - SDL_PULSEAUDIO_SHARED opt
  145. # - HAVE_SDL_LOADSO opt
  146. macro(CheckPulseAudio)
  147. if(SDL_PULSEAUDIO)
  148. pkg_check_modules(PKG_PULSEAUDIO libpulse-simple)
  149. if(PKG_PULSEAUDIO_FOUND)
  150. set(HAVE_PULSEAUDIO TRUE)
  151. file(GLOB PULSEAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/pulseaudio/*.c)
  152. list(APPEND SOURCE_FILES ${PULSEAUDIO_SOURCES})
  153. set(SDL_AUDIO_DRIVER_PULSEAUDIO 1)
  154. list(APPEND EXTRA_CFLAGS ${PKG_PULSEAUDIO_CFLAGS})
  155. if(SDL_PULSEAUDIO_SHARED AND NOT HAVE_SDL_LOADSO)
  156. message_warn("You must have SDL_LoadObject() support for dynamic PulseAudio loading")
  157. endif()
  158. FindLibraryAndSONAME("pulse-simple" LIBDIRS ${PKG_PULSEAUDIO_LIBRARY_DIRS})
  159. if(SDL_PULSEAUDIO_SHARED AND PULSE_SIMPLE_LIB AND HAVE_SDL_LOADSO)
  160. set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${PULSE_SIMPLE_LIB_SONAME}\"")
  161. set(HAVE_PULSEAUDIO_SHARED TRUE)
  162. else()
  163. list(APPEND EXTRA_LDFLAGS ${PKG_PULSEAUDIO_LDFLAGS})
  164. endif()
  165. set(HAVE_SDL_AUDIO TRUE)
  166. endif()
  167. endif()
  168. endmacro()
  169. # Requires:
  170. # - PkgCheckModules
  171. # Optional:
  172. # - SDL_JACK_SHARED opt
  173. # - HAVE_SDL_LOADSO opt
  174. macro(CheckJACK)
  175. if(SDL_JACK)
  176. pkg_check_modules(PKG_JACK jack)
  177. if(PKG_JACK_FOUND)
  178. set(HAVE_JACK TRUE)
  179. file(GLOB JACK_SOURCES ${SDL2_SOURCE_DIR}/src/audio/jack/*.c)
  180. list(APPEND SOURCE_FILES ${JACK_SOURCES})
  181. set(SDL_AUDIO_DRIVER_JACK 1)
  182. list(APPEND EXTRA_CFLAGS ${PKG_JACK_CFLAGS})
  183. if(SDL_JACK_SHARED AND NOT HAVE_SDL_LOADSO)
  184. message_warn("You must have SDL_LoadObject() support for dynamic JACK audio loading")
  185. endif()
  186. FindLibraryAndSONAME("jack" LIBDIRS ${PKG_JACK_LIBRARY_DIRS})
  187. if(SDL_JACK_SHARED AND JACK_LIB AND HAVE_SDL_LOADSO)
  188. set(SDL_AUDIO_DRIVER_JACK_DYNAMIC "\"${JACK_LIB_SONAME}\"")
  189. set(HAVE_JACK_SHARED TRUE)
  190. else()
  191. list(APPEND EXTRA_LDFLAGS ${PKG_JACK_LDFLAGS})
  192. endif()
  193. set(HAVE_SDL_AUDIO TRUE)
  194. endif()
  195. endif()
  196. endmacro()
  197. # Requires:
  198. # - PkgCheckModules
  199. # Optional:
  200. # - SDL_ESD_SHARED opt
  201. # - HAVE_SDL_LOADSO opt
  202. macro(CheckESD)
  203. if(SDL_ESD)
  204. pkg_check_modules(PKG_ESD esound)
  205. if(PKG_ESD_FOUND)
  206. set(HAVE_ESD TRUE)
  207. file(GLOB ESD_SOURCES ${SDL2_SOURCE_DIR}/src/audio/esd/*.c)
  208. list(APPEND SOURCE_FILES ${ESD_SOURCES})
  209. set(SDL_AUDIO_DRIVER_ESD 1)
  210. list(APPEND EXTRA_CFLAGS ${PKG_ESD_CFLAGS})
  211. if(SDL_ESD_SHARED AND NOT HAVE_SDL_LOADSO)
  212. message_warn("You must have SDL_LoadObject() support for dynamic ESD loading")
  213. endif()
  214. FindLibraryAndSONAME(esd LIBDIRS ${PKG_ESD_LIBRARY_DIRS})
  215. if(SDL_ESD_SHARED AND ESD_LIB AND HAVE_SDL_LOADSO)
  216. set(SDL_AUDIO_DRIVER_ESD_DYNAMIC "\"${ESD_LIB_SONAME}\"")
  217. set(HAVE_ESD_SHARED TRUE)
  218. else()
  219. list(APPEND EXTRA_LDFLAGS ${PKG_ESD_LDFLAGS})
  220. endif()
  221. set(HAVE_SDL_AUDIO TRUE)
  222. endif()
  223. endif()
  224. endmacro()
  225. # Requires:
  226. # - n/a
  227. # Optional:
  228. # - SDL_ARTS_SHARED opt
  229. # - HAVE_SDL_LOADSO opt
  230. macro(CheckARTS)
  231. if(SDL_ARTS)
  232. find_program(ARTS_CONFIG arts-config)
  233. if(ARTS_CONFIG)
  234. execute_process(CMD_ARTSCFLAGS ${ARTS_CONFIG} --cflags
  235. OUTPUT_VARIABLE ARTS_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
  236. list(APPEND EXTRA_CFLAGS ${ARTS_CFLAGS})
  237. execute_process(CMD_ARTSLIBS ${ARTS_CONFIG} --libs
  238. OUTPUT_VARIABLE ARTS_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE)
  239. file(GLOB ARTS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/arts/*.c)
  240. list(APPEND SOURCE_FILES ${ARTS_SOURCES})
  241. set(SDL_AUDIO_DRIVER_ARTS 1)
  242. set(HAVE_ARTS TRUE)
  243. if(SDL_ARTS_SHARED AND NOT HAVE_SDL_LOADSO)
  244. message_warn("You must have SDL_LoadObject() support for dynamic ARTS loading")
  245. endif()
  246. FindLibraryAndSONAME(artsc)
  247. if(SDL_ARTS_SHARED AND ARTSC_LIB AND HAVE_SDL_LOADSO)
  248. # TODO
  249. set(SDL_AUDIO_DRIVER_ARTS_DYNAMIC "\"${ARTSC_LIB_SONAME}\"")
  250. set(HAVE_ARTS_SHARED TRUE)
  251. else()
  252. list(APPEND EXTRA_LDFLAGS ${ARTS_LIBS})
  253. endif()
  254. set(HAVE_SDL_AUDIO TRUE)
  255. endif()
  256. endif()
  257. endmacro()
  258. # Requires:
  259. # - n/a
  260. # Optional:
  261. # - SDL_NAS_SHARED opt
  262. # - HAVE_SDL_LOADSO opt
  263. macro(CheckNAS)
  264. if(SDL_NAS)
  265. # TODO: set include paths properly, so the NAS headers are found
  266. check_include_file(audio/audiolib.h HAVE_NAS_H)
  267. find_library(D_NAS_LIB audio)
  268. if(HAVE_NAS_H AND D_NAS_LIB)
  269. set(HAVE_NAS TRUE)
  270. file(GLOB NAS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/nas/*.c)
  271. list(APPEND SOURCE_FILES ${NAS_SOURCES})
  272. set(SDL_AUDIO_DRIVER_NAS 1)
  273. if(SDL_NAS_SHARED AND NOT HAVE_SDL_LOADSO)
  274. message_warn("You must have SDL_LoadObject() support for dynamic NAS loading")
  275. endif()
  276. FindLibraryAndSONAME("audio")
  277. if(SDL_NAS_SHARED AND AUDIO_LIB AND HAVE_SDL_LOADSO)
  278. set(SDL_AUDIO_DRIVER_NAS_DYNAMIC "\"${AUDIO_LIB_SONAME}\"")
  279. set(HAVE_NAS_SHARED TRUE)
  280. else()
  281. list(APPEND EXTRA_LIBS ${D_NAS_LIB})
  282. endif()
  283. set(HAVE_SDL_AUDIO TRUE)
  284. endif()
  285. endif()
  286. endmacro()
  287. # Requires:
  288. # - PkgCheckModules
  289. # Optional:
  290. # - SDL_SNDIO_SHARED opt
  291. # - HAVE_SDL_LOADSO opt
  292. macro(CheckSNDIO)
  293. if(SDL_SNDIO)
  294. pkg_check_modules(PKG_SNDIO sndio)
  295. if(PKG_SNDIO_FOUND)
  296. set(HAVE_SNDIO TRUE)
  297. file(GLOB SNDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sndio/*.c)
  298. list(APPEND SOURCE_FILES ${SNDIO_SOURCES})
  299. set(SDL_AUDIO_DRIVER_SNDIO 1)
  300. list(APPEND EXTRA_CFLAGS ${PKG_SNDIO_CFLAGS})
  301. if(SDL_SNDIO_SHARED AND NOT HAVE_SDL_LOADSO)
  302. message_warn("You must have SDL_LoadObject() support for dynamic sndio loading")
  303. endif()
  304. FindLibraryAndSONAME("sndio" LIBDIRS ${PKG_SNDIO_LIBRARY_DIRS})
  305. if(SDL_SNDIO_SHARED AND SNDIO_LIB AND HAVE_SDL_LOADSO)
  306. set(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC "\"${SNDIO_LIB_SONAME}\"")
  307. set(HAVE_SNDIO_SHARED TRUE)
  308. else()
  309. list(APPEND EXTRA_LIBS ${PKG_SNDIO_LDFLAGS})
  310. endif()
  311. set(HAVE_SDL_AUDIO TRUE)
  312. endif()
  313. endif()
  314. endmacro()
  315. # Requires:
  316. # - PkgCheckModules
  317. # Optional:
  318. # - FUSIONSOUND_SHARED opt
  319. # - HAVE_SDL_LOADSO opt
  320. macro(CheckFusionSound)
  321. if(FUSIONSOUND)
  322. pkg_check_modules(PKG_FUSIONSOUND fusionsound>=1.0.0)
  323. if(PKG_FUSIONSOUND_FOUND)
  324. set(HAVE_FUSIONSOUND TRUE)
  325. file(GLOB FUSIONSOUND_SOURCES ${SDL2_SOURCE_DIR}/src/audio/fusionsound/*.c)
  326. list(APPEND SOURCE_FILES ${FUSIONSOUND_SOURCES})
  327. set(SDL_AUDIO_DRIVER_FUSIONSOUND 1)
  328. list(APPEND EXTRA_CFLAGS ${PKG_FUSIONSOUND_CFLAGS})
  329. if(FUSIONSOUND_SHARED AND NOT HAVE_SDL_LOADSO)
  330. message_warn("You must have SDL_LoadObject() support for dynamic FusionSound loading")
  331. endif()
  332. FindLibraryAndSONAME("fusionsound" LIBDIRS ${PKG_FUSIONSOUND_LIBRARY_DIRS})
  333. if(FUSIONSOUND_SHARED AND FUSIONSOUND_LIB AND HAVE_SDL_LOADSO)
  334. set(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "\"${FUSIONSOUND_LIB_SONAME}\"")
  335. set(HAVE_FUSIONSOUND_SHARED TRUE)
  336. else()
  337. list(APPEND EXTRA_LDFLAGS ${PKG_FUSIONSOUND_LDFLAGS})
  338. endif()
  339. set(HAVE_SDL_AUDIO TRUE)
  340. endif()
  341. endif()
  342. endmacro()
  343. # Requires:
  344. # - SDL_LIBSAMPLERATE
  345. # Optional:
  346. # - SDL_LIBSAMPLERATE_SHARED opt
  347. # - HAVE_SDL_LOADSO opt
  348. macro(CheckLibSampleRate)
  349. if(SDL_LIBSAMPLERATE)
  350. find_package(SampleRate QUIET)
  351. if(SampleRate_FOUND AND TARGET SampleRate::samplerate)
  352. set(HAVE_LIBSAMPLERATE TRUE)
  353. set(HAVE_LIBSAMPLERATE_H TRUE)
  354. if(SDL_LIBSAMPLERATE_SHARED)
  355. target_include_directories(sdl-build-options INTERFACE $<TARGET_PROPERTY:SampleRate::samplerate,INTERFACE_INCLUDE_DIRECTORIES>)
  356. if(NOT HAVE_SDL_LOADSO)
  357. message_warn("You must have SDL_LoadObject() support for dynamic libsamplerate loading")
  358. else()
  359. get_property(_samplerate_type TARGET SampleRate::samplerate PROPERTY TYPE)
  360. if(_samplerate_type STREQUAL "SHARED_LIBRARY")
  361. set(HAVE_LIBSAMPLERATE_SHARED TRUE)
  362. if(WIN32 OR OS2)
  363. set(SDL_LIBSAMPLERATE_DYNAMIC "\"$<TARGET_FILE_NAME:SampleRate::samplerate>\"")
  364. else()
  365. set(SDL_LIBSAMPLERATE_DYNAMIC "\"$<TARGET_SONAME_FILE_NAME:SampleRate::samplerate>\"")
  366. endif()
  367. endif()
  368. endif()
  369. else()
  370. target_link_libraries(sdl-build-options INTERFACE SampleRate::samplerate)
  371. list(APPEND SDL_REQUIRES_PRIVATE SampleRate::samplerate)
  372. endif()
  373. else()
  374. check_include_file(samplerate.h HAVE_LIBSAMPLERATE_H)
  375. if(HAVE_LIBSAMPLERATE_H)
  376. set(HAVE_LIBSAMPLERATE TRUE)
  377. if(SDL_LIBSAMPLERATE_SHARED AND NOT HAVE_SDL_LOADSO)
  378. message_warn("You must have SDL_LoadObject() support for dynamic libsamplerate loading")
  379. endif()
  380. FindLibraryAndSONAME("samplerate")
  381. if(SDL_LIBSAMPLERATE_SHARED AND SAMPLERATE_LIB AND HAVE_SDL_LOADSO)
  382. set(SDL_LIBSAMPLERATE_DYNAMIC "\"${SAMPLERATE_LIB_SONAME}\"")
  383. set(HAVE_LIBSAMPLERATE_SHARED TRUE)
  384. else()
  385. list(APPEND EXTRA_LDFLAGS -lsamplerate)
  386. endif()
  387. endif()
  388. endif()
  389. endif()
  390. endmacro()
  391. # Requires:
  392. # - n/a
  393. # Optional:
  394. # - SDL_X11_SHARED opt
  395. # - HAVE_SDL_LOADSO opt
  396. macro(CheckX11)
  397. cmake_push_check_state(RESET)
  398. if(SDL_X11)
  399. foreach(_LIB X11 Xext Xcursor Xi Xfixes Xrandr Xrender Xss)
  400. FindLibraryAndSONAME("${_LIB}")
  401. endforeach()
  402. set(X11_dirs)
  403. find_path(X_INCLUDEDIR
  404. NAMES X11/Xlib.h
  405. PATHS
  406. /usr/pkg/xorg/include
  407. /usr/X11R6/include
  408. /usr/X11R7/include
  409. /usr/local/include/X11
  410. /usr/include/X11
  411. /usr/openwin/include
  412. /usr/openwin/share/include
  413. /opt/graphics/OpenGL/include
  414. /opt/X11/include
  415. )
  416. if(X_INCLUDEDIR)
  417. list(APPEND EXTRA_CFLAGS "-I${X_INCLUDEDIR}")
  418. list(APPEND CMAKE_REQUIRED_INCLUDES ${X_INCLUDEDIR})
  419. endif()
  420. find_file(HAVE_XCURSOR_H NAMES "X11/Xcursor/Xcursor.h" HINTS "${X_INCLUDEDIR}")
  421. find_file(HAVE_XINPUT2_H NAMES "X11/extensions/XInput2.h" HINTS "${X_INCLUDEDIR}")
  422. find_file(HAVE_XRANDR_H NAMES "X11/extensions/Xrandr.h" HINTS "${X_INCLUDEDIR}")
  423. find_file(HAVE_XFIXES_H_ NAMES "X11/extensions/Xfixes.h" HINTS "${X_INCLUDEDIR}")
  424. find_file(HAVE_XRENDER_H NAMES "X11/extensions/Xrender.h" HINTS "${X_INCLUDEDIR}")
  425. find_file(HAVE_XSS_H NAMES "X11/extensions/scrnsaver.h" HINTS "${X_INCLUDEDIR}")
  426. find_file(HAVE_XSHAPE_H NAMES "X11/extensions/shape.h" HINTS "${X_INCLUDEDIR}")
  427. find_file(HAVE_XDBE_H NAMES "X11/extensions/Xdbe.h" HINTS "${X_INCLUDEDIR}")
  428. find_file(HAVE_XEXT_H NAMES "X11/extensions/Xext.h" HINTS "${X_INCLUDEDIR}")
  429. if(X11_LIB)
  430. if(NOT HAVE_XEXT_H)
  431. message_error("Missing Xext.h, maybe you need to install the libxext-dev package?")
  432. endif()
  433. set(HAVE_X11 TRUE)
  434. set(HAVE_SDL_VIDEO TRUE)
  435. file(GLOB X11_SOURCES ${SDL2_SOURCE_DIR}/src/video/x11/*.c)
  436. list(APPEND SOURCE_FILES ${X11_SOURCES})
  437. set(SDL_VIDEO_DRIVER_X11 1)
  438. # !!! FIXME: why is this disabled for Apple?
  439. if(APPLE)
  440. set(SDL_X11_SHARED OFF)
  441. endif()
  442. check_symbol_exists(shmat "sys/shm.h" HAVE_SHMAT_IN_LIBC)
  443. if(NOT HAVE_SHMAT_IN_LIBC)
  444. check_library_exists(ipc shmat "" HAVE_SHMAT_IN_LIBIPC)
  445. if(HAVE_SHMAT_IN_LIBIPC)
  446. list(APPEND EXTRA_LIBS ipc)
  447. endif()
  448. if(NOT HAVE_SHMAT_IN_LIBIPC)
  449. list(APPEND EXTRA_CFLAGS "-DNO_SHARED_MEMORY")
  450. endif()
  451. endif()
  452. if(SDL_X11_SHARED)
  453. if(NOT HAVE_SDL_LOADSO)
  454. message_warn("You must have SDL_LoadObject() support for dynamic X11 loading")
  455. set(HAVE_X11_SHARED FALSE)
  456. else()
  457. set(HAVE_X11_SHARED TRUE)
  458. endif()
  459. if(X11_LIB)
  460. if(HAVE_X11_SHARED)
  461. set(SDL_VIDEO_DRIVER_X11_DYNAMIC "\"${X11_LIB_SONAME}\"")
  462. else()
  463. list(APPEND EXTRA_LIBS ${X11_LIB})
  464. endif()
  465. endif()
  466. if(XEXT_LIB)
  467. if(HAVE_X11_SHARED)
  468. set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "\"${XEXT_LIB_SONAME}\"")
  469. else()
  470. list(APPEND EXTRA_LIBS ${XEXT_LIB_SONAME})
  471. endif()
  472. endif()
  473. else()
  474. list(APPEND EXTRA_LIBS ${X11_LIB} ${XEXT_LIB})
  475. endif()
  476. set(CMAKE_REQUIRED_LIBRARIES ${X11_LIB} ${X11_LIB})
  477. check_c_source_compiles("
  478. #include <X11/Xlib.h>
  479. int main(int argc, char **argv) {
  480. Display *display;
  481. XEvent event;
  482. XGenericEventCookie *cookie = &event.xcookie;
  483. XNextEvent(display, &event);
  484. XGetEventData(display, cookie);
  485. XFreeEventData(display, cookie);
  486. return 0; }" HAVE_XGENERICEVENT)
  487. if(HAVE_XGENERICEVENT)
  488. set(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1)
  489. endif()
  490. check_symbol_exists(XkbKeycodeToKeysym "X11/Xlib.h;X11/XKBlib.h" SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM)
  491. if(SDL_X11_XCURSOR AND HAVE_XCURSOR_H AND XCURSOR_LIB)
  492. set(HAVE_X11_XCURSOR TRUE)
  493. if(HAVE_X11_SHARED)
  494. set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "\"${XCURSOR_LIB_SONAME}\"")
  495. else()
  496. list(APPEND EXTRA_LIBS ${XCURSOR_LIB})
  497. endif()
  498. set(SDL_VIDEO_DRIVER_X11_XCURSOR 1)
  499. endif()
  500. if(SDL_X11_XDBE AND HAVE_XDBE_H)
  501. set(HAVE_X11_XDBE TRUE)
  502. set(SDL_VIDEO_DRIVER_X11_XDBE 1)
  503. endif()
  504. if(SDL_X11_XINPUT AND HAVE_XINPUT2_H AND XI_LIB)
  505. set(HAVE_X11_XINPUT TRUE)
  506. if(HAVE_X11_SHARED)
  507. set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "\"${XI_LIB_SONAME}\"")
  508. else()
  509. list(APPEND EXTRA_LIBS ${XI_LIB})
  510. endif()
  511. set(SDL_VIDEO_DRIVER_X11_XINPUT2 1)
  512. # Check for multitouch
  513. check_c_source_compiles("
  514. #include <X11/Xlib.h>
  515. #include <X11/Xproto.h>
  516. #include <X11/extensions/XInput2.h>
  517. int event_type = XI_TouchBegin;
  518. XITouchClassInfo *t;
  519. Status XIAllowTouchEvents(Display *a,int b,unsigned int c,Window d,int f) {
  520. return (Status)0;
  521. }
  522. int main(int argc, char **argv) { return 0; }" HAVE_XINPUT2_MULTITOUCH)
  523. if(HAVE_XINPUT2_MULTITOUCH)
  524. set(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1)
  525. endif()
  526. endif()
  527. # check along with XInput2.h because we use Xfixes with XIBarrierReleasePointer
  528. if(SDL_X11_XFIXES AND HAVE_XFIXES_H_ AND HAVE_XINPUT2_H)
  529. check_c_source_compiles("
  530. #include <X11/Xlib.h>
  531. #include <X11/Xproto.h>
  532. #include <X11/extensions/XInput2.h>
  533. #include <X11/extensions/Xfixes.h>
  534. BarrierEventID b;
  535. int main(int argc, char **argv) { return 0; }" HAVE_XFIXES_H)
  536. endif()
  537. if(SDL_X11_XFIXES AND HAVE_XFIXES_H AND HAVE_XINPUT2_H AND XFIXES_LIB)
  538. if(HAVE_X11_SHARED)
  539. set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES "\"${XFIXES_LIB_SONAME}\"")
  540. else()
  541. list(APPEND EXTRA_LIBS ${XFIXES_LIB})
  542. endif()
  543. set(SDL_VIDEO_DRIVER_X11_XFIXES 1)
  544. set(HAVE_X11_XFIXES TRUE)
  545. endif()
  546. if(SDL_X11_XRANDR AND HAVE_XRANDR_H AND XRANDR_LIB)
  547. if(HAVE_X11_SHARED)
  548. set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "\"${XRANDR_LIB_SONAME}\"")
  549. else()
  550. list(APPEND EXTRA_LIBS ${XRANDR_LIB})
  551. endif()
  552. set(SDL_VIDEO_DRIVER_X11_XRANDR 1)
  553. set(HAVE_X11_XRANDR TRUE)
  554. endif()
  555. if(SDL_X11_XSCRNSAVER AND HAVE_XSS_H AND XSS_LIB)
  556. if(HAVE_X11_SHARED)
  557. set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "\"${XSS_LIB_SONAME}\"")
  558. else()
  559. list(APPEND EXTRA_LIBS ${XSS_LIB})
  560. endif()
  561. set(SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1)
  562. set(HAVE_X11_XSCRNSAVER TRUE)
  563. endif()
  564. if(SDL_X11_XSHAPE AND HAVE_XSHAPE_H)
  565. set(SDL_VIDEO_DRIVER_X11_XSHAPE 1)
  566. set(HAVE_X11_XSHAPE TRUE)
  567. endif()
  568. set(CMAKE_REQUIRED_LIBRARIES)
  569. endif()
  570. endif()
  571. if(NOT HAVE_X11)
  572. # Prevent Mesa from including X11 headers
  573. list(APPEND EXTRA_CFLAGS "-DMESA_EGL_NO_X11_HEADERS -DEGL_NO_X11")
  574. endif()
  575. cmake_pop_check_state()
  576. endmacro()
  577. macro(WaylandProtocolGen _SCANNER _CODE_MODE _XML _PROTL)
  578. set(_WAYLAND_PROT_C_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-protocol.c")
  579. set(_WAYLAND_PROT_H_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-client-protocol.h")
  580. add_custom_command(
  581. OUTPUT "${_WAYLAND_PROT_H_CODE}"
  582. DEPENDS "${_XML}"
  583. COMMAND "${_SCANNER}"
  584. ARGS client-header "${_XML}" "${_WAYLAND_PROT_H_CODE}"
  585. )
  586. add_custom_command(
  587. OUTPUT "${_WAYLAND_PROT_C_CODE}"
  588. DEPENDS "${_WAYLAND_PROT_H_CODE}"
  589. COMMAND "${_SCANNER}"
  590. ARGS "${_CODE_MODE}" "${_XML}" "${_WAYLAND_PROT_C_CODE}"
  591. )
  592. list(APPEND SDL_GENERATED_HEADERS "${_WAYLAND_PROT_H_CODE}")
  593. list(APPEND SOURCE_FILES "${_WAYLAND_PROT_C_CODE}")
  594. endmacro()
  595. # Requires:
  596. # - EGL
  597. # - PkgCheckModules
  598. # Optional:
  599. # - SDL_WAYLAND_SHARED opt
  600. # - HAVE_SDL_LOADSO opt
  601. macro(CheckWayland)
  602. if(SDL_WAYLAND)
  603. set(WAYLAND_FOUND FALSE)
  604. pkg_check_modules(PKG_WAYLAND "wayland-client>=1.18" wayland-egl wayland-cursor egl "xkbcommon>=0.5.0")
  605. if(PKG_WAYLAND_FOUND)
  606. set(WAYLAND_FOUND TRUE)
  607. find_program(WAYLAND_SCANNER NAMES wayland-scanner REQUIRED)
  608. execute_process(
  609. COMMAND ${WAYLAND_SCANNER} --version
  610. RESULT_VARIABLE WAYLAND_SCANNER_VERSION_RC
  611. ERROR_VARIABLE WAYLAND_SCANNER_VERSION
  612. ERROR_STRIP_TRAILING_WHITESPACE
  613. )
  614. if(NOT WAYLAND_SCANNER_VERSION_RC EQUAL 0)
  615. message(FATAL "Failed to get wayland-scanner version")
  616. set(WAYLAND_FOUND FALSE)
  617. endif()
  618. string(REPLACE "wayland-scanner " "" WAYLAND_SCANNER_VERSION ${WAYLAND_SCANNER_VERSION})
  619. string(COMPARE LESS ${WAYLAND_SCANNER_VERSION} "1.15.0" WAYLAND_SCANNER_PRE_1_15)
  620. if(WAYLAND_SCANNER_PRE_1_15)
  621. set(WAYLAND_SCANNER_CODE_MODE "code")
  622. else()
  623. set(WAYLAND_SCANNER_CODE_MODE "private-code")
  624. endif()
  625. endif()
  626. if(WAYLAND_FOUND)
  627. target_link_directories(sdl-build-options INTERFACE "${PKG_WAYLAND_LIBRARY_DIRS}")
  628. target_include_directories(sdl-build-options INTERFACE "${PKG_WAYLAND_INCLUDE_DIRS}")
  629. set(HAVE_WAYLAND TRUE)
  630. set(HAVE_SDL_VIDEO TRUE)
  631. file(GLOB WAYLAND_SOURCES ${SDL2_SOURCE_DIR}/src/video/wayland/*.c)
  632. list(APPEND SOURCE_FILES ${WAYLAND_SOURCES})
  633. # We have to generate some protocol interface code for some unstable Wayland features.
  634. file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols")
  635. target_include_directories(sdl-build-options INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols")
  636. file(GLOB WAYLAND_PROTOCOLS_XML RELATIVE "${SDL2_SOURCE_DIR}/wayland-protocols/" "${SDL2_SOURCE_DIR}/wayland-protocols/*.xml")
  637. foreach(_XML ${WAYLAND_PROTOCOLS_XML})
  638. string(REGEX REPLACE "\\.xml$" "" _PROTL "${_XML}")
  639. WaylandProtocolGen("${WAYLAND_SCANNER}" "${WAYLAND_SCANNER_CODE_MODE}" "${SDL2_SOURCE_DIR}/wayland-protocols/${_XML}" "${_PROTL}")
  640. endforeach()
  641. if(SDL_WAYLAND_QT_TOUCH)
  642. set(HAVE_WAYLAND_QT_TOUCH TRUE)
  643. set(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 1)
  644. endif()
  645. if(SDL_WAYLAND_SHARED AND NOT HAVE_SDL_LOADSO)
  646. message_warn("You must have SDL_LoadObject() support for dynamic Wayland loading")
  647. endif()
  648. FindLibraryAndSONAME(wayland-client LIBDIRS ${PKG_WAYLAND_LIBRARY_DIRS})
  649. FindLibraryAndSONAME(wayland-egl LIBDIRS ${PKG_WAYLAND_LIBRARY_DIRS})
  650. FindLibraryAndSONAME(wayland-cursor LIBDIRS ${PKG_WAYLAND_LIBRARY_DIRS})
  651. FindLibraryAndSONAME(xkbcommon LIBDIRS ${PKG_WAYLAND_LIBRARY_DIRS})
  652. if(SDL_WAYLAND_SHARED AND WAYLAND_CLIENT_LIB AND WAYLAND_EGL_LIB AND WAYLAND_CURSOR_LIB AND XKBCOMMON_LIB AND HAVE_SDL_LOADSO)
  653. set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC "\"${WAYLAND_CLIENT_LIB_SONAME}\"")
  654. set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL "\"${WAYLAND_EGL_LIB_SONAME}\"")
  655. set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR "\"${WAYLAND_CURSOR_LIB_SONAME}\"")
  656. set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON "\"${XKBCOMMON_LIB_SONAME}\"")
  657. set(HAVE_WAYLAND_SHARED TRUE)
  658. else()
  659. list(APPEND EXTRA_LIBS ${PKG_WAYLAND_LIBRARIES})
  660. endif()
  661. if(SDL_WAYLAND_LIBDECOR)
  662. pkg_check_modules(PKG_LIBDECOR libdecor-0)
  663. if(PKG_LIBDECOR_FOUND)
  664. set(HAVE_WAYLAND_LIBDECOR TRUE)
  665. set(HAVE_LIBDECOR_H 1)
  666. target_link_directories(sdl-build-options INTERFACE "${PKG_LIBDECOR_LIBRARY_DIRS}")
  667. target_include_directories(sdl-build-options INTERFACE "${PKG_LIBDECOR_INCLUDE_DIRS}")
  668. if(SDL_WAYLAND_LIBDECOR_SHARED AND NOT HAVE_SDL_LOADSO)
  669. message_warn("You must have SDL_LoadObject() support for dynamic libdecor loading")
  670. endif()
  671. FindLibraryAndSONAME(decor-0 LIBDIRS ${PKG_LIBDECOR_LIBRARY_DIRS})
  672. if(SDL_WAYLAND_LIBDECOR_SHARED AND DECOR_0_LIB AND HAVE_SDL_LOADSO)
  673. set(HAVE_WAYLAND_LIBDECOR_SHARED TRUE)
  674. set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR "\"${DECOR_0_LIB_SONAME}\"")
  675. else()
  676. list(APPEND EXTRA_LIBS ${PKG_LIBDECOR_LIBRARIES})
  677. endif()
  678. cmake_push_check_state()
  679. list(APPEND CMAKE_REQUIRED_FLAGS ${PKG_LIBDECOR_CFLAGS})
  680. list(APPEND CMAKE_REQUIRED_INCLUDES ${PKG_LIBDECOR_INCLUDE_DIRS})
  681. list(APPEND CMAKE_REQUIRED_LIBRARIES ${PKG_LIBDECOR_LINK_LIBRARIES})
  682. check_symbol_exists(libdecor_frame_get_max_content_size "libdecor.h" HAVE_LIBDECOR_FRAME_GET_MAX_CONTENT_SIZE)
  683. check_symbol_exists(libdecor_frame_get_min_content_size "libdecor.h" HAVE_LIBDECOR_FRAME_GET_MIN_CONTENT_SIZE)
  684. if(HAVE_LIBDECOR_FRAME_GET_MAX_CONTENT_SIZE AND HAVE_LIBDECOR_FRAME_GET_MIN_CONTENT_SIZE)
  685. set(SDL_HAVE_LIBDECOR_GET_MIN_MAX 1)
  686. endif()
  687. cmake_pop_check_state()
  688. endif()
  689. endif()
  690. set(SDL_VIDEO_DRIVER_WAYLAND 1)
  691. endif()
  692. endif()
  693. endmacro()
  694. # Requires:
  695. # - n/a
  696. #
  697. macro(CheckCOCOA)
  698. if(SDL_COCOA)
  699. if(APPLE) # Apple always has Cocoa.
  700. set(HAVE_COCOA TRUE)
  701. endif()
  702. if(HAVE_COCOA)
  703. file(GLOB COCOA_SOURCES ${SDL2_SOURCE_DIR}/src/video/cocoa/*.m)
  704. list(APPEND SOURCE_FILES ${COCOA_SOURCES})
  705. set(SDL_VIDEO_DRIVER_COCOA 1)
  706. set(HAVE_SDL_VIDEO TRUE)
  707. endif()
  708. endif()
  709. endmacro()
  710. # Requires:
  711. # - PkgCheckModules
  712. # Optional:
  713. # - DIRECTFB_SHARED opt
  714. # - HAVE_SDL_LOADSO opt
  715. macro(CheckDirectFB)
  716. if(SDL_DIRECTFB)
  717. pkg_check_modules(PKG_DIRECTFB directfb>=1.0.0)
  718. if(PKG_DIRECTFB_FOUND)
  719. set(HAVE_DIRECTFB TRUE)
  720. file(GLOB DIRECTFB_SOURCES ${SDL2_SOURCE_DIR}/src/video/directfb/*.c)
  721. list(APPEND SOURCE_FILES ${DIRECTFB_SOURCES})
  722. set(SDL_VIDEO_DRIVER_DIRECTFB 1)
  723. set(SDL_VIDEO_RENDER_DIRECTFB 1)
  724. list(APPEND EXTRA_CFLAGS ${PKG_DIRECTFB_CFLAGS})
  725. list(APPEND SDL_CFLAGS ${PKG_DIRECTFB_CFLAGS})
  726. if(SDL_DIRECTFB_SHARED AND NOT HAVE_SDL_LOADSO)
  727. message_warn("You must have SDL_LoadObject() support for dynamic DirectFB loading")
  728. endif()
  729. FindLibraryAndSONAME("directfb" LIBDIRS ${PKG_DIRECTFB_LIBRARY_DIRS})
  730. if(SDL_DIRECTFB_SHARED AND DIRECTFB_LIB AND HAVE_SDL_LOADSO)
  731. set(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "\"${DIRECTFB_LIB_SONAME}\"")
  732. set(HAVE_DIRECTFB_SHARED TRUE)
  733. else()
  734. list(APPEND EXTRA_LDFLAGS ${PKG_DIRECTFB_LDFLAGS})
  735. endif()
  736. set(HAVE_SDL_VIDEO TRUE)
  737. endif()
  738. endif()
  739. endmacro()
  740. # Requires:
  741. # - n/a
  742. macro(CheckVivante)
  743. if(SDL_VIVANTE)
  744. check_c_source_compiles("
  745. #include <gc_vdk.h>
  746. int main(int argc, char** argv) { return 0; }" HAVE_VIVANTE_VDK)
  747. check_c_source_compiles("
  748. #define LINUX
  749. #define EGL_API_FB
  750. #include <EGL/eglvivante.h>
  751. int main(int argc, char** argv) { return 0; }" HAVE_VIVANTE_EGL_FB)
  752. if(HAVE_VIVANTE_VDK OR HAVE_VIVANTE_EGL_FB)
  753. set(HAVE_VIVANTE TRUE)
  754. set(HAVE_SDL_VIDEO TRUE)
  755. file(GLOB VIVANTE_SOURCES ${SDL2_SOURCE_DIR}/src/video/vivante/*.c)
  756. list(APPEND SOURCE_FILES ${VIVANTE_SOURCES})
  757. set(SDL_VIDEO_DRIVER_VIVANTE 1)
  758. if(HAVE_VIVANTE_VDK)
  759. set(SDL_VIDEO_DRIVER_VIVANTE_VDK 1)
  760. find_library(VIVANTE_LIBRARY REQUIRED NAMES VIVANTE vivante drm_vivante)
  761. find_library(VIVANTE_VDK_LIBRARY VDK REQUIRED)
  762. list(APPEND EXTRA_LIBS ${VIVANTE_LIBRARY} ${VIVANTE_VDK_LIBRARY})
  763. else()
  764. list(APPEND SDL_CFLAGS -DLINUX -DEGL_API_FB)
  765. list(APPEND EXTRA_LIBS EGL)
  766. endif(HAVE_VIVANTE_VDK)
  767. endif()
  768. endif()
  769. endmacro()
  770. # Requires:
  771. # - nada
  772. macro(CheckGLX)
  773. if(SDL_OPENGL)
  774. check_c_source_compiles("
  775. #include <GL/glx.h>
  776. int main(int argc, char** argv) { return 0; }" HAVE_OPENGL_GLX)
  777. if(HAVE_OPENGL_GLX)
  778. set(SDL_VIDEO_OPENGL_GLX 1)
  779. endif()
  780. endif()
  781. endmacro()
  782. # Requires:
  783. # - PkgCheckModules
  784. macro(CheckEGL)
  785. if (SDL_OPENGL OR SDL_OPENGLES)
  786. pkg_check_modules(EGL egl)
  787. set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} ${EGL_CFLAGS}")
  788. check_c_source_compiles("
  789. #define EGL_API_FB
  790. #define MESA_EGL_NO_X11_HEADERS
  791. #define EGL_NO_X11
  792. #include <EGL/egl.h>
  793. #include <EGL/eglext.h>
  794. int main (int argc, char** argv) { return 0; }" HAVE_OPENGL_EGL)
  795. if(HAVE_OPENGL_EGL)
  796. set(SDL_VIDEO_OPENGL_EGL 1)
  797. endif()
  798. endif()
  799. endmacro()
  800. # Requires:
  801. # - nada
  802. macro(CheckOpenGL)
  803. if(SDL_OPENGL)
  804. check_c_source_compiles("
  805. #include <GL/gl.h>
  806. #include <GL/glext.h>
  807. int main(int argc, char** argv) { return 0; }" HAVE_OPENGL)
  808. if(HAVE_OPENGL)
  809. set(SDL_VIDEO_OPENGL 1)
  810. set(SDL_VIDEO_RENDER_OGL 1)
  811. endif()
  812. endif()
  813. endmacro()
  814. # Requires:
  815. # - nada
  816. macro(CheckOpenGLES)
  817. if(SDL_OPENGLES)
  818. check_c_source_compiles("
  819. #include <GLES/gl.h>
  820. #include <GLES/glext.h>
  821. int main (int argc, char** argv) { return 0; }" HAVE_OPENGLES_V1)
  822. if(HAVE_OPENGLES_V1)
  823. set(HAVE_OPENGLES TRUE)
  824. set(SDL_VIDEO_OPENGL_ES 1)
  825. set(SDL_VIDEO_RENDER_OGL_ES 1)
  826. endif()
  827. check_c_source_compiles("
  828. #include <GLES2/gl2.h>
  829. #include <GLES2/gl2ext.h>
  830. int main (int argc, char** argv) { return 0; }" HAVE_OPENGLES_V2)
  831. if(HAVE_OPENGLES_V2)
  832. set(HAVE_OPENGLES TRUE)
  833. set(SDL_VIDEO_OPENGL_ES2 1)
  834. set(SDL_VIDEO_RENDER_OGL_ES2 1)
  835. endif()
  836. endif()
  837. endmacro()
  838. # Requires:
  839. # - nada
  840. # Optional:
  841. # - THREADS opt
  842. # Sets:
  843. # PTHREAD_CFLAGS
  844. # PTHREAD_LIBS
  845. macro(CheckPTHREAD)
  846. if(SDL_THREADS AND SDL_PTHREADS)
  847. if(ANDROID)
  848. # the android libc provides built-in support for pthreads, so no
  849. # additional linking or compile flags are necessary
  850. elseif(LINUX)
  851. set(PTHREAD_CFLAGS "-D_REENTRANT")
  852. set(PTHREAD_LDFLAGS "-pthread")
  853. elseif(BSDI)
  854. set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
  855. set(PTHREAD_LDFLAGS "")
  856. elseif(DARWIN)
  857. set(PTHREAD_CFLAGS "-D_THREAD_SAFE")
  858. # causes Carbon.p complaints?
  859. # set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
  860. set(PTHREAD_LDFLAGS "")
  861. elseif(FREEBSD)
  862. set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
  863. set(PTHREAD_LDFLAGS "-pthread")
  864. elseif(NETBSD)
  865. set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
  866. set(PTHREAD_LDFLAGS "-lpthread")
  867. elseif(OPENBSD)
  868. set(PTHREAD_CFLAGS "-D_REENTRANT")
  869. set(PTHREAD_LDFLAGS "-lpthread")
  870. elseif(SOLARIS)
  871. set(PTHREAD_CFLAGS "-D_REENTRANT")
  872. set(PTHREAD_LDFLAGS "-pthread -lposix4")
  873. elseif(SYSV5)
  874. set(PTHREAD_CFLAGS "-D_REENTRANT -Kthread")
  875. set(PTHREAD_LDFLAGS "")
  876. elseif(AIX)
  877. set(PTHREAD_CFLAGS "-D_REENTRANT -mthreads")
  878. set(PTHREAD_LDFLAGS "-pthread")
  879. elseif(HPUX)
  880. set(PTHREAD_CFLAGS "-D_REENTRANT")
  881. set(PTHREAD_LDFLAGS "-L/usr/lib -pthread")
  882. elseif(HAIKU)
  883. set(PTHREAD_CFLAGS "-D_REENTRANT")
  884. set(PTHREAD_LDFLAGS "")
  885. elseif(EMSCRIPTEN)
  886. set(PTHREAD_CFLAGS "-D_REENTRANT -pthread")
  887. set(PTHREAD_LDFLAGS "-pthread")
  888. else()
  889. set(PTHREAD_CFLAGS "-D_REENTRANT")
  890. set(PTHREAD_LDFLAGS "-lpthread")
  891. endif()
  892. # Run some tests
  893. set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
  894. set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${PTHREAD_CFLAGS} ${PTHREAD_LDFLAGS}")
  895. check_c_source_compiles("
  896. #include <pthread.h>
  897. int main(int argc, char** argv) {
  898. pthread_attr_t type;
  899. pthread_attr_init(&type);
  900. return 0;
  901. }" HAVE_PTHREADS)
  902. if(HAVE_PTHREADS)
  903. set(SDL_THREAD_PTHREAD 1)
  904. list(APPEND EXTRA_CFLAGS ${PTHREAD_CFLAGS})
  905. list(APPEND EXTRA_LDFLAGS ${PTHREAD_LDFLAGS})
  906. list(APPEND SDL_CFLAGS ${PTHREAD_CFLAGS})
  907. check_c_source_compiles("
  908. #include <pthread.h>
  909. int main(int argc, char **argv) {
  910. pthread_mutexattr_t attr;
  911. pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  912. return 0;
  913. }" HAVE_RECURSIVE_MUTEXES)
  914. if(HAVE_RECURSIVE_MUTEXES)
  915. set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1)
  916. else()
  917. check_c_source_compiles("
  918. #include <pthread.h>
  919. int main(int argc, char **argv) {
  920. pthread_mutexattr_t attr;
  921. pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
  922. return 0;
  923. }" HAVE_RECURSIVE_MUTEXES_NP)
  924. if(HAVE_RECURSIVE_MUTEXES_NP)
  925. set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1)
  926. endif()
  927. endif()
  928. if(SDL_PTHREADS_SEM)
  929. check_c_source_compiles("#include <pthread.h>
  930. #include <semaphore.h>
  931. int main(int argc, char **argv) { return 0; }" HAVE_PTHREADS_SEM)
  932. if(HAVE_PTHREADS_SEM)
  933. check_c_source_compiles("
  934. #include <pthread.h>
  935. #include <semaphore.h>
  936. int main(int argc, char **argv) {
  937. sem_timedwait(NULL, NULL);
  938. return 0;
  939. }" HAVE_SEM_TIMEDWAIT)
  940. endif()
  941. endif()
  942. check_include_files("pthread.h" HAVE_PTHREAD_H)
  943. check_include_files("pthread_np.h" HAVE_PTHREAD_NP_H)
  944. if (HAVE_PTHREAD_H)
  945. check_c_source_compiles("
  946. #include <pthread.h>
  947. int main(int argc, char **argv) {
  948. #ifdef __APPLE__
  949. pthread_setname_np(\"\");
  950. #else
  951. pthread_setname_np(pthread_self(),\"\");
  952. #endif
  953. return 0;
  954. }" HAVE_PTHREAD_SETNAME_NP)
  955. if (HAVE_PTHREAD_NP_H)
  956. check_symbol_exists(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
  957. endif()
  958. endif()
  959. set(SOURCE_FILES ${SOURCE_FILES}
  960. ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_systhread.c
  961. ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_sysmutex.c # Can be faked, if necessary
  962. ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syscond.c # Can be faked, if necessary
  963. ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_systls.c
  964. )
  965. if(HAVE_PTHREADS_SEM)
  966. set(SOURCE_FILES ${SOURCE_FILES}
  967. ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syssem.c)
  968. else()
  969. set(SOURCE_FILES ${SOURCE_FILES}
  970. ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syssem.c)
  971. endif()
  972. set(HAVE_SDL_THREADS TRUE)
  973. endif()
  974. set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
  975. endif()
  976. endmacro()
  977. # Requires
  978. # - nada
  979. # Optional:
  980. # Sets:
  981. # USB_LIBS
  982. # USB_CFLAGS
  983. macro(CheckUSBHID)
  984. check_library_exists(usbhid hid_init "" LIBUSBHID)
  985. if(LIBUSBHID)
  986. check_include_file(usbhid.h HAVE_USBHID_H)
  987. if(HAVE_USBHID_H)
  988. set(USB_CFLAGS "-DHAVE_USBHID_H")
  989. endif()
  990. check_include_file(libusbhid.h HAVE_LIBUSBHID_H)
  991. if(HAVE_LIBUSBHID_H)
  992. set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSBHID_H")
  993. endif()
  994. set(USB_LIBS ${USB_LIBS} usbhid)
  995. else()
  996. check_include_file(usb.h HAVE_USB_H)
  997. if(HAVE_USB_H)
  998. set(USB_CFLAGS "-DHAVE_USB_H")
  999. endif()
  1000. check_include_file(libusb.h HAVE_LIBUSB_H)
  1001. if(HAVE_LIBUSB_H)
  1002. set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSB_H")
  1003. endif()
  1004. check_library_exists(usb hid_init "" LIBUSB)
  1005. if(LIBUSB)
  1006. set(USB_LIBS ${USB_LIBS} usb)
  1007. endif()
  1008. endif()
  1009. set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
  1010. set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${USB_CFLAGS}")
  1011. set(CMAKE_REQUIRED_LIBRARIES "${USB_LIBS}")
  1012. check_c_source_compiles("
  1013. #include <sys/types.h>
  1014. #if defined(HAVE_USB_H)
  1015. #include <usb.h>
  1016. #endif
  1017. #ifdef __DragonFly__
  1018. # include <bus/u4b/usb.h>
  1019. # include <bus/u4b/usbhid.h>
  1020. #else
  1021. # include <dev/usb/usb.h>
  1022. # include <dev/usb/usbhid.h>
  1023. #endif
  1024. #if defined(HAVE_USBHID_H)
  1025. #include <usbhid.h>
  1026. #elif defined(HAVE_LIBUSB_H)
  1027. #include <libusb.h>
  1028. #elif defined(HAVE_LIBUSBHID_H)
  1029. #include <libusbhid.h>
  1030. #endif
  1031. int main(int argc, char **argv) {
  1032. struct report_desc *repdesc;
  1033. struct usb_ctl_report *repbuf;
  1034. hid_kind_t hidkind;
  1035. return 0;
  1036. }" HAVE_USBHID)
  1037. if(HAVE_USBHID)
  1038. check_c_source_compiles("
  1039. #include <sys/types.h>
  1040. #if defined(HAVE_USB_H)
  1041. #include <usb.h>
  1042. #endif
  1043. #ifdef __DragonFly__
  1044. # include <bus/u4b/usb.h>
  1045. # include <bus/u4b/usbhid.h>
  1046. #else
  1047. # include <dev/usb/usb.h>
  1048. # include <dev/usb/usbhid.h>
  1049. #endif
  1050. #if defined(HAVE_USBHID_H)
  1051. #include <usbhid.h>
  1052. #elif defined(HAVE_LIBUSB_H)
  1053. #include <libusb.h>
  1054. #elif defined(HAVE_LIBUSBHID_H)
  1055. #include <libusbhid.h>
  1056. #endif
  1057. int main(int argc, char** argv) {
  1058. struct usb_ctl_report buf;
  1059. if (buf.ucr_data) { }
  1060. return 0;
  1061. }" HAVE_USBHID_UCR_DATA)
  1062. if(HAVE_USBHID_UCR_DATA)
  1063. set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_UCR_DATA")
  1064. endif()
  1065. check_c_source_compiles("
  1066. #include <sys/types.h>
  1067. #if defined(HAVE_USB_H)
  1068. #include <usb.h>
  1069. #endif
  1070. #ifdef __DragonFly__
  1071. #include <bus/u4b/usb.h>
  1072. #include <bus/u4b/usbhid.h>
  1073. #else
  1074. #include <dev/usb/usb.h>
  1075. #include <dev/usb/usbhid.h>
  1076. #endif
  1077. #if defined(HAVE_USBHID_H)
  1078. #include <usbhid.h>
  1079. #elif defined(HAVE_LIBUSB_H)
  1080. #include <libusb.h>
  1081. #elif defined(HAVE_LIBUSBHID_H)
  1082. #include <libusbhid.h>
  1083. #endif
  1084. int main(int argc, char **argv) {
  1085. report_desc_t d;
  1086. hid_start_parse(d, 1, 1);
  1087. return 0;
  1088. }" HAVE_USBHID_NEW)
  1089. if(HAVE_USBHID_NEW)
  1090. set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_NEW")
  1091. endif()
  1092. check_c_source_compiles("
  1093. #include <machine/joystick.h>
  1094. int main(int argc, char** argv) {
  1095. struct joystick t;
  1096. return 0;
  1097. }" HAVE_MACHINE_JOYSTICK)
  1098. if(HAVE_MACHINE_JOYSTICK)
  1099. set(SDL_HAVE_MACHINE_JOYSTICK_H 1)
  1100. endif()
  1101. set(SDL_JOYSTICK_USBHID 1)
  1102. file(GLOB BSD_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/bsd/*.c)
  1103. list(APPEND SOURCE_FILES ${BSD_JOYSTICK_SOURCES})
  1104. list(APPEND EXTRA_CFLAGS ${USB_CFLAGS})
  1105. list(APPEND EXTRA_LIBS ${USB_LIBS})
  1106. set(HAVE_SDL_JOYSTICK TRUE)
  1107. set(CMAKE_REQUIRED_LIBRARIES)
  1108. set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
  1109. endif()
  1110. endmacro()
  1111. # Check for HIDAPI support
  1112. macro(CheckHIDAPI)
  1113. set(HAVE_HIDAPI TRUE)
  1114. if(SDL_HIDAPI)
  1115. if(SDL_HIDAPI_LIBUSB)
  1116. set(HAVE_LIBUSB FALSE)
  1117. pkg_check_modules(PKG_LIBUSB libusb-1.0)
  1118. if(PKG_LIBUSB_FOUND)
  1119. check_include_file(libusb.h HAVE_LIBUSB_H ${PKG_LIBUSB_CFLAGS})
  1120. if(HAVE_LIBUSB_H)
  1121. set(HAVE_LIBUSB TRUE)
  1122. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PKG_LIBUSB_CFLAGS}")
  1123. if(HIDAPI_ONLY_LIBUSB)
  1124. list(APPEND EXTRA_LIBS ${PKG_LIBUSB_LIBRARIES})
  1125. elseif(OS2)
  1126. set(SDL_LIBUSB_DYNAMIC "\"usb100.dll\"")
  1127. else()
  1128. # libusb is loaded dynamically, so don't add it to EXTRA_LIBS
  1129. FindLibraryAndSONAME("usb-1.0" LIBDIRS ${PKG_LIBUSB_LIBRARY_DIRS})
  1130. if(USB_1.0_LIB)
  1131. set(SDL_LIBUSB_DYNAMIC "\"${USB_1.0_LIB_SONAME}\"")
  1132. endif()
  1133. endif()
  1134. endif()
  1135. endif()
  1136. if(HIDAPI_ONLY_LIBUSB AND NOT HAVE_LIBUSB)
  1137. set(HAVE_HIDAPI FALSE)
  1138. endif()
  1139. set(HAVE_HIDAPI_LIBUSB ${HAVE_LIBUSB})
  1140. endif()
  1141. if(HAVE_HIDAPI)
  1142. if(ANDROID)
  1143. list(APPEND SOURCE_FILES ${SDL2_SOURCE_DIR}/src/hidapi/android/hid.cpp)
  1144. endif()
  1145. if(IOS OR TVOS)
  1146. list(APPEND SOURCE_FILES ${SDL2_SOURCE_DIR}/src/hidapi/ios/hid.m)
  1147. set(SDL_FRAMEWORK_COREBLUETOOTH 1)
  1148. endif()
  1149. set(HAVE_SDL_HIDAPI TRUE)
  1150. if(SDL_JOYSTICK AND SDL_HIDAPI_JOYSTICK)
  1151. set(SDL_JOYSTICK_HIDAPI 1)
  1152. set(HAVE_SDL_JOYSTICK TRUE)
  1153. set(HAVE_HIDAPI_JOYSTICK TRUE)
  1154. file(GLOB HIDAPI_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/hidapi/*.c)
  1155. list(APPEND SOURCE_FILES ${HIDAPI_JOYSTICK_SOURCES})
  1156. endif()
  1157. else()
  1158. set(SDL_HIDAPI_DISABLED 1)
  1159. endif()
  1160. else()
  1161. set(SDL_HIDAPI_DISABLED 1)
  1162. endif()
  1163. endmacro()
  1164. # Requires:
  1165. # - n/a
  1166. macro(CheckRPI)
  1167. if(SDL_RPI)
  1168. pkg_check_modules(VIDEO_RPI bcm_host brcmegl)
  1169. if (NOT VIDEO_RPI_FOUND)
  1170. set(VIDEO_RPI_INCLUDE_DIRS "/opt/vc/include" "/opt/vc/include/interface/vcos/pthreads" "/opt/vc/include/interface/vmcs_host/linux/" )
  1171. set(VIDEO_RPI_LIBRARY_DIRS "/opt/vc/lib" )
  1172. set(VIDEO_RPI_LIBRARIES bcm_host )
  1173. set(VIDEO_RPI_LDFLAGS "-Wl,-rpath,/opt/vc/lib")
  1174. endif()
  1175. listtostr(VIDEO_RPI_INCLUDE_DIRS VIDEO_RPI_INCLUDE_FLAGS "-I")
  1176. listtostr(VIDEO_RPI_LIBRARY_DIRS VIDEO_RPI_LIBRARY_FLAGS "-L")
  1177. set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
  1178. set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
  1179. set(CMAKE_REQUIRED_LIBRARIES "${VIDEO_RPI_LIBRARIES}")
  1180. check_c_source_compiles("
  1181. #include <bcm_host.h>
  1182. #include <EGL/eglplatform.h>
  1183. int main(int argc, char **argv) {
  1184. EGL_DISPMANX_WINDOW_T window;
  1185. bcm_host_init();
  1186. }" HAVE_RPI)
  1187. set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
  1188. set(CMAKE_REQUIRED_LIBRARIES)
  1189. if(SDL_VIDEO AND HAVE_RPI)
  1190. set(HAVE_SDL_VIDEO TRUE)
  1191. set(SDL_VIDEO_DRIVER_RPI 1)
  1192. file(GLOB VIDEO_RPI_SOURCES ${SDL2_SOURCE_DIR}/src/video/raspberry/*.c)
  1193. list(APPEND SOURCE_FILES ${VIDEO_RPI_SOURCES})
  1194. list(APPEND EXTRA_LIBS ${VIDEO_RPI_LIBRARIES})
  1195. # !!! FIXME: shouldn't be using CMAKE_C_FLAGS, right?
  1196. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
  1197. list(APPEND EXTRA_LDFLAGS ${VIDEO_RPI_LDFLAGS})
  1198. endif()
  1199. endif()
  1200. endmacro()
  1201. # Requires:
  1202. # - EGL
  1203. # - PkgCheckModules
  1204. # Optional:
  1205. # - SDL_KMSDRM_SHARED opt
  1206. # - HAVE_SDL_LOADSO opt
  1207. macro(CheckKMSDRM)
  1208. if(SDL_KMSDRM)
  1209. pkg_check_modules(PKG_KMSDRM libdrm gbm egl)
  1210. if(PKG_KMSDRM_FOUND AND HAVE_OPENGL_EGL)
  1211. target_link_directories(sdl-build-options INTERFACE ${PKG_KMSDRM_LIBRARY_DIRS})
  1212. target_include_directories(sdl-build-options INTERFACE "${PKG_KMSDRM_INCLUDE_DIRS}")
  1213. set(HAVE_KMSDRM TRUE)
  1214. set(HAVE_SDL_VIDEO TRUE)
  1215. file(GLOB KMSDRM_SOURCES ${SDL2_SOURCE_DIR}/src/video/kmsdrm/*.c)
  1216. list(APPEND SOURCE_FILES ${KMSDRM_SOURCES})
  1217. list(APPEND EXTRA_CFLAGS ${PKG_KMSDRM_CFLAGS})
  1218. set(SDL_VIDEO_DRIVER_KMSDRM 1)
  1219. if(SDL_KMSDRM_SHARED AND NOT HAVE_SDL_LOADSO)
  1220. message_warn("You must have SDL_LoadObject() support for dynamic KMS/DRM loading")
  1221. endif()
  1222. if(SDL_KMSDRM_SHARED AND HAVE_SDL_LOADSO)
  1223. FindLibraryAndSONAME(drm LIBDIRS ${PKG_KMSDRM_LIBRARY_DIRS})
  1224. FindLibraryAndSONAME(gbm LIBDIRS ${PKG_KMSDRM_LIBRARY_DIRS})
  1225. set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC "\"${DRM_LIB_SONAME}\"")
  1226. set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM "\"${GBM_LIB_SONAME}\"")
  1227. set(HAVE_KMSDRM_SHARED TRUE)
  1228. else()
  1229. list(APPEND EXTRA_LIBS ${PKG_KMSDRM_LIBRARIES})
  1230. endif()
  1231. endif()
  1232. endif()
  1233. endmacro()
  1234. macro(CheckLibUDev)
  1235. if(SDL_LIBUDEV)
  1236. check_include_file("libudev.h" have_libudev_header)
  1237. if(have_libudev_header)
  1238. set(HAVE_LIBUDEV_H TRUE)
  1239. FindLibraryAndSONAME(udev)
  1240. if(UDEV_LIB_SONAME)
  1241. set(SDL_UDEV_DYNAMIC "\"${UDEV_LIB_SONAME}\"")
  1242. endif()
  1243. endif()
  1244. endif()
  1245. endmacro()