CMakeLists.txt 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. cmake_minimum_required(VERSION 3.0...3.5)
  2. project(SDL2_test)
  3. include(CheckCCompilerFlag)
  4. include(CMakeParseArguments)
  5. include(CMakePushCheckState)
  6. set(SDL_TEST_EXECUTABLES)
  7. set(SDL_TESTS_NONINTERACTIVE)
  8. set(SDL_TESTS_NEEDS_RESOURCES)
  9. macro(add_sdl_test_executable TARGET)
  10. cmake_parse_arguments(AST "NONINTERACTIVE;NEEDS_RESOURCES" "" "" ${ARGN})
  11. if(ANDROID)
  12. add_library(${TARGET} SHARED ${AST_UNPARSED_ARGUMENTS})
  13. else()
  14. add_executable(${TARGET} ${AST_UNPARSED_ARGUMENTS})
  15. endif()
  16. list(APPEND SDL_TEST_EXECUTABLES ${TARGET})
  17. if(AST_NONINTERACTIVE)
  18. list(APPEND SDL_TESTS_NONINTERACTIVE ${TARGET})
  19. endif()
  20. if(AST_NEEDS_RESOURCES)
  21. list(APPEND SDL_TESTS_NEEDS_RESOURCES ${TARGET})
  22. endif()
  23. if(HAVE_GCC_WDOCUMENTATION)
  24. target_compile_options(${TARGET} PRIVATE "-Wdocumentation")
  25. if(HAVE_GCC_WERROR_DOCUMENTATION)
  26. target_compile_options(${TARGET} PRIVATE "-Werror=documentation")
  27. endif()
  28. endif()
  29. if(HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND)
  30. if(SDL_WERROR)
  31. if(HAVE_GCC_WERROR_DOCUMENTATION_UNKNOWN_COMMAND)
  32. target_compile_options(${TARGET} PRIVATE "-Werror=documentation-unknown-command")
  33. endif()
  34. endif()
  35. target_compile_options(${TARGET} PRIVATE "-Wdocumentation-unknown-command")
  36. endif()
  37. if(HAVE_GCC_COMMENT_BLOCK_COMMANDS)
  38. target_compile_options(${TARGET} PRIVATE "-fcomment-block-commands=threadsafety")
  39. target_compile_options(${TARGET} PRIVATE "-fcomment-block-commands=deprecated")
  40. else()
  41. if(HAVE_CLANG_COMMENT_BLOCK_COMMANDS)
  42. target_compile_options(${TARGET} PRIVATE "/clang:-fcomment-block-commands=threadsafety")
  43. target_compile_options(${TARGET} PRIVATE "/clang:-fcomment-block-commands=deprecated")
  44. endif()
  45. endif()
  46. if(USE_GCC OR USE_CLANG)
  47. check_c_compiler_flag(-fno-fast-math HAVE_GCC_FNO_FAST_MATH)
  48. if(HAVE_GCC_FNO_FAST_MATH)
  49. target_compile_options(${TARGET} PRIVATE -fno-fast-math)
  50. endif()
  51. endif()
  52. endmacro()
  53. if(NOT TARGET SDL2::SDL2-static)
  54. find_package(SDL2 2.0.23 REQUIRED COMPONENTS SDL2-static SDL2test)
  55. endif()
  56. enable_testing()
  57. if(SDL_INSTALL_TESTS)
  58. include(GNUInstallDirs)
  59. endif()
  60. if(N3DS)
  61. link_libraries(SDL2::SDL2main)
  62. endif()
  63. if(PSP)
  64. link_libraries(
  65. SDL2::SDL2main
  66. SDL2::SDL2test
  67. SDL2::SDL2-static
  68. GL
  69. pspvram
  70. pspvfpu
  71. pspdisplay
  72. pspgu
  73. pspge
  74. pspaudio
  75. pspctrl
  76. psphprm
  77. psppower
  78. )
  79. elseif(PS2)
  80. link_libraries(
  81. SDL2main
  82. SDL2_test
  83. SDL2-static
  84. patches
  85. gskit
  86. dmakit
  87. ps2_drivers
  88. )
  89. else()
  90. link_libraries(SDL2::SDL2test SDL2::SDL2-static)
  91. endif()
  92. if(WINDOWS)
  93. # mingw32 must come before SDL2main to link successfully
  94. if(MINGW OR CYGWIN)
  95. link_libraries(mingw32)
  96. endif()
  97. # CET support was added in VS 16.7
  98. if(MSVC_VERSION GREATER 1926 AND CMAKE_GENERATOR_PLATFORM MATCHES "Win32|x64")
  99. link_libraries(-CETCOMPAT)
  100. endif()
  101. # FIXME: Parent directory CMakeLists.txt only sets these for mingw/cygwin,
  102. # but we need them for VS as well.
  103. link_libraries(SDL2main)
  104. add_definitions(-Dmain=SDL_main)
  105. endif()
  106. # CMake incorrectly detects opengl32.lib being present on MSVC ARM64
  107. if(NOT MSVC OR NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64")
  108. # Prefer GLVND, if present
  109. set(OpenGL_GL_PREFERENCE GLVND)
  110. find_package(OpenGL)
  111. endif()
  112. if (OPENGL_FOUND)
  113. add_definitions(-DHAVE_OPENGL)
  114. endif()
  115. add_sdl_test_executable(checkkeys checkkeys.c)
  116. add_sdl_test_executable(checkkeysthreads checkkeysthreads.c)
  117. add_sdl_test_executable(loopwave NEEDS_RESOURCES loopwave.c testutils.c)
  118. add_sdl_test_executable(loopwavequeue NEEDS_RESOURCES loopwavequeue.c testutils.c)
  119. add_sdl_test_executable(testsurround testsurround.c)
  120. add_sdl_test_executable(testresample NEEDS_RESOURCES testresample.c)
  121. add_sdl_test_executable(testaudioinfo testaudioinfo.c)
  122. file(GLOB TESTAUTOMATION_SOURCE_FILES testautomation*.c)
  123. add_sdl_test_executable(testautomation NONINTERACTIVE NEEDS_RESOURCES ${TESTAUTOMATION_SOURCE_FILES})
  124. add_sdl_test_executable(testmultiaudio NEEDS_RESOURCES testmultiaudio.c testutils.c)
  125. add_sdl_test_executable(testaudiohotplug NEEDS_RESOURCES testaudiohotplug.c testutils.c)
  126. add_sdl_test_executable(testaudiocapture testaudiocapture.c)
  127. add_sdl_test_executable(testatomic NONINTERACTIVE testatomic.c)
  128. add_sdl_test_executable(testintersections testintersections.c)
  129. add_sdl_test_executable(testrelative testrelative.c)
  130. add_sdl_test_executable(testhittesting testhittesting.c)
  131. add_sdl_test_executable(testdraw2 testdraw2.c)
  132. add_sdl_test_executable(testdrawchessboard testdrawchessboard.c)
  133. add_sdl_test_executable(testdropfile testdropfile.c)
  134. add_sdl_test_executable(testerror NONINTERACTIVE testerror.c)
  135. if(LINUX)
  136. add_sdl_test_executable(testevdev NONINTERACTIVE testevdev.c)
  137. endif()
  138. add_sdl_test_executable(testfile testfile.c)
  139. add_sdl_test_executable(testgamecontroller NEEDS_RESOURCES testgamecontroller.c testutils.c)
  140. add_sdl_test_executable(testgeometry testgeometry.c testutils.c)
  141. add_sdl_test_executable(testgesture testgesture.c)
  142. add_sdl_test_executable(testgl2 testgl2.c)
  143. add_sdl_test_executable(testgles testgles.c)
  144. add_sdl_test_executable(testgles2 testgles2.c)
  145. add_sdl_test_executable(testgles2_sdf NEEDS_RESOURCES testgles2_sdf.c testutils.c)
  146. add_sdl_test_executable(testhaptic testhaptic.c)
  147. add_sdl_test_executable(testhotplug testhotplug.c)
  148. add_sdl_test_executable(testrumble testrumble.c)
  149. add_sdl_test_executable(testthread NONINTERACTIVE testthread.c)
  150. add_sdl_test_executable(testiconv NEEDS_RESOURCES testiconv.c testutils.c)
  151. add_sdl_test_executable(testime NEEDS_RESOURCES testime.c testutils.c)
  152. add_sdl_test_executable(testjoystick testjoystick.c)
  153. add_sdl_test_executable(testkeys testkeys.c)
  154. add_sdl_test_executable(testloadso testloadso.c)
  155. add_sdl_test_executable(testlocale NONINTERACTIVE testlocale.c)
  156. add_sdl_test_executable(testlock testlock.c)
  157. add_sdl_test_executable(testmouse testmouse.c)
  158. if(APPLE)
  159. add_sdl_test_executable(testnative NEEDS_RESOURCES
  160. testnative.c
  161. testnativecocoa.m
  162. testnativex11.c
  163. testutils.c
  164. )
  165. cmake_push_check_state(RESET)
  166. check_c_compiler_flag(-Wno-error=deprecated-declarations HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS)
  167. cmake_pop_check_state()
  168. if(HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS)
  169. set_property(SOURCE "testnativecocoa.m" APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-error=deprecated-declarations")
  170. endif()
  171. elseif(WINDOWS)
  172. add_sdl_test_executable(testnative NEEDS_RESOURCES testnative.c testnativew32.c testutils.c)
  173. elseif(HAVE_X11)
  174. add_sdl_test_executable(testnative NEEDS_RESOURCES testnative.c testnativex11.c testutils.c)
  175. target_link_libraries(testnative X11)
  176. elseif(OS2)
  177. add_sdl_test_executable(testnative NEEDS_RESOURCES testnative.c testnativeos2.c testutils.c)
  178. endif()
  179. add_sdl_test_executable(testoverlay2 NEEDS_RESOURCES testoverlay2.c testyuv_cvt.c testutils.c)
  180. add_sdl_test_executable(testplatform NONINTERACTIVE testplatform.c)
  181. add_sdl_test_executable(testpower NONINTERACTIVE testpower.c)
  182. add_sdl_test_executable(testfilesystem NONINTERACTIVE testfilesystem.c)
  183. if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
  184. add_sdl_test_executable(testfilesystem_pre NONINTERACTIVE testfilesystem_pre.c)
  185. endif()
  186. add_sdl_test_executable(testrendertarget NEEDS_RESOURCES testrendertarget.c testutils.c)
  187. add_sdl_test_executable(testscale NEEDS_RESOURCES testscale.c testutils.c)
  188. add_sdl_test_executable(testsem testsem.c)
  189. add_sdl_test_executable(testsensor testsensor.c)
  190. add_sdl_test_executable(testshader NEEDS_RESOURCES testshader.c)
  191. add_sdl_test_executable(testshape NEEDS_RESOURCES testshape.c)
  192. add_sdl_test_executable(testsprite2 NEEDS_RESOURCES testsprite2.c testutils.c)
  193. add_sdl_test_executable(testspriteminimal NEEDS_RESOURCES testspriteminimal.c testutils.c)
  194. add_sdl_test_executable(teststreaming NEEDS_RESOURCES teststreaming.c testutils.c)
  195. add_sdl_test_executable(testtimer NONINTERACTIVE testtimer.c)
  196. add_sdl_test_executable(testurl testurl.c)
  197. add_sdl_test_executable(testver NONINTERACTIVE testver.c)
  198. add_sdl_test_executable(testviewport NEEDS_RESOURCES testviewport.c testutils.c)
  199. add_sdl_test_executable(testwm2 testwm2.c)
  200. add_sdl_test_executable(testyuv NEEDS_RESOURCES testyuv.c testyuv_cvt.c)
  201. add_sdl_test_executable(torturethread torturethread.c)
  202. add_sdl_test_executable(testrendercopyex NEEDS_RESOURCES testrendercopyex.c testutils.c)
  203. add_sdl_test_executable(testmessage testmessage.c)
  204. add_sdl_test_executable(testdisplayinfo testdisplayinfo.c)
  205. add_sdl_test_executable(testqsort NONINTERACTIVE testqsort.c)
  206. add_sdl_test_executable(testbounds testbounds.c)
  207. add_sdl_test_executable(testcustomcursor testcustomcursor.c)
  208. add_sdl_test_executable(controllermap NEEDS_RESOURCES controllermap.c testutils.c)
  209. add_sdl_test_executable(testvulkan testvulkan.c)
  210. add_sdl_test_executable(testoffscreen testoffscreen.c)
  211. cmake_push_check_state(RESET)
  212. check_c_compiler_flag(-Wformat-overflow HAVE_WFORMAT_OVERFLOW)
  213. if(HAVE_WFORMAT_OVERFLOW)
  214. target_compile_definitions(testautomation PRIVATE HAVE_WFORMAT_OVERFLOW)
  215. endif()
  216. check_c_compiler_flag(-Wformat HAVE_WFORMAT)
  217. if(HAVE_WFORMAT)
  218. target_compile_definitions(testautomation PRIVATE HAVE_WFORMAT)
  219. endif()
  220. check_c_compiler_flag(-Wformat-extra-args HAVE_WFORMAT_EXTRA_ARGS)
  221. if(HAVE_WFORMAT_EXTRA_ARGS)
  222. target_compile_definitions(testautomation PRIVATE HAVE_WFORMAT_EXTRA_ARGS)
  223. endif()
  224. cmake_pop_check_state()
  225. if(SDL_DUMMYAUDIO)
  226. list(APPEND SDL_TESTS_NONINTERACTIVE
  227. testaudioinfo
  228. testsurround
  229. )
  230. endif()
  231. if(SDL_DUMMYVIDEO)
  232. list(APPEND SDL_TESTS_NONINTERACTIVE
  233. testkeys
  234. testbounds
  235. testdisplayinfo
  236. )
  237. endif()
  238. if(OPENGL_FOUND)
  239. if(TARGET OpenGL::GL)
  240. target_link_libraries(testshader OpenGL::GL)
  241. target_link_libraries(testgl2 OpenGL::GL)
  242. else()
  243. if(EMSCRIPTEN AND OPENGL_gl_LIBRARY STREQUAL "nul")
  244. set(OPENGL_gl_LIBRARY GL)
  245. endif()
  246. # emscripten's FindOpenGL.cmake does not create OpenGL::GL
  247. target_link_libraries(testshader ${OPENGL_gl_LIBRARY})
  248. target_link_libraries(testgl2 ${OPENGL_gl_LIBRARY})
  249. endif()
  250. endif()
  251. if(EMSCRIPTEN)
  252. target_link_libraries(testshader -sLEGACY_GL_EMULATION)
  253. endif()
  254. file(GLOB RESOURCE_FILES *.bmp *.wav *.hex moose.dat utf8.txt)
  255. file(COPY ${RESOURCE_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
  256. if(PSP)
  257. # Build EBOOT files if building for PSP
  258. set(BUILD_EBOOT
  259. ${SDL_TESTS_NEEDS_RESOURCES}
  260. testatomic
  261. testaudiocapture
  262. testaudioinfo
  263. testbounds
  264. testdisplayinfo
  265. testdraw2
  266. testdrawchessboard
  267. testerror
  268. testfile
  269. testfilesystem
  270. testgeometry
  271. testgl2
  272. testhittesting
  273. testiconv
  274. testintersections
  275. testjoystick
  276. testlock
  277. testmessage
  278. testoverlay2
  279. testplatform
  280. testpower
  281. testqsort
  282. testsem
  283. teststreaming
  284. testsurround
  285. testthread
  286. testtimer
  287. testver
  288. testviewport
  289. testwm2
  290. torturethread
  291. )
  292. foreach(APP IN LISTS BUILD_EBOOT)
  293. create_pbp_file(
  294. TARGET ${APP}
  295. TITLE SDL-${APP}
  296. ICON_PATH NULL
  297. BACKGROUND_PATH NULL
  298. PREVIEW_PATH NULL
  299. )
  300. add_custom_command(
  301. TARGET ${APP} POST_BUILD
  302. COMMAND ${CMAKE_COMMAND} -E make_directory
  303. $<TARGET_FILE_DIR:${ARG_TARGET}>/sdl-${APP}
  304. )
  305. add_custom_command(
  306. TARGET ${APP} POST_BUILD
  307. COMMAND ${CMAKE_COMMAND} -E rename
  308. $<TARGET_FILE_DIR:${ARG_TARGET}>/EBOOT.PBP
  309. $<TARGET_FILE_DIR:${ARG_TARGET}>/sdl-${APP}/EBOOT.PBP
  310. )
  311. if(${BUILD_PRX})
  312. add_custom_command(
  313. TARGET ${APP} POST_BUILD
  314. COMMAND ${CMAKE_COMMAND} -E copy
  315. $<TARGET_FILE_DIR:${ARG_TARGET}>/${APP}
  316. $<TARGET_FILE_DIR:${ARG_TARGET}>/sdl-${APP}/${APP}
  317. )
  318. add_custom_command(
  319. TARGET ${APP} POST_BUILD
  320. COMMAND ${CMAKE_COMMAND} -E rename
  321. $<TARGET_FILE_DIR:${ARG_TARGET}>/${APP}.prx
  322. $<TARGET_FILE_DIR:${ARG_TARGET}>/sdl-${APP}/${APP}.prx
  323. )
  324. endif()
  325. add_custom_command(
  326. TARGET ${APP} POST_BUILD
  327. COMMAND ${CMAKE_COMMAND} -E remove
  328. $<TARGET_FILE_DIR:${ARG_TARGET}>/PARAM.SFO
  329. )
  330. endforeach()
  331. endif()
  332. if(N3DS)
  333. set(ROMFS_DIR "${CMAKE_CURRENT_BINARY_DIR}/romfs")
  334. file(COPY ${RESOURCE_FILES} DESTINATION "${ROMFS_DIR}")
  335. foreach(APP IN LISTS SDL_TEST_EXECUTABLES)
  336. get_target_property(TARGET_BINARY_DIR ${APP} BINARY_DIR)
  337. set(SMDH_FILE "${TARGET_BINARY_DIR}/${APP}.smdh")
  338. ctr_generate_smdh("${SMDH_FILE}"
  339. NAME "SDL-${APP}"
  340. DESCRIPTION "SDL2 Test suite"
  341. AUTHOR "SDL2 Contributors"
  342. ICON "${CMAKE_CURRENT_SOURCE_DIR}/n3ds/logo48x48.png"
  343. )
  344. ctr_create_3dsx(
  345. ${APP}
  346. ROMFS "${ROMFS_DIR}"
  347. SMDH "${SMDH_FILE}"
  348. )
  349. endforeach()
  350. endif()
  351. if(RISCOS)
  352. set(SDL_TEST_EXECUTABLES_AIF)
  353. foreach(APP IN LISTS SDL_TEST_EXECUTABLES)
  354. target_link_options(${APP} PRIVATE -static)
  355. add_custom_command(
  356. OUTPUT ${APP},ff8
  357. COMMAND elf2aif ${APP} ${APP},ff8
  358. DEPENDS ${APP}
  359. )
  360. add_custom_target(${APP}-aif ALL DEPENDS ${APP},ff8)
  361. list(APPEND SDL_TEST_EXECUTABLES_AIF ${CMAKE_CURRENT_BINARY_DIR}/${APP},ff8)
  362. endforeach()
  363. endif()
  364. if(CMAKE_RUNTIME_OUTPUT_DIRECTORY)
  365. set(test_bin_dir "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
  366. if(NOT IS_ABSOLUTE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
  367. set(test_bin_dir "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
  368. endif()
  369. else()
  370. set(test_bin_dir "${CMAKE_CURRENT_BINARY_DIR}")
  371. endif()
  372. if(NOT CMAKE_VERSION VERSION_LESS 3.20)
  373. get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
  374. set(test_bin_dir "${test_bin_dir}$<$<BOOL:${is_multi_config}>:/$<CONFIG>>")
  375. endif()
  376. set(RESOURCE_FILES_BINDIR)
  377. foreach(resource_file IN LISTS RESOURCE_FILES)
  378. get_filename_component(res_file_name ${resource_file} NAME)
  379. set(resource_file_bindir "${test_bin_dir}/${res_file_name}")
  380. add_custom_command(OUTPUT "${resource_file_bindir}"
  381. COMMAND "${CMAKE_COMMAND}" -E copy "${resource_file}" "${resource_file_bindir}"
  382. DEPENDS "${resource_file}"
  383. )
  384. list(APPEND RESOURCE_FILES_BINDIR "${resource_file_bindir}")
  385. endforeach()
  386. add_custom_target(copy-sdl-test-resources
  387. DEPENDS "${RESOURCE_FILES_BINDIR}"
  388. )
  389. foreach(APP IN LISTS SDL_TESTS_NEEDS_RESOURCES)
  390. if(PSP OR PS2)
  391. foreach(RESOURCE_FILE ${RESOURCE_FILES})
  392. add_custom_command(TARGET ${APP} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${RESOURCE_FILE} $<TARGET_FILE_DIR:${APP}>/sdl-${APP})
  393. endforeach()
  394. else()
  395. add_dependencies(${APP} copy-sdl-test-resources)
  396. endif()
  397. if(APPLE)
  398. # Make sure resource files get installed into macOS/iOS .app bundles.
  399. target_sources(${APP} PRIVATE "${RESOURCE_FILES}")
  400. set_target_properties(${APP} PROPERTIES RESOURCE "${RESOURCE_FILES}")
  401. endif()
  402. endforeach()
  403. # Set Apple App ID / Bundle ID. This is needed to launch apps on some Apple
  404. # platforms (iOS, for example).
  405. if(APPLE)
  406. if(${CMAKE_VERSION} VERSION_LESS "3.7.0")
  407. # CMake's 'BUILDSYSTEM_TARGETS' property is only available in
  408. # CMake 3.7 and above.
  409. message(WARNING "Unable to set Bundle ID for Apple .app builds due to old CMake (pre 3.7).")
  410. else()
  411. get_property(TARGETS DIRECTORY ${CMAKE_CURRENT_LIST_DIR} PROPERTY BUILDSYSTEM_TARGETS)
  412. foreach(CURRENT_TARGET IN LISTS TARGETS)
  413. get_property(TARGET_TYPE TARGET ${CURRENT_TARGET} PROPERTY TYPE)
  414. if(TARGET_TYPE STREQUAL "EXECUTABLE")
  415. set_target_properties("${CURRENT_TARGET}" PROPERTIES
  416. MACOSX_BUNDLE_GUI_IDENTIFIER "org.libsdl.${CURRENT_TARGET}"
  417. MACOSX_BUNDLE_BUNDLE_VERSION "${SDL_VERSION}"
  418. MACOSX_BUNDLE_SHORT_VERSION_STRING "${SDL_VERSION}"
  419. )
  420. endif()
  421. endforeach()
  422. endif()
  423. endif()
  424. set(TESTS_ENVIRONMENT
  425. SDL_AUDIODRIVER=dummy
  426. SDL_VIDEODRIVER=dummy
  427. )
  428. foreach(TESTCASE ${SDL_TESTS_NONINTERACTIVE})
  429. add_test(
  430. NAME ${TESTCASE}
  431. COMMAND ${TESTCASE}
  432. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  433. )
  434. set_tests_properties(${TESTCASE}
  435. PROPERTIES
  436. ENVIRONMENT "${TESTS_ENVIRONMENT}"
  437. TIMEOUT 10
  438. )
  439. if(SDL_INSTALL_TESTS)
  440. set(exe ${TESTCASE})
  441. set(installedtestsdir "${CMAKE_INSTALL_FULL_LIBEXECDIR}/installed-tests/SDL2")
  442. configure_file(template.test.in "${exe}.test" @ONLY)
  443. install(
  444. FILES "${CMAKE_CURRENT_BINARY_DIR}/${exe}.test"
  445. DESTINATION ${CMAKE_INSTALL_DATADIR}/installed-tests/SDL2
  446. )
  447. endif()
  448. endforeach()
  449. set_tests_properties(testautomation PROPERTIES TIMEOUT 120)
  450. set_tests_properties(testthread PROPERTIES TIMEOUT 40)
  451. set_tests_properties(testtimer PROPERTIES TIMEOUT 60)
  452. if(TARGET testfilesystem_pre)
  453. set_property(TEST testfilesystem_pre PROPERTY TIMEOUT 60)
  454. set_property(TEST testfilesystem APPEND PROPERTY DEPENDS testfilesystem_pre)
  455. endif()
  456. if(SDL_INSTALL_TESTS)
  457. if(RISCOS)
  458. install(
  459. FILES ${SDL_TEST_EXECUTABLES_AIF}
  460. DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL2
  461. )
  462. else()
  463. install(
  464. TARGETS ${SDL_TEST_EXECUTABLES}
  465. DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL2
  466. )
  467. endif()
  468. if(MSVC)
  469. foreach(test ${SDL_TEST_EXECUTABLES})
  470. SDL_install_pdb(${test} "${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL2")
  471. endforeach()
  472. endif()
  473. install(
  474. FILES ${RESOURCE_FILES}
  475. DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL2
  476. )
  477. endif()