cmake_minimum_required(VERSION 3.13)
set(PICO_BOARD pico)                  # same flash (W25Q16, 2 MB) and 12 MHz crystal as the Pico
include(pico_sdk_import.cmake)
project(ashlight C CXX ASM)
set(CMAKE_C_STANDARD 11)
pico_sdk_init()

set(ASHLIGHT_BOARD "ashlight_revb" CACHE STRING "ashlight_revb or pico_proto")
set(ASHLIGHT_VERSION "0.2.0")

add_executable(ashlight main.c hal.c ../src/ashlight_core.c ../src/settings.c)
target_include_directories(ashlight PRIVATE . ../include)
if(ASHLIGHT_BOARD STREQUAL "pico_proto")
    target_compile_definitions(ashlight PRIVATE ASHLIGHT_BOARD_PICO_PROTO)
else()
    target_compile_definitions(ashlight PRIVATE ASHLIGHT_BOARD_REVB)
endif()
target_compile_definitions(ashlight PRIVATE ASHLIGHT_VERSION="${ASHLIGHT_VERSION}"
    PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS=0)
target_compile_options(ashlight PRIVATE -Wall -Wextra -Werror)
target_link_libraries(ashlight pico_stdlib pico_unique_id hardware_i2c hardware_adc hardware_flash
    hardware_pll hardware_clocks hardware_watchdog)
pico_enable_stdio_usb(ashlight 1)
pico_enable_stdio_uart(ashlight 0)
pico_set_program_name(ashlight "AshLight")
pico_set_program_url(ashlight "https://ashlight.radiantmachines.com")
# UF2 is produced by tools/elf2uf2.py (no picotool download needed at build time)
pico_add_dis_output(ashlight)
pico_add_bin_output(ashlight)
