# Interactive demo programs (formerly Test/). Most open a window and cycle through test screens;
# see the comments at the top of each source file for keyboard/mouse controls and arguments.

set(SDLGFX_DEMO_LIB SDL_gfx::SDL_gfx)
if(NOT TARGET SDL_gfx::SDL_gfx)
    set(SDLGFX_DEMO_LIB SDL_gfx::SDL_gfx-static)
endif()

function(sdlgfx_add_demo name)
    add_executable(${name} ${name}.c)
    target_link_libraries(${name} PRIVATE ${SDLGFX_DEMO_LIB} sdlgfx_build_flags)
    if(TARGET SDL::SDLmain)
        target_link_libraries(${name} PRIVATE SDL::SDLmain)
    endif()
    if(UNIX)
        target_link_libraries(${name} PRIVATE m)
    endif()
    set_target_properties(${name} PROPERTIES
        C_STANDARD 99
        FOLDER demo
        RUNTIME_OUTPUT_DIRECTORY "${SDLGFX_RUNTIME_DIR}")
    # Demos load sample images and fonts from their working directory (the executable folder).
    add_dependencies(${name} sdlgfx_runtime)
endfunction()

foreach(demo
        LaplaceRelaxation
        TestABGR
        TestFonts
        TestFramerate
        TestGfxBlit
        TestGfxPrimitives
        TestGfxTexture
        TestImageFilter
        TestRotozoom
        TestShrink)
    sdlgfx_add_demo(${demo})
endforeach()
