# Configure with [fxsdk build-fx] or [fxsdk build-cg], which provide the
# toolchain file and module path of the fxSDK

cmake_minimum_required(VERSION 3.15)
project(Golly)

include(GenerateG1A)
include(Fxconv)
find_package(Gint 2.1 REQUIRED)

set(SOURCES
  src/main.c
  src/editmode.c
)

set(ASSETS_fx
  assets-fx/runbar.png
  assets-fx/editbar.png
  assets-fx/patternbar.png
  assets-fx/smalltext.png
  assets-fx/patterns/koksgalaxy.png
  assets-fx/patterns/mazing.png
  assets-fx/patterns/unix.png
  assets-fx/patterns/figureeight.png
  assets-fx/patterns/glider.png
  assets-fx/patterns/lightweight.png
  assets-fx/patterns/copperhead.png
  assets-fx/patterns/weekender.png
  assets-fx/patterns/schick.png
  assets-fx/patterns/mwssonmwss1.png
  assets-fx/patterns/rpentomino.png
  assets-fx/patterns/piheptomino.png
  assets-fx/patterns/bheptomino.png
)

fxconv_declare_assets(${ASSETS} ${ASSETS_fx} WITH_METADATA)
fxconv_declare_converters(assets-fx/converters.py)

add_executable(golly ${SOURCES} ${ASSETS_${FXSDK_PLATFORM}})
target_compile_options(golly PRIVATE -Wall -Wextra -std=c11  -O3)
target_link_libraries(golly Gint::Gint)
target_link_options(golly PRIVATE -Wl,-Map=map.map)

if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
  generate_g1a(TARGET golly OUTPUT "Golly.g1a"
    NAME "Golly" ICON assets-fx/icon.png)
endif()
