# Interactive demo programs (formerly Tests/). They use SDL2's SDL_test_common for window and
# renderer command-line options; run with --help for usage.

set(SDL2GFX_DEMO_LIB SDL2_gfx::SDL2_gfx)
if(NOT TARGET SDL2_gfx::SDL2_gfx)
    set(SDL2GFX_DEMO_LIB SDL2_gfx::SDL2_gfx-static)
endif()

function(sdl2gfx_add_demo name)
    add_executable(${name} ${name}.c)
    target_link_libraries(${name} PRIVATE ${SDL2GFX_DEMO_LIB} sdl2gfx_build_flags ${ARGN})
    if(TARGET SDL2::SDL2main)
        target_link_libraries(${name} PRIVATE SDL2::SDL2main)
    endif()
    if(UNIX)
        target_link_libraries(${name} PRIVATE m)
    endif()
    set_target_properties(${name} PROPERTIES
        C_STANDARD 99
        FOLDER demo
        RUNTIME_OUTPUT_DIRECTORY "${SDL2GFX_RUNTIME_DIR}")
    # Demos load the sample images from their working directory (the executable folder).
    add_dependencies(${name} sdl2gfx_runtime)
endfunction()

sdl2gfx_add_demo(testgfx SDL2::SDL2test)
sdl2gfx_add_demo(testrotozoom SDL2::SDL2test)
sdl2gfx_add_demo(testframerate SDL2::SDL2test)
sdl2gfx_add_demo(testimagefilter)
