2022-06-15 19:40:53 -06:00
cmake_minimum_required ( VERSION 3.0 )
2022-11-21 21:28:58 -07:00
project ( SDL3_test )
2022-06-15 19:40:53 -06:00
2022-11-30 15:40:34 -07:00
enable_testing ( )
include ( "${CMAKE_CURRENT_LIST_DIR}/../cmake/sdlplatform.cmake" )
SDL_DetectCMakePlatform ( )
2022-10-05 15:55:59 -06:00
include ( CheckCCompilerFlag )
2022-11-26 02:41:46 -07:00
include ( CheckIncludeFile )
2022-11-01 04:04:45 -06:00
include ( CMakeParseArguments )
2022-10-05 15:55:59 -06:00
include ( CMakePushCheckState )
2022-11-30 15:40:34 -07:00
include ( GNUInstallDirs )
2022-10-05 15:55:59 -06:00
2022-11-30 15:40:34 -07:00
set ( SDL_TESTS_LINK_SHARED_DEFAULT ON )
2023-02-16 12:29:36 -07:00
if ( EMSCRIPTEN OR N3DS OR PS2 OR PSP OR RISCOS OR VITA )
2022-11-30 15:40:34 -07:00
set ( SDL_TESTS_LINK_SHARED_DEFAULT OFF )
2020-11-25 06:30:29 -07:00
endif ( )
2022-11-30 15:40:34 -07:00
option ( SDL_TESTS_LINK_SHARED "link tests to shared SDL library" ${ SDL_TESTS_LINK_SHARED_DEFAULT } )
2022-12-16 16:05:55 -07:00
set ( SDL_TESTS_TIMEOUT_MULTIPLIER "1" CACHE STRING "Timeout multiplier to account for really slow machines" )
2021-03-30 02:32:39 -06:00
2022-11-30 15:40:34 -07:00
if ( SDL_TESTS_LINK_SHARED )
2023-02-16 15:30:20 -07:00
set ( sdl_name_component SDL3-shared )
2022-01-03 10:41:21 -07:00
else ( )
2022-11-30 15:40:34 -07:00
set ( sdl_name_component SDL3-static )
2022-01-03 10:41:21 -07:00
endif ( )
2018-02-24 09:59:58 -07:00
2022-11-30 15:40:34 -07:00
if ( NOT TARGET SDL3:: ${ sdl_name_component } )
2023-02-16 12:15:59 -07:00
find_package ( SDL3 3.0.0 REQUIRED CONFIG COMPONENTS ${ sdl_name_component } SDL3_test )
2018-02-24 09:59:58 -07:00
endif ( )
2023-03-21 11:16:45 -06:00
if ( TARGET sdl-build-options )
set ( SDL3_TESTS_SUBPROJECT ON )
else ( )
set ( SDL3_TESTS_SUBPROJECT OFF )
endif ( )
2021-10-31 18:11:09 -06:00
# CMake incorrectly detects opengl32.lib being present on MSVC ARM64
if ( NOT MSVC OR NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64" )
2022-06-14 21:36:28 -06:00
# Prefer GLVND, if present
set ( OpenGL_GL_PREFERENCE GLVND )
2021-10-31 18:11:09 -06:00
find_package ( OpenGL )
endif ( )
2021-03-04 08:28:10 -07:00
2022-11-30 15:40:34 -07:00
set ( SDL_TEST_EXECUTABLES )
2023-03-01 15:41:22 -07:00
# FIXME: can be OBJECT library for CMake 3.16
add_library ( sdltests_utils STATIC
2022-11-30 15:40:34 -07:00
t e s t u t i l s . c
)
target_link_libraries ( sdltests_utils PRIVATE SDL3:: ${ sdl_name_component } )
file ( GLOB RESOURCE_FILES *.bmp *.wav *.hex moose.dat utf8.txt )
2023-02-24 21:06:44 -07:00
set ( RESOURCE_FILE_NAMES )
foreach ( RESOURCE_FILE ${ RESOURCE_FILES } )
get_filename_component ( res_file_name ${ RESOURCE_FILE } NAME )
list ( APPEND RESOURCE_FILE_NAMES "${res_file_name}" )
endforeach ( )
2022-11-30 15:40:34 -07:00
2023-03-17 12:23:56 -06:00
define_property ( TARGET PROPERTY SDL_NONINTERACTIVE BRIEF_DOCS "If true, target is a non-interactive test executable." FULL_DOCS "If true, target is a noninteractive test executable." )
define_property ( TARGET PROPERTY SDL_NONINTERACTIVE_ARGUMENTS BRIEF_DOCS "Argument(s) to run executable in non-interactive mode." FULL_DOCS "Argument(s) to run executable in non-interactive mode." )
define_property ( TARGET PROPERTY SDL_NONINTERACTIVE_TIMEOUT BRIEF_DOCS "Timeout for noninteractive executable." FULL_DOCS "Timeout for noninteractive executable." )
2022-11-30 15:40:34 -07:00
macro ( add_sdl_test_executable TARGET )
2023-05-24 17:15:12 -06:00
cmake_parse_arguments ( AST "NONINTERACTIVE;NEEDS_RESOURCES;TESTUTILS;NO_C90" "" "NONINTERACTIVE_TIMEOUT;NONINTERACTIVE_ARGS;SOURCES" ${ ARGN } )
2023-03-17 12:23:56 -06:00
if ( AST_UNPARSED_ARGUMENTS )
message ( FATAL_ERROR "Unknown argument(s): ${AST_UNPARSED_ARGUMENTS}" )
endif ( )
if ( NOT AST_SOURCES )
message ( FATAL_ERROR "add_sdl_test_executable needs at least one source" )
endif ( )
2022-11-30 15:40:34 -07:00
if ( AST_NEEDS_RESOURCES )
2023-03-17 12:23:56 -06:00
list ( APPEND AST_SOURCES ${ RESOURCE_FILES } )
2022-11-30 15:40:34 -07:00
endif ( )
2023-03-27 16:38:07 -06:00
if ( ANDROID )
add_library ( ${ TARGET } SHARED ${ AST_SOURCES } )
else ( )
add_executable ( ${ TARGET } ${ AST_SOURCES } )
endif ( )
2022-12-12 15:27:42 -07:00
target_link_libraries ( ${ TARGET } PRIVATE SDL3::SDL3_test SDL3:: ${ sdl_name_component } )
2023-03-01 15:41:22 -07:00
if ( AST_TESTUTILS )
target_link_libraries ( ${ TARGET } PRIVATE sdltests_utils )
endif ( )
2023-05-24 17:15:12 -06:00
if ( NOT AST_NO_C90 AND NOT SDL_CMAKE_PLATFORM MATCHES "^(n3ds|ps2|psp)$" )
set_property ( TARGET ${ TARGET } PROPERTY C_STANDARD 90 )
set_property ( TARGET ${ TARGET } PROPERTY C_EXTENSIONS FALSE )
endif ( )
2022-11-30 15:40:34 -07:00
list ( APPEND SDL_TEST_EXECUTABLES ${ TARGET } )
if ( AST_NONINTERACTIVE )
2023-03-17 12:23:56 -06:00
set_property ( TARGET ${ TARGET } PROPERTY SDL_NONINTERACTIVE 1 )
endif ( )
if ( AST_NONINTERACTIVE_ARGS )
set_property ( TARGET ${ TARGET } PROPERTY SDL_NONINTERACTIVE_ARGUMENTS "${AST_NONINTERACTIVE_ARGS}" )
endif ( )
if ( AST_NONINTERACTIVE_TIMEOUT )
set_property ( TARGET ${ TARGET } PROPERTY SDL_NONINTERACTIVE_TIMEOUT "${AST_NONINTERACTIVE_TIMEOUT}" )
2022-11-30 15:40:34 -07:00
endif ( )
if ( AST_NEEDS_RESOURCES )
if ( PSP OR PS2 )
add_custom_command ( TARGET ${ TARGET } POST_BUILD
C O M M A N D $ { C M A K E _ C O M M A N D } A R G S - E m a k e _ d i r e c t o r y $ < T A R G E T _ F I L E _ D I R : $ { T A R G E T } > / s d l - $ { T A R G E T }
C O M M A N D $ { C M A K E _ C O M M A N D } A R G S - E c o p y _ i f _ d i f f e r e n t $ { R E S O U R C E _ F I L E S } $ < T A R G E T _ F I L E _ D I R : $ { T A R G E T } > / s d l - $ { T A R G E T } )
else ( )
add_custom_command ( TARGET ${ TARGET } POST_BUILD
C O M M A N D $ { C M A K E _ C O M M A N D } A R G S - E c o p y _ i f _ d i f f e r e n t $ { R E S O U R C E _ F I L E S } $ < T A R G E T _ F I L E _ D I R : $ { T A R G E T } > )
endif ( )
if ( APPLE )
# Make sure resource files get installed into macOS/iOS .app bundles.
set_target_properties ( ${ TARGET } PROPERTIES RESOURCE "${RESOURCE_FILES}" )
endif ( )
2023-02-24 21:06:44 -07:00
set_property ( TARGET ${ TARGET } APPEND PROPERTY ADDITIONAL_CLEAN_FILES "$<TARGET_FILE_DIR:${TARGET}>/$<JOIN:${RESOURCE_FILE_NAMES},$<SEMICOLON>$<TARGET_FILE_DIR:${TARGET}>/>" )
2022-11-30 15:40:34 -07:00
endif ( )
if ( WINDOWS )
# CET support was added in VS 16.7
if ( MSVC_VERSION GREATER 1926 AND CMAKE_GENERATOR_PLATFORM MATCHES "Win32|x64" )
set_property ( TARGET ${ TARGET } APPEND_STRING PROPERTY LINK_FLAGS " -CETCOMPAT" )
endif ( )
elseif ( PSP )
target_link_libraries ( ${ TARGET } PRIVATE GL )
endif ( )
if ( OPENGL_FOUND )
target_compile_definitions ( ${ TARGET } PRIVATE HAVE_OPENGL )
endif ( )
2023-01-07 08:15:28 -07:00
if ( TARGET sdl-global-options )
target_link_libraries ( ${ TARGET } PRIVATE $< BUILD_INTERFACE:sdl-global-options > )
endif ( )
2023-03-21 11:16:45 -06:00
if ( SDL3_TESTS_SUBPROJECT )
# FIXME: only add "${SDL3_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>" + include paths of external dependencies
target_include_directories ( ${ TARGET } PRIVATE "$<TARGET_PROPERTY:SDL3::${sdl_name_component},INCLUDE_DIRECTORIES>" )
else ( )
target_include_directories ( ${ TARGET } PRIVATE "../include" )
endif ( )
2022-11-30 15:40:34 -07:00
endmacro ( )
2022-11-26 02:41:46 -07:00
check_include_file ( signal.h HAVE_SIGNAL_H )
2022-11-30 15:40:34 -07:00
if ( HAVE_SIGNAL_H )
2022-11-26 02:41:46 -07:00
add_definitions ( -DHAVE_SIGNAL_H )
endif ( )
check_include_file ( libudev.h HAVE_LIBUDEV_H )
2022-11-30 15:40:34 -07:00
if ( HAVE_LIBUDEV_H )
2022-11-26 02:41:46 -07:00
add_definitions ( -DHAVE_LIBUDEV_H )
2021-03-04 08:28:10 -07:00
endif ( )
2023-03-17 12:23:56 -06:00
add_sdl_test_executable ( checkkeys SOURCES checkkeys.c )
add_sdl_test_executable ( checkkeysthreads SOURCES checkkeysthreads.c )
add_sdl_test_executable ( loopwave NEEDS_RESOURCES TESTUTILS SOURCES loopwave.c )
add_sdl_test_executable ( loopwavequeue NEEDS_RESOURCES TESTUTILS SOURCES loopwavequeue.c )
add_sdl_test_executable ( testsurround SOURCES testsurround.c )
add_sdl_test_executable ( testresample NEEDS_RESOURCES SOURCES testresample.c )
add_sdl_test_executable ( testaudioinfo SOURCES testaudioinfo.c )
2023-04-01 20:29:30 -06:00
add_sdl_test_executable ( testaudiostreamdynamicresample SOURCES testaudiostreamdynamicresample.c )
2018-02-24 09:59:58 -07:00
file ( GLOB TESTAUTOMATION_SOURCE_FILES testautomation*.c )
2023-05-24 17:15:12 -06:00
add_sdl_test_executable ( testautomation NEEDS_RESOURCES NO_C90 SOURCES ${ TESTAUTOMATION_SOURCE_FILES } )
2023-03-17 12:23:56 -06:00
add_sdl_test_executable ( testmultiaudio NEEDS_RESOURCES TESTUTILS SOURCES testmultiaudio.c )
add_sdl_test_executable ( testaudiohotplug NEEDS_RESOURCES TESTUTILS SOURCES testaudiohotplug.c )
add_sdl_test_executable ( testaudiocapture SOURCES testaudiocapture.c )
add_sdl_test_executable ( testatomic NONINTERACTIVE SOURCES testatomic.c )
add_sdl_test_executable ( testintersections SOURCES testintersections.c )
add_sdl_test_executable ( testrelative SOURCES testrelative.c )
add_sdl_test_executable ( testhittesting SOURCES testhittesting.c )
add_sdl_test_executable ( testdraw SOURCES testdraw.c )
add_sdl_test_executable ( testdrawchessboard SOURCES testdrawchessboard.c )
add_sdl_test_executable ( testdropfile SOURCES testdropfile.c )
add_sdl_test_executable ( testerror NONINTERACTIVE SOURCES testerror.c )
2022-05-04 06:15:12 -06:00
2023-03-27 06:11:23 -06:00
if ( SDL3_TESTS_SUBPROJECT )
2023-03-16 17:25:39 -06:00
set ( build_options_dependent_tests )
2023-03-17 12:23:56 -06:00
add_sdl_test_executable ( testevdev NONINTERACTIVE SOURCES testevdev.c )
2023-03-16 17:25:39 -06:00
list ( APPEND build_options_dependent_tests testevdev )
if ( APPLE )
add_sdl_test_executable ( testnative NEEDS_RESOURCES TESTUTILS
2023-03-17 12:23:56 -06:00
S O U R C E S
t e s t n a t i v e . c
t e s t n a t i v e c o c o a . m
t e s t n a t i v e x 1 1 . c
2023-03-16 17:25:39 -06:00
)
cmake_push_check_state ( )
check_c_compiler_flag ( -Wno-error=deprecated-declarations HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS )
cmake_pop_check_state ( )
2023-03-27 19:22:29 -06:00
target_link_libraries ( testnative PRIVATE "-Wl,-framework,Cocoa" )
2023-03-16 17:25:39 -06:00
if ( HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS )
set_property ( SOURCE "testnativecocoa.m" APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-error=deprecated-declarations" )
endif ( )
list ( APPEND build_options_dependent_tests testnative )
elseif ( WINDOWS )
2023-03-27 06:11:23 -06:00
add_sdl_test_executable ( testnative NEEDS_RESOURCES TESTUTILS SOURCES testnative.c testnativew32.c )
2023-03-16 17:25:39 -06:00
list ( APPEND build_options_dependent_tests testnative )
elseif ( HAVE_X11 )
2023-03-17 12:23:56 -06:00
add_sdl_test_executable ( testnative NEEDS_RESOURCES TESTUTILS SOURCES testnative.c testnativex11.c )
2023-03-16 17:25:39 -06:00
target_link_libraries ( testnative PRIVATE X11 )
list ( APPEND build_options_dependent_tests testnative )
endif ( )
foreach ( t ${ build_options_dependent_tests } )
target_include_directories ( ${ t } BEFORE PRIVATE $< TARGET_PROPERTY:sdl-build-options,INTERFACE_INCLUDE_DIRECTORIES > )
target_include_directories ( ${ t } BEFORE PRIVATE ${ SDL3_SOURCE_DIR } /src )
endforeach ( )
2022-05-04 06:15:12 -06:00
endif ( )
2023-03-17 12:23:56 -06:00
add_sdl_test_executable ( testfile NONINTERACTIVE SOURCES testfile.c )
2023-07-11 15:21:35 -06:00
add_sdl_test_executable ( testcontroller TESTUTILS SOURCES testcontroller.c gamepadutils.c )
2023-03-17 12:23:56 -06:00
add_sdl_test_executable ( testgeometry TESTUTILS SOURCES testgeometry.c )
add_sdl_test_executable ( testgl SOURCES testgl.c )
add_sdl_test_executable ( testgles SOURCES testgles.c )
2023-03-27 16:38:07 -06:00
if ( ANDROID )
target_link_libraries ( testgles PRIVATE GLESv1_CM )
endif ( )
2023-03-17 12:23:56 -06:00
add_sdl_test_executable ( testgles2 SOURCES testgles2.c )
add_sdl_test_executable ( testgles2_sdf TESTUTILS SOURCES testgles2_sdf.c )
add_sdl_test_executable ( testhaptic SOURCES testhaptic.c )
add_sdl_test_executable ( testhotplug SOURCES testhotplug.c )
add_sdl_test_executable ( testrumble SOURCES testrumble.c )
add_sdl_test_executable ( testthread NONINTERACTIVE NONINTERACTIVE_TIMEOUT 40 SOURCES testthread.c )
add_sdl_test_executable ( testiconv NEEDS_RESOURCES TESTUTILS SOURCES testiconv.c )
add_sdl_test_executable ( testime NEEDS_RESOURCES TESTUTILS SOURCES testime.c )
add_sdl_test_executable ( testkeys SOURCES testkeys.c )
add_sdl_test_executable ( testloadso SOURCES testloadso.c )
add_sdl_test_executable ( testlocale NONINTERACTIVE SOURCES testlocale.c )
2023-05-24 17:15:12 -06:00
add_sdl_test_executable ( testlock NO_C90 SOURCES testlock.c )
2023-04-23 23:07:59 -06:00
add_sdl_test_executable ( testrwlock SOURCES testrwlock.c )
2023-03-17 12:23:56 -06:00
add_sdl_test_executable ( testmouse SOURCES testmouse.c )
add_sdl_test_executable ( testoverlay NEEDS_RESOURCES TESTUTILS SOURCES testoverlay.c )
add_sdl_test_executable ( testplatform NONINTERACTIVE SOURCES testplatform.c )
add_sdl_test_executable ( testpower NONINTERACTIVE SOURCES testpower.c )
add_sdl_test_executable ( testfilesystem NONINTERACTIVE SOURCES testfilesystem.c )
add_sdl_test_executable ( testrendertarget NEEDS_RESOURCES TESTUTILS SOURCES testrendertarget.c )
add_sdl_test_executable ( testscale NEEDS_RESOURCES TESTUTILS SOURCES testscale.c )
add_sdl_test_executable ( testsem NONINTERACTIVE NONINTERACTIVE_ARGS 10 NONINTERACTIVE_TIMEOUT 30 SOURCES testsem.c )
add_sdl_test_executable ( testsensor SOURCES testsensor.c )
add_sdl_test_executable ( testshader NEEDS_RESOURCES TESTUTILS SOURCES testshader.c )
add_sdl_test_executable ( testshape NEEDS_RESOURCES SOURCES testshape.c )
add_sdl_test_executable ( testsprite NEEDS_RESOURCES TESTUTILS SOURCES testsprite.c )
add_sdl_test_executable ( testspriteminimal NEEDS_RESOURCES TESTUTILS SOURCES testspriteminimal.c )
add_sdl_test_executable ( teststreaming NEEDS_RESOURCES TESTUTILS SOURCES teststreaming.c )
add_sdl_test_executable ( testtimer NONINTERACTIVE NONINTERACTIVE_TIMEOUT 60 SOURCES testtimer.c )
add_sdl_test_executable ( testurl SOURCES testurl.c )
add_sdl_test_executable ( testver NONINTERACTIVE SOURCES testver.c )
add_sdl_test_executable ( testviewport NEEDS_RESOURCES TESTUTILS SOURCES testviewport.c )
add_sdl_test_executable ( testwm SOURCES testwm.c )
add_sdl_test_executable ( testyuv NONINTERACTIVE NONINTERACTIVE_ARGS "--automated" NEEDS_RESOURCES TESTUTILS SOURCES testyuv.c testyuv_cvt.c )
add_sdl_test_executable ( torturethread NONINTERACTIVE NONINTERACTIVE_TIMEOUT 30 SOURCES torturethread.c )
add_sdl_test_executable ( testrendercopyex NEEDS_RESOURCES TESTUTILS SOURCES testrendercopyex.c )
add_sdl_test_executable ( testmessage SOURCES testmessage.c )
add_sdl_test_executable ( testdisplayinfo SOURCES testdisplayinfo.c )
add_sdl_test_executable ( testqsort NONINTERACTIVE SOURCES testqsort.c )
add_sdl_test_executable ( testbounds NONINTERACTIVE SOURCES testbounds.c )
add_sdl_test_executable ( testcustomcursor SOURCES testcustomcursor.c )
2023-05-24 17:15:12 -06:00
add_sdl_test_executable ( testvulkan NO_C90 SOURCES testvulkan.c )
2023-03-17 12:23:56 -06:00
add_sdl_test_executable ( testoffscreen SOURCES testoffscreen.c )
add_sdl_test_executable ( testpopup SOURCES testpopup.c )
2018-02-24 09:59:58 -07:00
2022-10-05 16:31:00 -06:00
check_c_compiler_flag ( -Wformat-overflow HAVE_WFORMAT_OVERFLOW )
if ( HAVE_WFORMAT_OVERFLOW )
target_compile_definitions ( testautomation PRIVATE HAVE_WFORMAT_OVERFLOW )
endif ( )
check_c_compiler_flag ( -Wformat HAVE_WFORMAT )
if ( HAVE_WFORMAT )
target_compile_definitions ( testautomation PRIVATE HAVE_WFORMAT )
endif ( )
2023-01-07 14:25:09 -07:00
cmake_push_check_state ( )
if ( HAVE_WFORMAT )
# Some compilers ignore -Wformat-extra-args without -Wformat
set ( CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wformat" )
endif ( )
2022-10-05 16:31:00 -06:00
check_c_compiler_flag ( -Wformat-extra-args HAVE_WFORMAT_EXTRA_ARGS )
2023-01-07 14:25:09 -07:00
cmake_pop_check_state ( )
2022-10-05 16:31:00 -06:00
if ( HAVE_WFORMAT_EXTRA_ARGS )
target_compile_definitions ( testautomation PRIVATE HAVE_WFORMAT_EXTRA_ARGS )
endif ( )
2022-05-18 10:04:12 -06:00
if ( SDL_DUMMYAUDIO )
2023-03-17 12:23:56 -06:00
set_property ( TARGET testaudioinfo PROPERTY SDL_NONINTERACTIVE 1 )
set_property ( TARGET testsurround PROPERTY SDL_NONINTERACTIVE 1 )
2022-05-18 10:04:12 -06:00
endif ( )
2022-04-12 06:33:58 -06:00
2022-05-18 10:04:12 -06:00
if ( SDL_DUMMYVIDEO )
2023-03-17 12:23:56 -06:00
set_property ( TARGET testkeys PROPERTY SDL_NONINTERACTIVE 1 )
set_property ( TARGET testbounds PROPERTY SDL_NONINTERACTIVE 1 )
set_property ( TARGET testdisplayinfo PROPERTY SDL_NONINTERACTIVE 1 )
2022-05-18 10:04:12 -06:00
endif ( )
2022-04-12 06:33:58 -06:00
2021-03-04 08:28:10 -07:00
if ( OPENGL_FOUND )
2022-11-01 04:33:39 -06:00
if ( TARGET OpenGL::GL )
2022-11-30 15:40:34 -07:00
target_link_libraries ( testshader PRIVATE OpenGL::GL )
2023-01-03 11:28:18 -07:00
target_link_libraries ( testgl PRIVATE OpenGL::GL )
2022-11-01 04:33:39 -06:00
else ( )
2022-11-01 06:40:19 -06:00
if ( EMSCRIPTEN AND OPENGL_gl_LIBRARY STREQUAL "nul" )
set ( OPENGL_gl_LIBRARY GL )
endif ( )
2022-11-01 04:33:39 -06:00
# emscripten's FindOpenGL.cmake does not create OpenGL::GL
2022-11-30 15:40:34 -07:00
target_link_libraries ( testshader PRIVATE ${ OPENGL_gl_LIBRARY } )
2023-01-03 11:28:18 -07:00
target_link_libraries ( testgl PRIVATE ${ OPENGL_gl_LIBRARY } )
2022-11-01 04:33:39 -06:00
endif ( )
2021-03-04 08:28:10 -07:00
endif ( )
2022-11-01 06:09:52 -06:00
if ( EMSCRIPTEN )
2022-11-30 15:40:34 -07:00
set_property ( TARGET testshader APPEND_STRING PROPERTY LINK_FLAGS " -sLEGACY_GL_EMULATION" )
2022-11-01 06:09:52 -06:00
endif ( )
2021-03-04 08:28:10 -07:00
2022-01-05 03:33:51 -07:00
if ( PSP )
# Build EBOOT files if building for PSP
2022-11-30 15:40:34 -07:00
foreach ( APP ${ SDL_TEST_EXECUTABLES } )
2022-01-03 10:41:21 -07:00
create_pbp_file (
T A R G E T $ { A P P }
T I T L E S D L - $ { A P P }
I C O N _ P A T H N U L L
B A C K G R O U N D _ P A T H N U L L
P R E V I E W _ P A T H N U L L
)
add_custom_command (
T A R G E T $ { A P P } P O S T _ B U I L D
C O M M A N D $ { C M A K E _ C O M M A N D } - E m a k e _ d i r e c t o r y
2022-01-03 10:56:02 -07:00
$ < T A R G E T _ F I L E _ D I R : $ { A R G _ T A R G E T } > / s d l - $ { A P P }
2022-01-03 10:41:21 -07:00
)
add_custom_command (
T A R G E T $ { A P P } P O S T _ B U I L D
C O M M A N D $ { C M A K E _ C O M M A N D } - E r e n a m e
$ < T A R G E T _ F I L E _ D I R : $ { A R G _ T A R G E T } > / E B O O T . P B P
2022-01-03 10:56:02 -07:00
$ < T A R G E T _ F I L E _ D I R : $ { A R G _ T A R G E T } > / s d l - $ { A P P } / E B O O T . P B P
2022-01-03 10:41:21 -07:00
)
2022-11-30 15:40:34 -07:00
if ( BUILD_PRX )
2022-01-03 10:56:02 -07:00
add_custom_command (
T A R G E T $ { A P P } P O S T _ B U I L D
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y
$ < T A R G E T _ F I L E _ D I R : $ { A R G _ T A R G E T } > / $ { A P P }
$ < T A R G E T _ F I L E _ D I R : $ { A R G _ T A R G E T } > / s d l - $ { A P P } / $ { A P P }
)
add_custom_command (
T A R G E T $ { A P P } P O S T _ B U I L D
C O M M A N D $ { C M A K E _ C O M M A N D } - E r e n a m e
$ < T A R G E T _ F I L E _ D I R : $ { A R G _ T A R G E T } > / $ { A P P } . p r x
$ < T A R G E T _ F I L E _ D I R : $ { A R G _ T A R G E T } > / s d l - $ { A P P } / $ { A P P } . p r x
)
endif ( )
2022-01-03 10:41:21 -07:00
add_custom_command (
T A R G E T $ { A P P } P O S T _ B U I L D
C O M M A N D $ { C M A K E _ C O M M A N D } - E r e m o v e
$ < T A R G E T _ F I L E _ D I R : $ { A R G _ T A R G E T } > / P A R A M . S F O
)
endforeach ( )
endif ( )
2021-03-30 02:32:39 -06:00
if ( N3DS )
set ( ROMFS_DIR "${CMAKE_CURRENT_BINARY_DIR}/romfs" )
file ( COPY ${ RESOURCE_FILES } DESTINATION "${ROMFS_DIR}" )
2022-11-30 15:40:34 -07:00
foreach ( APP ${ SDL_TEST_EXECUTABLES } )
2021-03-30 02:32:39 -06:00
get_target_property ( TARGET_BINARY_DIR ${ APP } BINARY_DIR )
set ( SMDH_FILE "${TARGET_BINARY_DIR}/${APP}.smdh" )
2023-01-07 08:15:28 -07:00
ctr_generate_smdh ( "${SMDH_FILE}"
2021-03-30 02:32:39 -06:00
N A M E " S D L - $ { A P P } "
2022-11-21 21:28:58 -07:00
D E S C R I P T I O N " S D L 3 T e s t s u i t e "
A U T H O R " S D L 3 C o n t r i b u t o r s "
2021-03-30 02:32:39 -06:00
I C O N " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / n 3 d s / l o g o 4 8 x 4 8 . p n g "
)
ctr_create_3dsx (
$ { A P P }
R O M F S " $ { R O M F S _ D I R } "
S M D H " $ { S M D H _ F I L E } "
)
endforeach ( )
endif ( )
2022-05-19 16:11:22 -06:00
if ( RISCOS )
2022-11-01 04:04:45 -06:00
set ( SDL_TEST_EXECUTABLES_AIF )
2022-11-30 15:40:34 -07:00
foreach ( APP ${ SDL_TEST_EXECUTABLES } )
set_property ( TARGET ${ APP } APPEND_STRING PROPERTY LINK_FLAGS " -static" )
2022-05-19 16:11:22 -06:00
add_custom_command (
O U T P U T $ { A P P } , f f 8
C O M M A N D e l f 2 a i f $ { A P P } $ { A P P } , f f 8
D E P E N D S $ { A P P }
)
add_custom_target ( ${ APP } -aif ALL DEPENDS ${ APP } ,ff8 )
2022-11-01 04:04:45 -06:00
list ( APPEND SDL_TEST_EXECUTABLES_AIF ${ CMAKE_CURRENT_BINARY_DIR } / ${ APP } ,ff8 )
2022-05-19 16:11:22 -06:00
endforeach ( )
endif ( )
CMake: iOS support added
When using a recent version of CMake (3.14+), this should make it possible to:
- build SDL for iOS, both static and dynamic
- build SDL test apps (as iOS .app bundles)
- generate a working SDL_config.h for iOS (using SDL_config.h.cmake as a basis)
To use, set the following CMake variables when running CMake's configuration stage:
- CMAKE_SYSTEM_NAME=iOS
- CMAKE_OSX_SYSROOT=<SDK> (examples: iphoneos, iphonesimulator, iphoneos12.4, /full/path/to/iPhoneOS.sdk, etc.)
- CMAKE_OSX_ARCHITECTURES=<semicolon-separated list of CPU architectures> (example: "arm64;armv7s")
Examples:
- for Simulator, using the latest, installed SDK:
cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
- for Device, using the latest, installed SDK, 64-bit only
cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=arm64
- for Device, using the latest, installed SDK, mixed 32/64 bit
cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES="arm64;armv7s"
- for Device, using a specific SDK revision (iOS 12.4, in this example):
cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos12.4 -DCMAKE_OSX_ARCHITECTURES=arm64
- for Simulator, using the latest, installed SDK, and building SDL test apps (as .app bundles):
cmake path/to/SDL -DSDL_TEST=1 -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
2019-08-27 09:07:43 -06:00
# Set Apple App ID / Bundle ID. This is needed to launch apps on some Apple
# platforms (iOS, for example).
if ( APPLE )
2022-11-30 15:40:34 -07:00
if ( CMAKE_VERSION VERSION_LESS "3.7.0" )
CMake: iOS support added
When using a recent version of CMake (3.14+), this should make it possible to:
- build SDL for iOS, both static and dynamic
- build SDL test apps (as iOS .app bundles)
- generate a working SDL_config.h for iOS (using SDL_config.h.cmake as a basis)
To use, set the following CMake variables when running CMake's configuration stage:
- CMAKE_SYSTEM_NAME=iOS
- CMAKE_OSX_SYSROOT=<SDK> (examples: iphoneos, iphonesimulator, iphoneos12.4, /full/path/to/iPhoneOS.sdk, etc.)
- CMAKE_OSX_ARCHITECTURES=<semicolon-separated list of CPU architectures> (example: "arm64;armv7s")
Examples:
- for Simulator, using the latest, installed SDK:
cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
- for Device, using the latest, installed SDK, 64-bit only
cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=arm64
- for Device, using the latest, installed SDK, mixed 32/64 bit
cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES="arm64;armv7s"
- for Device, using a specific SDK revision (iOS 12.4, in this example):
cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos12.4 -DCMAKE_OSX_ARCHITECTURES=arm64
- for Simulator, using the latest, installed SDK, and building SDL test apps (as .app bundles):
cmake path/to/SDL -DSDL_TEST=1 -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
2019-08-27 09:07:43 -06:00
# CMake's 'BUILDSYSTEM_TARGETS' property is only available in
# CMake 3.7 and above.
message ( WARNING "Unable to set Bundle ID for Apple .app builds due to old CMake (pre 3.7)." )
else ( )
2022-11-30 15:40:34 -07:00
foreach ( CURRENT_TARGET ${ SDL_TEST_EXECUTABLES } )
set_target_properties ( "${CURRENT_TARGET}" PROPERTIES
M A C O S X _ B U N D L E _ G U I _ I D E N T I F I E R " o r g . l i b s d l . $ { C U R R E N T _ T A R G E T } "
2023-01-09 06:11:54 -07:00
M A C O S X _ B U N D L E _ B U N D L E _ V E R S I O N " $ { S D L 3 _ V E R S I O N } "
M A C O S X _ B U N D L E _ S H O R T _ V E R S I O N _ S T R I N G " $ { S D L 3 _ V E R S I O N } "
2022-11-30 15:40:34 -07:00
)
CMake: iOS support added
When using a recent version of CMake (3.14+), this should make it possible to:
- build SDL for iOS, both static and dynamic
- build SDL test apps (as iOS .app bundles)
- generate a working SDL_config.h for iOS (using SDL_config.h.cmake as a basis)
To use, set the following CMake variables when running CMake's configuration stage:
- CMAKE_SYSTEM_NAME=iOS
- CMAKE_OSX_SYSROOT=<SDK> (examples: iphoneos, iphonesimulator, iphoneos12.4, /full/path/to/iPhoneOS.sdk, etc.)
- CMAKE_OSX_ARCHITECTURES=<semicolon-separated list of CPU architectures> (example: "arm64;armv7s")
Examples:
- for Simulator, using the latest, installed SDK:
cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
- for Device, using the latest, installed SDK, 64-bit only
cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=arm64
- for Device, using the latest, installed SDK, mixed 32/64 bit
cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES="arm64;armv7s"
- for Device, using a specific SDK revision (iOS 12.4, in this example):
cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos12.4 -DCMAKE_OSX_ARCHITECTURES=arm64
- for Simulator, using the latest, installed SDK, and building SDL test apps (as .app bundles):
cmake path/to/SDL -DSDL_TEST=1 -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
2019-08-27 09:07:43 -06:00
endforeach ( )
endif ( )
endif ( )
2022-04-12 06:33:58 -06:00
set ( TESTS_ENVIRONMENT
2022-12-08 02:40:01 -07:00
S D L _ A U D I O _ D R I V E R = d u m m y
S D L _ V I D E O _ D R I V E R = d u m m y
2023-01-20 17:57:10 -07:00
P A T H = $ < T A R G E T _ F I L E _ D I R : S D L 3 : : $ { s d l _ n a m e _ c o m p o n e n t } >
2022-04-12 06:33:58 -06:00
)
2023-03-17 12:23:56 -06:00
foreach ( TEST ${ SDL_TEST_EXECUTABLES } )
get_property ( noninteractive TARGET ${ TEST } PROPERTY SDL_NONINTERACTIVE )
if ( noninteractive )
set ( command ${ TEST } )
get_property ( noninteractive_arguments TARGET ${ TEST } PROPERTY SDL_NONINTERACTIVE_ARGUMENTS )
if ( noninteractive_arguments )
list ( APPEND command ${ noninteractive_arguments } )
endif ( )
add_test (
N A M E $ { T E S T }
C O M M A N D $ { c o m m a n d }
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
2022-05-04 06:53:15 -06:00
)
2023-03-17 12:23:56 -06:00
set_tests_properties ( ${ TEST } PROPERTIES ENVIRONMENT "${TESTS_ENVIRONMENT}" )
get_property ( noninteractive_timeout TARGET ${ TEST } PROPERTY SDL_NONINTERACTIVE_TIMEOUT )
if ( NOT noninteractive_timeout )
set ( noninteractive_timeout 10 )
endif ( )
math ( EXPR noninteractive_timeout "${noninteractive_timeout}*${SDL_TESTS_TIMEOUT_MULTIPLIER}" )
set_tests_properties ( ${ TEST } PROPERTIES TIMEOUT "${noninteractive_timeout}" )
if ( SDL_INSTALL_TESTS )
set ( exe ${ TEST } )
set ( installedtestsdir "${CMAKE_INSTALL_FULL_LIBEXECDIR}/installed-tests/SDL3" )
configure_file ( template.test.in "${exe}.test" @ONLY )
install (
F I L E S " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { e x e } . t e s t "
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ D A T A D I R } / i n s t a l l e d - t e s t s / S D L 3
)
endif ( )
2022-05-04 06:53:15 -06:00
endif ( )
2022-04-12 06:33:58 -06:00
endforeach ( )
2020-11-25 06:30:29 -07:00
if ( SDL_INSTALL_TESTS )
2022-05-19 16:11:22 -06:00
if ( RISCOS )
install (
2022-11-01 04:04:45 -06:00
F I L E S $ { S D L _ T E S T _ E X E C U T A B L E S _ A I F }
2022-11-21 21:28:58 -07:00
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B E X E C D I R } / i n s t a l l e d - t e s t s / S D L 3
2022-05-19 16:11:22 -06:00
)
else ( )
install (
2022-11-01 04:04:45 -06:00
T A R G E T S $ { S D L _ T E S T _ E X E C U T A B L E S }
2022-11-21 21:28:58 -07:00
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B E X E C D I R } / i n s t a l l e d - t e s t s / S D L 3
2022-05-19 16:11:22 -06:00
)
endif ( )
2020-11-25 06:30:29 -07:00
install (
F I L E S $ { R E S O U R C E _ F I L E S }
2022-11-21 21:28:58 -07:00
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B E X E C D I R } / i n s t a l l e d - t e s t s / S D L 3
2020-11-25 06:30:29 -07:00
)
endif ( )