cmake_minimum_required(VERSION 3.25)
project(KartPadViewportInterpolationTests LANGUAGES C CXX OBJC OBJCXX)
set(CMAKE_CXX_STANDARD 20)

set(KARTPAD_AURORA_SOURCE "" CACHE PATH "Aurora directory from a prepared KartPad runtime")
if(NOT EXISTS "${KARTPAD_AURORA_SOURCE}/lib/gx/frame_interpolation.cpp")
  message(FATAL_ERROR "Set KARTPAD_AURORA_SOURCE to a prepared runtime's aurora-main directory")
endif()
option(KARTPAD_TEST_SANITIZERS "Enable address and undefined behavior sanitizers" OFF)
set(AURORA_ENABLE_CARD OFF CACHE BOOL "Tests do not use memory cards")
add_subdirectory("${KARTPAD_AURORA_SOURCE}" aurora)
enable_testing()
add_subdirectory("${KARTPAD_AURORA_SOURCE}/tests" aurora-tests)
target_sources(gx_fifo_tests PRIVATE "${CMAKE_CURRENT_LIST_DIR}/../apple_viewport_interpolation_test.cpp")
target_include_directories(gx_fifo_tests PRIVATE "${KARTPAD_AURORA_SOURCE}/tests")
# The production runtime also preserves the interpolation NaN/Inf checks.
target_compile_options(gx_fifo_tests PRIVATE -fno-finite-math-only)
if(KARTPAD_TEST_SANITIZERS)
  target_compile_options(gx_fifo_tests PRIVATE -fsanitize=address,undefined -fno-omit-frame-pointer)
  target_link_options(gx_fifo_tests PRIVATE -fsanitize=address,undefined)
endif()
