cmake_minimum_required(VERSION 3.8)
cmake_policy(SET CMP0069 NEW)


if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AVR")
    add_subdirectory("atmega328p")
elseif ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Cortex-M7")
    add_subdirectory("NUCLEO-H743ZI2")
elseif ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "MICROBLAZE")
    add_subdirectory("mb")
elseif ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Cortex-M4")
    add_subdirectory("stm32f407g-disc1")
elseif ("${TOOLCHAIN_PREFIX}" STREQUAL "")
    add_subdirectory("host")
    set(CMAKE_SIZE_UTIL size CACHE INTERNAL "size tool")
endif()


# any platform, as there is no timer
add_executable(ping-pong-throughput ping-pong-throughput.cpp)
target_link_libraries(ping-pong-throughput board)
add_custom_command(TARGET ping-pong-throughput
    POST_BUILD COMMAND ${CMAKE_SIZE_UTIL} ping-pong-throughput)

#if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Cortex-M7")
#    set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/NUCLEO-H743ZI2/STM32H743ZITx_FLASH.ld)
#    target_link_options(ping-pong-throughput PUBLIC -T ${LINKER_SCRIPT})
#endif()

if (DEFINED LINKER_SCRIPT)
    target_link_options(ping-pong-throughput PUBLIC -T ${LINKER_SCRIPT})
endif()
