cmake_minimum_required(VERSION 4.3)
project(ascii_aquarium)

set(CMAKE_CXX_STANDARD 20)

add_executable(ascii_aquarium main.cpp)

# Make sure the fish sprite files are available next to the built
# executable, since that's where CLion runs the program from by default.
#
# CONFIGURE_DEPENDS makes CMake re-scan the fish/ directory (and reconfigure)
# whenever its contents change, and listing the files as DEPENDS below means
# the copy step re-runs whenever a fish file is added/edited/removed - even
# if main.cpp itself didn't change.
file(GLOB FISH_SOURCE_FILES CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/fish/*)

add_custom_command(
    OUTPUT ${CMAKE_BINARY_DIR}/fish_copied.stamp
    COMMAND ${CMAKE_COMMAND} -E copy_directory
        ${CMAKE_SOURCE_DIR}/fish
        $<TARGET_FILE_DIR:ascii_aquarium>/fish
    COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/fish_copied.stamp
    DEPENDS ${FISH_SOURCE_FILES}
    COMMENT "Copying fish sprites to build output"
)

add_custom_target(copy_fish ALL DEPENDS ${CMAKE_BINARY_DIR}/fish_copied.stamp)
add_dependencies(ascii_aquarium copy_fish)
