2023-07-16 11:38:17 -06:00
#
# CMake script for building the SDL tests
#
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 ( )
2023-02-27 20:20:30 -07:00
set ( HAVE_TESTS_LINK_SHARED "${SDL_TESTS_LINK_SHARED}" PARENT_SCOPE )
2023-03-21 11:16:45 -06:00
2021-10-31 18:11:09 -06:00
# CMake incorrectly detects opengl32.lib being present on MSVC ARM64
2023-07-16 11:38:17 -06:00
if ( NOT ( MSVC AND SDL_CPU_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
2023-04-19 08:28:39 -06:00
if ( WINDOWS_STORE )
cmake_minimum_required ( VERSION 3.19 )
# CMP0112: Target file component generator expressions do not add target dependencies.
cmake_policy ( SET CMP0112 NEW )
endif ( )
2022-11-30 15:40:34 -07:00
set ( SDL_TEST_EXECUTABLES )
2023-02-27 20:20:30 -07:00
add_library ( sdltests_utils OBJECT
2022-11-30 15:40:34 -07:00
t e s t u t i l s . c
)
2023-02-27 20:20:30 -07:00
target_link_libraries ( sdltests_utils PRIVATE SDL3::Headers )
2022-11-30 15:40:34 -07:00
file ( GLOB RESOURCE_FILES *.bmp *.wav *.hex moose.dat utf8.txt )
2023-02-24 21:06:44 -07:00
set ( RESOURCE_FILE_NAMES )
2023-06-03 07:22:39 -06:00
foreach ( RESOURCE_FILE IN LISTS RESOURCE_FILES )
2023-02-24 21:06:44 -07:00
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." )
2023-04-19 08:28:39 -06:00
if ( WINDOWS_STORE )
add_library ( sdl_test_main_uwp OBJECT main.cpp )
target_link_libraries ( sdl_test_main_uwp PRIVATE SDL3::Headers )
target_compile_options ( sdl_test_main_uwp PRIVATE "/ZW" )
set_source_files_properties ( ${ RESOURCE_FILES } PROPERTIES VS_DEPLOYENT_LOCATION "Assets" )
endif ( )
2022-11-30 15:40:34 -07:00
macro ( add_sdl_test_executable TARGET )
2023-07-16 11:38:17 -06:00
cmake_parse_arguments ( AST "BUILD_DEPENDENT;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 ( )
2023-02-27 20:20:30 -07:00
if ( AST_TESTUTILS )
list ( APPEND AST_SOURCES $< TARGET_OBJECTS:sdltests_utils > )
endif ( )
2023-04-19 08:28:39 -06:00
set ( EXTRA_SOURCES "" )
if ( WINDOWS_STORE )
set ( uwp_bindir "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.dir" )
if ( NOT IS_DIRECTORY "${uwp_bindir}" )
execute_process ( COMMAND "${CMAKE_COMMAND}" -E make_directory "${uwp_bindir}" )
endif ( )
string ( REGEX REPLACE "[_]" "" SAFE_TARGET "${TARGET}" )
file ( GENERATE OUTPUT "${uwp_bindir}/${TARGET}.appxmanifest"
I N P U T " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / u w p / P a c k a g e . a p p x m a n i f e s t . i n "
T A R G E T " $ { T A R G E T } "
)
set_property ( SOURCE "${uwp_bindir}/${TARGET}.appxmanifest" PROPERTY VS_DEPLOYMENT_CONTENT 1 )
list ( APPEND EXTRA_SOURCES
" $ < T A R G E T _ O B J E C T S : s d l _ t e s t _ m a i n _ u w p > "
" $ { u w p _ b i n d i r } / $ { T A R G E T } . a p p x m a n i f e s t "
" u w p / l o g o - 5 0 x 5 0 . p n g "
" u w p / s q u a r e - 4 4 x 4 4 . p n g "
" u w p / s q u a r e - 1 5 0 x 1 5 0 . p n g "
" u w p / s p l a s h - 6 2 0 x 3 0 0 . p n g "
)
endif ( )
2022-11-30 15:40:34 -07:00
if ( AST_NEEDS_RESOURCES )
2023-04-19 08:28:39 -06:00
list ( APPEND EXTRA_SOURCES ${ RESOURCE_FILES } )
2022-11-30 15:40:34 -07:00
endif ( )
2023-03-27 16:38:07 -06:00
if ( ANDROID )
2023-04-19 08:28:39 -06:00
add_library ( ${ TARGET } SHARED ${ AST_SOURCES } ${ EXTRA_SOURCES } )
2023-03-27 16:38:07 -06:00
else ( )
2023-04-19 08:28:39 -06:00
add_executable ( ${ TARGET } ${ AST_SOURCES } ${ EXTRA_SOURCES } )
2023-03-27 16:38:07 -06:00
endif ( )
2023-02-27 20:20:30 -07:00
SDL_AddCommonCompilerFlags ( ${ TARGET } )
2022-12-12 15:27:42 -07:00
target_link_libraries ( ${ TARGET } PRIVATE SDL3::SDL3_test SDL3:: ${ sdl_name_component } )
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 } )
2023-04-19 08:28:39 -06:00
elseif ( WINDOWS_STORE )
# MSVC does build the dependent targets (or POST_BUILD commands) when building an application
# after starting to debug. By copying the resources in a custom target, the files can be copied afterwards.
# FIXME: find out proper way to add assets to UWP package
cmake_minimum_required ( VERSION 3.19 )
add_custom_target ( zzz-resources-copy- ${ TARGET }
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 " $ < T A R G E T _ F I L E _ D I R : $ { T A R G E T } > / A p p X "
C O M M A N D $ { C M A K E _ C O M M A N D } - 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 } > / A p p X "
)
add_dependencies ( ${ TARGET } zzz-resources-copy- ${ TARGET } )
2022-11-30 15:40:34 -07:00
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-06-03 07:22:39 -06:00
if ( EMSCRIPTEN )
foreach ( res IN LISTS RESOURCE_FILES )
get_filename_component ( res_name "${res}" NAME )
target_link_options ( ${ TARGET } PRIVATE "SHELL:--embed-file ${res}@${res_name}" )
endforeach ( )
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 ( )
2023-07-16 11:38:17 -06:00
if ( AST_BUILD_DEPENDENT )
2023-02-27 20:20:30 -07:00
target_include_directories ( ${ TARGET } BEFORE PRIVATE $< TARGET_PROPERTY:SDL3::${sdl_name_component},INCLUDE_DIRECTORIES > )
2023-07-16 11:38:17 -06:00
target_include_directories ( ${ TARGET } BEFORE PRIVATE ${ SDL3_SOURCE_DIR } /src )
endif ( )
2022-11-30 15:40:34 -07:00
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 ( )
2023-04-19 08:28:39 -06:00
if ( WINDOWS_STORE )
target_compile_definitions ( ${ TARGET } PRIVATE "SDL_MAIN_NOIMPL" )
set_property ( TARGET ${ TARGET } PROPERTY WIN32_EXECUTABLE TRUE )
set_property ( TARGET ${ TARGET } PROPERTY RUNTIME_OUTPUT_DIRECTORY "${uwp_bindir}" )
target_link_options ( ${ TARGET } PRIVATE
- n o d e f a u l t l i b : v c c o r l i b $ < $ < C O N F I G : D e b u g > : d >
- n o d e f a u l t l i b : m s v c r t $ < $ < C O N F I G : D e b u g > : d >
v c c o r l i b $ < $ < C O N F I G : D e b u g > : d > . l i b
m s v c r t $ < $ < C O N F I G : D e b u g > : d > . l i b
)
endif ( )
2022-11-30 15:40:34 -07:00
2023-06-03 07:22:39 -06:00
if ( EMSCRIPTEN )
set_property ( TARGET ${ TARGET } PROPERTY SUFFIX ".html" )
endif ( )
2022-11-30 15:40:34 -07:00
if ( OPENGL_FOUND )
target_compile_definitions ( ${ TARGET } PRIVATE HAVE_OPENGL )
endif ( )
2023-01-07 08:15:28 -07:00
2023-02-27 20:20:30 -07:00
# FIXME: only add "${SDL3_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>" + include paths of external dependencies
2023-07-16 11:38:17 -06:00
target_include_directories ( ${ TARGET } PRIVATE "$<TARGET_PROPERTY:SDL3::${sdl_name_component},INCLUDE_DIRECTORIES>" )
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 ( testsurround SOURCES testsurround.c )
add_sdl_test_executable ( testresample NEEDS_RESOURCES SOURCES testresample.c )
add_sdl_test_executable ( testaudioinfo SOURCES testaudioinfo.c )
2023-07-30 21:00:52 -06:00
add_sdl_test_executable ( testaudiostreamdynamicresample NEEDS_RESOURCES TESTUTILS 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-07-16 11:38:17 -06:00
set ( build_options_dependent_tests )
add_sdl_test_executable ( testevdev BUILD_DEPENDENT NONINTERACTIVE SOURCES testevdev.c )
2023-03-16 17:25:39 -06:00
2023-07-16 11:38:17 -06:00
if ( APPLE )
add_sdl_test_executable ( testnative BUILD_DEPENDENT NEEDS_RESOURCES TESTUTILS
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
)
cmake_push_check_state ( )
check_c_compiler_flag ( -Wno-error=deprecated-declarations HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS )
cmake_pop_check_state ( )
target_link_libraries ( testnative PRIVATE "-Wl,-framework,Cocoa" )
if ( HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS )
set_property ( SOURCE "testnativecocoa.m" APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-error=deprecated-declarations" )
endif ( )
elseif ( WINDOWS )
add_sdl_test_executable ( testnative BUILD_DEPENDENT NEEDS_RESOURCES TESTUTILS SOURCES testnative.c testnativew32.c )
elseif ( HAVE_X11 )
add_sdl_test_executable ( testnative BUILD_DEPENDENT NEEDS_RESOURCES TESTUTILS SOURCES testnative.c testnativex11.c )
target_link_libraries ( testnative PRIVATE X11 )
2022-05-04 06:15:12 -06:00
endif ( )
2023-09-04 13:10:30 -06:00
find_package ( Python3 )
function ( files2headers OUTPUT )
set ( xxd "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/xxd.py" )
set ( inputs ${ ARGN } )
set ( outputs )
foreach ( input IN LISTS inputs )
get_filename_component ( file_we "${input}" NAME_WE )
set ( intermediate "${CMAKE_CURRENT_BINARY_DIR}/${file_we}.h" )
set ( output "${CMAKE_CURRENT_SOURCE_DIR}/${file_we}.h" )
list ( APPEND outputs "${output}" )
if ( Python3_FOUND AND Python3_VERSION VERSION_GREATER_EQUAL "3.2" )
list ( APPEND outputs "${intermediate}" )
# Don't add the 'output' header to the output, to avoid marking them as GENERATED
# (generated files are removed when running the CLEAN target)
add_custom_command ( OUTPUT "${intermediate}"
C O M M A N D P y t h o n 3 : : I n t e r p r e t e r " $ { x x d } " - i " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / $ { i n p u t } " " - o " " $ { i n t e r m e d i a t e } "
C O M M A N D " $ { C M A K E _ C O M M A N D } " - E c o p y _ i f _ d i f f e r e n t " $ { i n t e r m e d i a t e } " " $ { o u t p u t } "
D E P E N D S " $ { x x d } " " $ { b m p } "
)
endif ( )
endforeach ( )
set ( ${ OUTPUT } "${outputs}" PARENT_SCOPE )
endfunction ( )
files2headers ( gamepad_image_headers
2023-07-16 07:50:32 -06:00
g a m e p a d _ a x i s _ a r r o w . b m p
g a m e p a d _ a x i s . b m p
g a m e p a d _ b a c k . b m p
g a m e p a d _ b a t t e r y _ e m p t y . b m p
g a m e p a d _ b a t t e r y _ f u l l . b m p
g a m e p a d _ b a t t e r y _ l o w . b m p
g a m e p a d _ b a t t e r y _ m e d i u m . b m p
g a m e p a d _ b a t t e r y _ u n k n o w n . b m p
g a m e p a d _ b a t t e r y _ w i r e d . b m p
g a m e p a d _ b u t t o n _ b a c k g r o u n d . b m p
g a m e p a d _ b u t t o n . b m p
g a m e p a d _ b u t t o n _ s m a l l . b m p
g a m e p a d _ f a c e _ a b x y . b m p
g a m e p a d _ f a c e _ b a y x . b m p
g a m e p a d _ f a c e _ s o n y . b m p
g a m e p a d _ f r o n t . b m p
g a m e p a d _ t o u c h p a d . b m p
)
2023-09-04 13:10:30 -06:00
files2headers ( icon_bmp_header icon.bmp )
2023-07-16 07:50:32 -06:00
2023-08-02 10:13:35 -06:00
add_sdl_test_executable ( testaudio NEEDS_RESOURCES TESTUTILS SOURCES testaudio.c )
2023-03-17 12:23:56 -06:00
add_sdl_test_executable ( testfile NONINTERACTIVE SOURCES testfile.c )
2023-07-16 07:50:32 -06:00
add_sdl_test_executable ( testcontroller TESTUTILS SOURCES testcontroller.c gamepadutils.c ${ gamepad_image_headers } )
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 )
2023-06-03 07:22:39 -06:00
add_sdl_test_executable ( testgles2_sdf NEEDS_RESOURCES TESTUTILS SOURCES testgles2_sdf.c )
2023-03-17 12:23:56 -06:00
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 )
2023-09-07 19:28:01 -06:00
if ( WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4 )
add_sdl_test_executable ( testfilesystem_pre SOURCES testfilesystem_pre.c NONINTERACTIVE NONINTERACTIVE_TIMEOUT 60 )
endif ( )
2023-03-17 12:23:56 -06:00
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 )
2023-09-04 13:10:30 -06:00
add_sdl_test_executable ( testspriteminimal SOURCES testspriteminimal.c ${ icon_bmp_header } )
2023-03-17 12:23:56 -06:00
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
2023-02-27 20:20:30 -07:00
string ( APPEND CMAKE_REQUIRED_FLAGS " -Wformat" )
2023-01-07 14:25:09 -07:00
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 )
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" )
2023-08-09 11:05:56 -06:00
find_package ( Python3 COMPONENTS Interpreter )
if ( TARGET Python3::Interpreter )
add_custom_target ( serve-sdl-tests
C O M M A N D P y t h o n 3 : : I n t e r p r e t e r " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / e m s c r i p t e n / s e r v e r . p y " - d " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } " )
endif ( )
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 )
2023-02-27 20:20:30 -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 } "
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 } "
)
endforeach ( )
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
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
2023-09-07 19:28:01 -06:00
if ( TARGET testfilesystem_pre )
set_property ( TEST testfilesystem APPEND PROPERTY DEPENDS testfilesystem_pre )
endif ( )
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 ( )
2023-03-27 04:03:42 -06:00
if ( ANDROID AND TARGET SDL3-jar )
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake/android" )
find_package ( SdlAndroid MODULE )
if ( SdlAndroid_FOUND )
set ( apks "" )
set ( packages "" )
include ( SdlAndroidFunctions )
sdl_create_android_debug_keystore ( SDL_test-debug-keystore )
sdl_android_compile_resources ( SDL_test-resources RESFOLDER android/res )
add_custom_target ( sdl-test-apks )
foreach ( TEST ${ SDL_TEST_EXECUTABLES } )
set ( ANDROID_MANIFEST_APP_NAME "${TEST}" )
set ( ANDROID_MANIFEST_LABEL "${TEST}" )
set ( ANDROID_MANIFEST_LIB_NAME "$<TARGET_FILE_BASE_NAME:${TEST}>" )
set ( ANDROID_MANIFEST_PACKAGE "org.libsdl.sdl.test.${TEST}" )
set ( generated_manifest_path "${CMAKE_CURRENT_BINARY_DIR}/android/${TEST}-src/AndroidManifest.xml" )
string ( REPLACE "." "/" JAVA_PACKAGE_DIR "${ANDROID_MANIFEST_PACKAGE}" )
set ( GENERATED_SRC_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/android/${TEST}-src" )
set ( GENERATED_RES_FOLDER "${GENERATED_SRC_FOLDER}/res" )
set ( JAVA_PACKAGE_DIR "${GENERATED_SRC_FOLDER}/${JAVA_PACKAGE_DIR}" )
configure_file ( android/cmake/SDLEntryTestActivity.java.cmake "${JAVA_PACKAGE_DIR}/SDLEntryTestActivity.java" @ONLY )
configure_file ( android/cmake/SDLTestActivity.java.cmake "${JAVA_PACKAGE_DIR}/SDLTestActivity.java" @ONLY )
configure_file ( android/cmake/res/values/strings.xml.cmake android/res/values/strings- ${ TEST } .xml @ONLY )
configure_file ( android/cmake/res/xml/shortcuts.xml.cmake "${GENERATED_RES_FOLDER}/xml/shortcuts.xml" @ONLY )
configure_file ( android/cmake/AndroidManifest.xml.cmake "${generated_manifest_path}" @ONLY )
file ( GENERATE
O U T P U T " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / a n d r o i d / $ { T E S T } - $ < C O N F I G > / r e s / v a l u e s / s t r i n g s . x m l "
I N P U T " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / a n d r o i d / r e s / v a l u e s / s t r i n g s - $ { T E S T } . x m l "
)
sdl_android_compile_resources ( ${ TEST } -resources
R E S O U R C E S
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / a n d r o i d / $ { T E S T } - $ < C O N F I G > / r e s / v a l u e s / s t r i n g s . x m l "
" $ { G E N E R A T E D _ R E S _ F O L D E R } / x m l / s h o r t c u t s . x m l "
)
sdl_android_link_resources ( ${ TEST } -apk-linked
M A N I F E S T " $ { g e n e r a t e d _ m a n i f e s t _ p a t h } "
P A C K A G E $ { A N D R O I D _ M A N I F E S T _ P A C K A G E }
R E S _ T A R G E T S S D L _ t e s t - r e s o u r c e s $ { T E S T } - r e s o u r c e s
T A R G E T _ S D K _ V E R S I O N 3 1
)
set ( CMAKE_JAVA_COMPILE_FLAGS "-encoding;utf-8" )
set ( classes_path "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TEST}-java.dir/classes" )
# Some CMake versions have a slow `cmake -E make_directory` implementation
if ( NOT IS_DIRECTORY "${classes_path}" )
execute_process ( COMMAND ${ CMAKE_COMMAND } -E make_directory "${classes_path}" )
endif ( )
set ( OUT_JAR "${CMAKE_CURRENT_BINARY_DIR}/${TEST}.jar" )
add_custom_command (
O U T P U T " $ { O U T _ J A R } "
C O M M A N D $ { C M A K E _ C O M M A N D } - E r m - r f " $ { c l a s s e s _ p a t h } "
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 " $ { c l a s s e s _ p a t h } "
C O M M A N D $ { J a v a _ J A V A C _ E X E C U T A B L E }
- s o u r c e 1 . 8 - t a r g e t 1 . 8
- b o o t c l a s s p a t h " $ < T A R G E T _ P R O P E R T Y : S D L 3 - j a r , O U T P U T > "
" $ { J A V A _ P A C K A G E _ D I R } / S D L E n t r y T e s t A c t i v i t y . j a v a "
" $ { J A V A _ P A C K A G E _ D I R } / S D L T e s t A c t i v i t y . j a v a "
$ < T A R G E T _ P R O P E R T Y : $ { T E S T } - a p k - l i n k e d , J A V A _ R >
- c p " $ < T A R G E T _ P R O P E R T Y : S D L 3 - j a r , O U T P U T > : $ { p a t h _ a n d r o i d _ j a r } "
- d " $ { c l a s s e s _ p a t h } "
C O M M A N D $ { J a v a _ J A R _ E X E C U T A B L E } c f " $ { O U T _ J A R } " - C " $ { c l a s s e s _ p a t h } " .
D E P E N D S $ < T A R G E T _ P R O P E R T Y : $ { T E S T } - a p k - l i n k e d , O U T P U T S > " $ < T A R G E T _ P R O P E R T Y : S D L 3 - j a r , O U T P U T > " " $ { J A V A _ P A C K A G E _ D I R } / S D L T e s t A c t i v i t y . j a v a " " $ { J A V A _ P A C K A G E _ D I R } / S D L E n t r y T e s t A c t i v i t y . j a v a "
)
add_custom_target ( ${ TEST } -jar DEPENDS "${OUT_JAR}" )
set_property ( TARGET ${ TEST } -jar PROPERTY OUTPUT "${OUT_JAR}" )
set ( dexworkdir "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TEST}-dex.dir" )
# Some CMake versions have a slow `cmake -E make_directory` implementation
if ( NOT IS_DIRECTORY "${dexworkdir}" )
execute_process ( COMMAND "${CMAKE_COMMAND}" -E make_directory "${dexworkdir}" )
endif ( )
set ( classes_dex_base_name "classes.dex" )
set ( classes_dex "${dexworkdir}/${classes_dex_base_name}" )
add_custom_command (
O U T P U T " $ { c l a s s e s _ d e x } "
C O M M A N D S d l A n d r o i d : : d 8
$ < T A R G E T _ P R O P E R T Y : $ { T E S T } - j a r , O U T P U T >
$ < T A R G E T _ P R O P E R T Y : S D L 3 - j a r , O U T P U T >
- - l i b " $ { p a t h _ a n d r o i d _ j a r } "
- - o u t p u t " $ { d e x w o r k d i r } "
D E P E N D S $ < T A R G E T _ P R O P E R T Y : $ { T E S T } - j a r , O U T P U T > $ < T A R G E T _ P R O P E R T Y : S D L 3 - j a r , O U T P U T >
)
add_custom_target ( ${ TEST } -dex DEPENDS "${classes_dex}" )
set_property ( TARGET ${ TEST } -dex PROPERTY OUTPUT "${classes_dex}" )
set_property ( TARGET ${ TEST } -dex PROPERTY OUTPUT_BASE_NAME "${classes_dex_base_name}" )
sdl_add_to_apk_unaligned ( ${ TEST } -unaligned-apk
A P K _ I N $ { T E S T } - a p k - l i n k e d
O U T D I R " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / i n t e r m e d i a t e s "
A S S E T S $ { R E S O U R C E _ F I L E S }
N A T I V E _ L I B S S D L 3 : : S D L 3 - s h a r e d $ { T E S T }
D E X $ { T E S T } - d e x
)
sdl_apk_align ( ${ TEST } -aligned-apk ${ TEST } -unaligned-apk
O U T D I R " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / i n t e r m e d i a t e s "
)
sdl_apk_sign ( ${ TEST } -apk ${ TEST } -aligned-apk
K E Y S T O R E S D L _ t e s t - d e b u g - k e y s t o r e
)
add_dependencies ( sdl-test-apks ${ TEST } -apk )
if ( TARGET SdlAndroid::adb )
add_custom_target ( install- ${ TEST }
C O M M A N D " $ { C M A K E _ C O M M A N D } " - D A C T I O N = i n s t a l l " - D A P K S = $ < T A R G E T _ P R O P E R T Y : $ { T E S T } - a p k , O U T P U T > " - P " $ { S D L 3 _ S O U R C E _ D I R } / c m a k e / a n d r o i d / S d l A n d r o i d S c r i p t . c m a k e "
D E P E N D S " $ { T E S T } - a p k "
)
add_custom_target ( start- ${ TEST }
C O M M A N D " $ { A D B _ B I N } " s h e l l a m s t a r t - a c t i v i t y - S " $ { A N D R O I D _ M A N I F E S T _ P A C K A G E } / . S D L T e s t A c t i v i t y "
)
add_custom_target ( build-install-start- ${ TEST }
C O M M A N D " $ { C M A K E _ C O M M A N D } " - D A C T I O N = b u i l d - i n s t a l l - r u n " - D E X E C U T A B L E S = $ { T E S T } " " - D B U I L D _ F O L D E R = $ { C M A K E _ B I N A R Y _ D I R } " - P " $ { S D L 3 _ S O U R C E _ D I R } / c m a k e / a n d r o i d / S d l A n d r o i d S c r i p t . c m a k e "
)
endif ( )
list ( APPEND packages "${ANDROID_MANIFEST_PACKAGE}" )
list ( APPEND install_targets install- ${ TEST } )
endforeach ( )
if ( TARGET SdlAndroid::adb )
add_custom_target ( install-sdl-test-apks
D E P E N D S $ { i n s t a l l _ t a r g e t s }
V E R B A T I M
)
add_custom_target ( uninstall-sdl-test-apks
C O M M A N D " $ { C M A K E _ C O M M A N D } " " - D A D B = $ < T A R G E T _ F I L E : S d l A n d r o i d : : a d b > " - D A C T I O N = u n i n s t a l l " - D P A C K A G E S = $ { p a c k a g e s } " - P " $ { S D L 3 _ S O U R C E _ D I R } / c m a k e / a n d r o i d / S d l A n d r o i d S c r i p t . c m a k e "
V E R B A T I M
)
endif ( )
endif ( )
endif ( )