@@ -1212,27 +1212,33 @@ if(SDLMIXER_SAMPLES)
1212
1212
check_include_file ("signal.h" HAVE_SIGNAL_H )
1213
1213
check_symbol_exists ("setbuf" "stdio.h" HAVE_SETBUF )
1214
1214
1215
- add_executable (playmus examples/playmus.c )
1216
- add_executable (playwave examples/playwave.c )
1217
-
1218
- foreach (prog playmus playwave )
1219
- sdl_add_warning_options (${prog} WARNING_AS_ERROR ${SDLMIXER_WERROR} )
1220
- target_link_libraries (${prog} PRIVATE SDL3::SDL3_test )
1221
- target_link_libraries (${prog} PRIVATE SDL3_mixer::${sdl3_mixer_target_name} )
1222
- target_link_libraries (${prog} PRIVATE ${sdl3_target_name} )
1215
+ function (add_sdl_mixer_example_executable TARGET )
1216
+ if (ANDROID )
1217
+ add_library (${TARGET} SHARED ${ARGN} )
1218
+ else ()
1219
+ add_executable (${TARGET} ${ARGN} )
1220
+ endif ()
1221
+ sdl_add_warning_options (${TARGET} WARNING_AS_ERROR ${SDLMIXER_WERROR} )
1222
+ sdl_target_link_options_no_undefined (${TARGET} )
1223
+ target_link_libraries (${TARGET} PRIVATE SDL3::SDL3_test )
1224
+ target_link_libraries (${TARGET} PRIVATE SDL3_mixer::${sdl3_mixer_target_name} )
1225
+ target_link_libraries (${TARGET} PRIVATE ${sdl3_target_name} )
1223
1226
if (HAVE_SIGNAL_H )
1224
- target_compile_definitions (${prog } PRIVATE HAVE_SIGNAL_H )
1227
+ target_compile_definitions (${TARGET } PRIVATE HAVE_SIGNAL_H )
1225
1228
endif ()
1226
1229
if (HAVE_SETBUF )
1227
- target_compile_definitions (${prog } PRIVATE HAVE_SETBUF )
1230
+ target_compile_definitions (${TARGET } PRIVATE HAVE_SETBUF )
1228
1231
endif ()
1229
1232
1230
1233
if (SDLMIXER_SAMPLES_INSTALL )
1231
- install (TARGETS ${prog }
1234
+ install (TARGETS ${TARGET }
1232
1235
RUNTIME DESTINATION "${CMAKE_INSTALL_LIBEXECDIR} /installed-tests/SDL3_mixer"
1233
1236
)
1234
1237
endif ()
1235
- endforeach ()
1238
+ endfunction ()
1239
+
1240
+ add_sdl_mixer_example_executable (playmus examples/playmus.c )
1241
+ add_sdl_mixer_example_executable (playwave examples/playwave.c )
1236
1242
endif ()
1237
1243
1238
1244
set (available_deps )
0 commit comments