cmake_minimum_required(VERSION 3.28)

project(fantemp LANGUAGES CXX)

# libavr from a local checkout (LIBAVR_ROOT) or the forge; the toolchain
# file comes from the same checkout via CMakePresets.json.
include(FetchContent)
if(NOT LIBAVR_ROOT AND DEFINED ENV{LIBAVR_ROOT})
	set(LIBAVR_ROOT $ENV{LIBAVR_ROOT})
endif()
if(LIBAVR_ROOT)
	FetchContent_Declare(libavr SOURCE_DIR ${LIBAVR_ROOT})
else()
	FetchContent_Declare(libavr GIT_REPOSITORY git@git.blackmark.me:avr/libavr.git GIT_TAG main)
endif()
FetchContent_MakeAvailable(libavr)

add_executable(fantemp src/main.cpp)
target_link_libraries(fantemp PRIVATE libavr)
add_custom_command(TARGET fantemp POST_BUILD COMMAND ${CMAKE_SIZE} $<TARGET_FILE:fantemp>)
