🛠️🐜 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.

300 lines
9.2 KiB

  1. cmake_minimum_required(VERSION 3.0.0)
  2. project(SDL2 C)
  3. # Global settings for all of the test targets
  4. # FIXME: is this wrong?
  5. remove_definitions(-DUSING_GENERATED_CONFIG_H)
  6. if(PSP)
  7. link_libraries(
  8. SDL2main
  9. SDL2_test
  10. SDL2-static
  11. GL
  12. pspvram
  13. pspvfpu
  14. pspdisplay
  15. pspgu
  16. pspge
  17. pspaudio
  18. pspctrl
  19. psphprm
  20. psppower
  21. )
  22. else()
  23. link_libraries(SDL2_test SDL2-static)
  24. endif()
  25. if(WINDOWS)
  26. # mingw32 must come before SDL2main to link successfully
  27. if(MINGW OR CYGWIN)
  28. link_libraries(mingw32)
  29. endif()
  30. # FIXME: Parent directory CMakeLists.txt only sets these for mingw/cygwin,
  31. # but we need them for VS as well.
  32. link_libraries(SDL2main)
  33. add_definitions(-Dmain=SDL_main)
  34. endif()
  35. # CMake incorrectly detects opengl32.lib being present on MSVC ARM64
  36. if(NOT MSVC OR NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64")
  37. find_package(OpenGL)
  38. endif()
  39. if (OPENGL_FOUND)
  40. add_definitions(-DHAVE_OPENGL)
  41. endif()
  42. add_executable(checkkeys checkkeys.c)
  43. add_executable(checkkeysthreads checkkeysthreads.c)
  44. add_executable(loopwave loopwave.c)
  45. add_executable(loopwavequeue loopwavequeue.c)
  46. add_executable(testsurround testsurround.c)
  47. add_executable(testresample testresample.c)
  48. add_executable(testaudioinfo testaudioinfo.c)
  49. file(GLOB TESTAUTOMATION_SOURCE_FILES testautomation*.c)
  50. add_executable(testautomation ${TESTAUTOMATION_SOURCE_FILES})
  51. add_executable(testmultiaudio testmultiaudio.c)
  52. add_executable(testaudiohotplug testaudiohotplug.c)
  53. add_executable(testaudiocapture testaudiocapture.c)
  54. add_executable(testatomic testatomic.c)
  55. add_executable(testintersections testintersections.c)
  56. add_executable(testrelative testrelative.c)
  57. add_executable(testhittesting testhittesting.c)
  58. add_executable(testdraw2 testdraw2.c)
  59. add_executable(testdrawchessboard testdrawchessboard.c)
  60. add_executable(testdropfile testdropfile.c)
  61. add_executable(testerror testerror.c)
  62. add_executable(testfile testfile.c)
  63. add_executable(testgamecontroller testgamecontroller.c)
  64. add_executable(testgeometry testgeometry.c)
  65. add_executable(testgesture testgesture.c)
  66. add_executable(testgl2 testgl2.c)
  67. add_executable(testgles testgles.c)
  68. add_executable(testgles2 testgles2.c)
  69. add_executable(testhaptic testhaptic.c)
  70. add_executable(testhotplug testhotplug.c)
  71. add_executable(testrumble testrumble.c)
  72. add_executable(testthread testthread.c)
  73. add_executable(testiconv testiconv.c)
  74. add_executable(testime testime.c)
  75. add_executable(testjoystick testjoystick.c)
  76. add_executable(testkeys testkeys.c)
  77. add_executable(testloadso testloadso.c)
  78. add_executable(testlock testlock.c)
  79. add_executable(testmouse testmouse.c)
  80. if(APPLE)
  81. add_executable(testnative testnative.c
  82. testnativecocoa.m
  83. testnativex11.c)
  84. elseif(WINDOWS)
  85. add_executable(testnative testnative.c testnativew32.c)
  86. elseif(UNIX)
  87. add_executable(testnative testnative.c testnativex11.c)
  88. endif()
  89. add_executable(testoverlay2 testoverlay2.c testyuv_cvt.c)
  90. add_executable(testplatform testplatform.c)
  91. add_executable(testpower testpower.c)
  92. add_executable(testfilesystem testfilesystem.c)
  93. add_executable(testrendertarget testrendertarget.c)
  94. add_executable(testscale testscale.c)
  95. add_executable(testsem testsem.c)
  96. add_executable(testshader testshader.c)
  97. add_executable(testshape testshape.c)
  98. add_executable(testsprite2 testsprite2.c)
  99. add_executable(testspriteminimal testspriteminimal.c)
  100. add_executable(teststreaming teststreaming.c)
  101. add_executable(testtimer testtimer.c)
  102. add_executable(testver testver.c)
  103. add_executable(testviewport testviewport.c)
  104. add_executable(testwm2 testwm2.c)
  105. add_executable(testyuv testyuv.c testyuv_cvt.c)
  106. add_executable(torturethread torturethread.c)
  107. add_executable(testrendercopyex testrendercopyex.c)
  108. add_executable(testmessage testmessage.c)
  109. add_executable(testdisplayinfo testdisplayinfo.c)
  110. add_executable(testqsort testqsort.c)
  111. add_executable(testbounds testbounds.c)
  112. add_executable(testcustomcursor testcustomcursor.c)
  113. add_executable(controllermap controllermap.c)
  114. add_executable(testvulkan testvulkan.c)
  115. add_executable(testoffscreen testoffscreen.c)
  116. if(OPENGL_FOUND)
  117. add_dependencies(testshader OpenGL::GL)
  118. add_dependencies(testgl2 OpenGL::GL)
  119. target_link_libraries(testshader OpenGL::GL)
  120. target_link_libraries(testgl2 OpenGL::GL)
  121. endif()
  122. file(GLOB RESOURCE_FILES *.bmp *.wav *.hex moose.dat utf8.txt)
  123. file(COPY ${RESOURCE_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
  124. if(PSP)
  125. set(NEEDS_RESOURCES
  126. testscale
  127. testrendercopyex
  128. controllermap
  129. testyuv
  130. testgamecontroller
  131. testshape
  132. testshader
  133. testspriteminimal
  134. testautomation
  135. testrendertarget
  136. testsprite2
  137. loopwave
  138. loopwavequeue
  139. testresample
  140. testaudiohotplug
  141. testmultiaudio
  142. testiconv
  143. testoverlay2
  144. teststreaming
  145. testviewport
  146. )
  147. else()
  148. set(NEEDS_RESOURCES
  149. testscale
  150. testrendercopyex
  151. controllermap
  152. testyuv
  153. testgamecontroller
  154. testshape
  155. testshader
  156. testspriteminimal
  157. testautomation
  158. testcustomcursor
  159. testrendertarget
  160. testsprite2
  161. loopwave
  162. loopwavequeue
  163. testresample
  164. testaudiohotplug
  165. testmultiaudio
  166. testime
  167. testnative
  168. testiconv
  169. testoverlay2
  170. teststreaming
  171. testviewport
  172. )
  173. endif()
  174. if(PSP)
  175. # Build EBOOT files if building for PSP
  176. set(BUILD_EBOOT
  177. ${NEEDS_RESOURCES}
  178. testbounds
  179. testgl2
  180. testsem
  181. testdisplayinfo
  182. teststreaming
  183. testgeometry
  184. testfile
  185. testdraw2
  186. testviewport
  187. testhittesting
  188. testoverlay2
  189. testver
  190. testdrawchessboard
  191. testsurround
  192. testintersections
  193. testmessage
  194. testaudiocapture
  195. testerror
  196. testatomic
  197. testjoystick
  198. testiconv
  199. testfilesystem
  200. testplatform
  201. testthread
  202. testqsort
  203. testaudioinfo
  204. testlock
  205. testtimer
  206. testpower
  207. testwm2
  208. torturethread
  209. )
  210. foreach(APP IN LISTS BUILD_EBOOT)
  211. create_pbp_file(
  212. TARGET ${APP}
  213. TITLE SDL-${APP}
  214. ICON_PATH NULL
  215. BACKGROUND_PATH NULL
  216. PREVIEW_PATH NULL
  217. )
  218. add_custom_command(
  219. TARGET ${APP} POST_BUILD
  220. COMMAND ${CMAKE_COMMAND} -E make_directory
  221. $<TARGET_FILE_DIR:${ARG_TARGET}>/sdl-${APP}
  222. )
  223. add_custom_command(
  224. TARGET ${APP} POST_BUILD
  225. COMMAND ${CMAKE_COMMAND} -E rename
  226. $<TARGET_FILE_DIR:${ARG_TARGET}>/EBOOT.PBP
  227. $<TARGET_FILE_DIR:${ARG_TARGET}>/sdl-${APP}/EBOOT.PBP
  228. )
  229. if(${BUILD_PRX})
  230. add_custom_command(
  231. TARGET ${APP} POST_BUILD
  232. COMMAND ${CMAKE_COMMAND} -E copy
  233. $<TARGET_FILE_DIR:${ARG_TARGET}>/${APP}
  234. $<TARGET_FILE_DIR:${ARG_TARGET}>/sdl-${APP}/${APP}
  235. )
  236. add_custom_command(
  237. TARGET ${APP} POST_BUILD
  238. COMMAND ${CMAKE_COMMAND} -E rename
  239. $<TARGET_FILE_DIR:${ARG_TARGET}>/${APP}.prx
  240. $<TARGET_FILE_DIR:${ARG_TARGET}>/sdl-${APP}/${APP}.prx
  241. )
  242. endif()
  243. add_custom_command(
  244. TARGET ${APP} POST_BUILD
  245. COMMAND ${CMAKE_COMMAND} -E remove
  246. $<TARGET_FILE_DIR:${ARG_TARGET}>/PARAM.SFO
  247. )
  248. endforeach()
  249. endif()
  250. foreach(APP IN LISTS NEEDS_RESOURCES)
  251. foreach(RESOURCE_FILE ${RESOURCE_FILES})
  252. if(PSP)
  253. add_custom_command(TARGET ${APP} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${RESOURCE_FILE} $<TARGET_FILE_DIR:${APP}>/sdl-${APP})
  254. else()
  255. add_custom_command(TARGET ${APP} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${RESOURCE_FILE} $<TARGET_FILE_DIR:${APP}>)
  256. endif()
  257. endforeach(RESOURCE_FILE)
  258. if(APPLE)
  259. # Make sure resource files get installed into macOS/iOS .app bundles.
  260. target_sources(${APP} PRIVATE "${RESOURCE_FILES}")
  261. set_target_properties(${APP} PROPERTIES RESOURCE "${RESOURCE_FILES}")
  262. endif()
  263. endforeach()
  264. # Set Apple App ID / Bundle ID. This is needed to launch apps on some Apple
  265. # platforms (iOS, for example).
  266. if(APPLE)
  267. if(${CMAKE_VERSION} VERSION_LESS "3.7.0")
  268. # CMake's 'BUILDSYSTEM_TARGETS' property is only available in
  269. # CMake 3.7 and above.
  270. message(WARNING "Unable to set Bundle ID for Apple .app builds due to old CMake (pre 3.7).")
  271. else()
  272. get_property(TARGETS DIRECTORY ${CMAKE_CURRENT_LIST_DIR} PROPERTY BUILDSYSTEM_TARGETS)
  273. foreach(CURRENT_TARGET IN LISTS TARGETS)
  274. get_property(TARGET_TYPE TARGET ${CURRENT_TARGET} PROPERTY TYPE)
  275. if(TARGET_TYPE STREQUAL "EXECUTABLE")
  276. set_target_properties("${CURRENT_TARGET}" PROPERTIES
  277. MACOSX_BUNDLE_GUI_IDENTIFIER "org.libsdl.${CURRENT_TARGET}"
  278. MACOSX_BUNDLE_BUNDLE_VERSION "${SDL_VERSION}"
  279. MACOSX_BUNDLE_SHORT_VERSION_STRING "${SDL_VERSION}"
  280. )
  281. endif()
  282. endforeach()
  283. endif()
  284. endif()