@@ -289,23 +289,30 @@ if(SDLNET_INSTALL)
289289endif ()
290290
291291if (SDLNET_SAMPLES)
292- add_executable (voipchat examples/voipchat.c)
293- add_executable (simple-http-get examples/simple-http-get .c)
294- add_executable (resolve-hostnames examples/resolve-hostnames.c)
295- add_executable (get -local-addrs examples/get -local-addrs.c)
296-
297- set (examples voipchat simple-http-get resolve-hostnames get -local-addrs)
298- foreach (example IN LISTS examples)
299- target_link_libraries (${example} PRIVATE SDL3_net::SDL3_net SDL3::SDL3)
300- set_property (TARGET ${example} PROPERTY C_STANDARD 99)
301- set_property (TARGET ${example} PROPERTY C_EXTENSIONS FALSE )
302- sdl_add_warning_options(${example} WARNING_AS_ERROR ${SDLNET_WERROR} )
292+ function (add_sdl_net_example_executable TARGET )
293+ if (ANDROID)
294+ add_library (${TARGET} SHARED ${ARGN} )
295+ else ()
296+ add_executable (${TARGET} ${ARGN} )
297+ endif ()
298+ sdl_add_warning_options(${TARGET} WARNING_AS_ERROR ${SDLTTF_WERROR} )
299+ sdl_target_link_options_no_undefined(${TARGET} )
300+ target_link_libraries (${TARGET} PRIVATE SDL3_net::${sdl3_net_target_name} )
301+ target_link_libraries (${TARGET} PRIVATE ${sdl3_target_name} )
302+ set_property (TARGET ${TARGET} PROPERTY C_STANDARD 99)
303+ set_property (TARGET ${TARGET} PROPERTY C_EXTENSIONS FALSE )
304+
303305 if (SDLNET_SAMPLES_INSTALL)
304- install (TARGETS ${example }
305- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR} "
306+ install (TARGETS ${TARGET }
307+ RUNTIME DESTINATION "${CMAKE_INSTALL_LIBEXECDIR} /installed-tests/SDL3_net "
306308 )
307309 endif ()
308- endforeach ()
310+ endfunction ()
311+ add_sdl_net_example_executable(voipchat examples/voipchat.c)
312+ add_sdl_net_example_executable(simple-http-get examples/simple-http-get .c)
313+ add_sdl_net_example_executable(resolve-hostnames examples/resolve-hostnames.c)
314+ add_sdl_net_example_executable(get -local-addrs examples/get -local-addrs.c)
315+
309316 # Build at least one example in C90
310317 set_property (TARGET get -local-addrs PROPERTY C_STANDARD 90)
311318endif ()
0 commit comments