cmake_minimum_required(VERSION 3.24)
project(AckmanRecomp VERSION 1.0.1 LANGUAGES C CXX)
include(GNUInstallDirs)
include(CTest)
option(ACKMAN_FLATPAK "Use persistent XDG directories inside the Flatpak sandbox" OFF)
set(ACKMAN_APPLICATION_ID "org.snesrecomp.AckmanRecomp")
set(ACKMAN_PACKAGE_DATADIR "${CMAKE_INSTALL_DATADIR}/${ACKMAN_APPLICATION_ID}")
if(ACKMAN_FLATPAK AND NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
  message(FATAL_ERROR "ACKMAN_FLATPAK is a Linux packaging option")
endif()
find_package(Python3 COMPONENTS Interpreter REQUIRED)
set(ZLIB_USE_STATIC_LIBS ON)
find_package(ZLIB REQUIRED)
if(ACKMAN_FLATPAK)
  get_target_property(ACKMAN_ZLIB_STATIC ZLIB::ZLIB IMPORTED_LOCATION_RELEASE)
  if(NOT ACKMAN_ZLIB_STATIC)
    get_target_property(ACKMAN_ZLIB_STATIC ZLIB::ZLIB IMPORTED_LOCATION)
  endif()
  if(NOT ACKMAN_ZLIB_STATIC MATCHES "\\.a$")
    message(FATAL_ERROR "Flatpak requires static zlib: set ZLIB_LIBRARY_RELEASE to /app/lib/libz.a")
  endif()
endif()
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(SNESRECOMP_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/external/snesrecomp")
if(NOT EXISTS "${SNESRECOMP_ROOT}/runner/runner.cmake")
  message(FATAL_ERROR "Run scripts/bootstrap.ps1 first")
endif()
find_package(Git REQUIRED)
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/framework.lock" EXPECTED_REV LIMIT_COUNT 1)
execute_process(COMMAND "${GIT_EXECUTABLE}" -c "safe.directory=${SNESRECOMP_ROOT}" -C "${SNESRECOMP_ROOT}" rev-parse HEAD OUTPUT_VARIABLE ACTUAL_REV OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ERROR_IS_FATAL ANY)
if(NOT ACTUAL_REV STREQUAL EXPECTED_REV)
  message(FATAL_ERROR "Framework revision differs from framework.lock")
endif()
# Flatpak prepares its sources in the manifest's extraction phase. Never
# rewrite runner.cmake (a Ninja regeneration input) during Flatpak configure.
if(NOT ACKMAN_FLATPAK)
  include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/AckmanPatches.cmake")
endif()
set(SNESRECOMP_SDL_BACKEND SDL3 CACHE STRING "Required backend" FORCE)
set(SNESRECOMP_ENABLE_MODS ON CACHE BOOL "Data-only mod packages" FORCE)
include("${SNESRECOMP_ROOT}/runner/runner.cmake")
add_executable(AckmanRecomp ${SNESRECOMP_RUNNER_SOURCES}
  src/main.c src/host_contract.c src/ackman_timing.c src/gen_stubs.c
  src/port_extensions.c src/rom_guard.c src/ackman_hooks.c src/ackman_audio.c src/ackman_pcm.c src/ackman_video.c src/ackman_debug.c src/ackman_log.c src/ackman_flow.c src/ackman_menu.c src/ackman_config.c )
target_sources(AckmanRecomp PRIVATE src/ackman_rumble.c src/ackman_ips.c src/ackman_mods.c)
target_sources(AckmanRecomp PRIVATE src/ackman_input_probe.c src/ackman_shader.c src/ackman_capture.c)
target_link_libraries(AckmanRecomp PRIVATE ZLIB::ZLIB)
if(WIN32)
  set_target_properties(AckmanRecomp PROPERTIES WIN32_EXECUTABLE TRUE)
  enable_language(RC)
  set(ACKMAN_ICON_PYTHON "${Python3_EXECUTABLE}" CACHE FILEPATH "Python interpreter with Pillow for Windows icon generation")
  execute_process(COMMAND "${ACKMAN_ICON_PYTHON}" -c "import PIL"
    RESULT_VARIABLE ACKMAN_PIL_STATUS OUTPUT_QUIET ERROR_QUIET)
  if(NOT ACKMAN_PIL_STATUS EQUAL 0)
    message(FATAL_ERROR "Set ACKMAN_ICON_PYTHON to a Python interpreter with Pillow installed")
  endif()
  set(ACKMAN_ICON_DIR "${CMAKE_CURRENT_BINARY_DIR}/windows-icon")
  add_custom_command(OUTPUT "${ACKMAN_ICON_DIR}/icon.ico" "${ACKMAN_ICON_DIR}/icon.rc"
    COMMAND "${ACKMAN_ICON_PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/build_icon.py"
      "${CMAKE_CURRENT_SOURCE_DIR}/icon.png" "${ACKMAN_ICON_DIR}"
    DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/icon.png" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/build_icon.py"
    VERBATIM)
  target_sources(AckmanRecomp PRIVATE "${ACKMAN_ICON_DIR}/icon.rc")
endif()
set_source_files_properties(src/ackman_log.c PROPERTIES COMPILE_DEFINITIONS ACKMAN_LOG_IMPLEMENTATION=1)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  # -D is processed before the forced logging header includes glibc headers.
  set_property(SOURCE "${SNESRECOMP_ROOT}/runner/src/host_report.c" APPEND
    PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE=1)
endif()
if(MSVC)
  target_compile_options(AckmanRecomp PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:/FI${CMAKE_CURRENT_SOURCE_DIR}/src/ackman_log_redirect.h>")
else()
  target_compile_options(AckmanRecomp PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-include${CMAKE_CURRENT_SOURCE_DIR}/src/ackman_log_redirect.h>")
endif()
set_source_files_properties("${SNESRECOMP_ROOT}/runner/src/desktop/host_main.c" PROPERTIES
  COMPILE_DEFINITIONS "msu1_set_rom_path=AckmanMsuSetRomPath;SDL_CreateWindow=AckmanCreateWindow;snes_mod_runtime_initialize_c=AckmanModsInitialize;SDL_PollEvent=AckmanPollEvent;SDL_SetRenderVSync=AckmanSetRenderVSync;SDL_Quit=AckmanDebugQuit;RtlRunFrame=AckmanRunFrame;snesrecomp_launcher_resolve_rom_sha256=AckmanResolveRom")
set_source_files_properties("${SNESRECOMP_ROOT}/runner/src/common_rtl.c" PROPERTIES
  COMPILE_DEFINITIONS "WriteReg=AckmanCoreWriteReg;WriteRegWord=AckmanCoreWriteRegWord;msu1_mix=AckmanMixPcm")
set_source_files_properties("${SNESRECOMP_ROOT}/runner/src/cpu_state.c" PROPERTIES COMPILE_DEFINITIONS "cpu_write8=AckmanCoreCpuWrite8")
set_source_files_properties("${SNESRECOMP_ROOT}/runner/src/snes/dsp.c" PROPERTIES COMPILE_DEFINITIONS "dsp_write=AckmanCoreDspWrite")
set_source_files_properties("${SNESRECOMP_ROOT}/runner/src/snes/apu.c" PROPERTIES COMPILE_DEFINITIONS "apu_cpuWrite=AckmanCoreApuWrite")
target_include_directories(AckmanRecomp PRIVATE ${SNESRECOMP_RUNNER_INCLUDE_DIRS}
  "${SNESRECOMP_ROOT}/runner/src/desktop" "${CMAKE_CURRENT_SOURCE_DIR}/src"
  "${CMAKE_CURRENT_SOURCE_DIR}/recomp")
target_link_libraries(AckmanRecomp PRIVATE ${SNESRECOMP_RUNNER_LIBRARIES})
target_compile_definitions(AckmanRecomp PRIVATE SNES_GAME_TITLE="Go Go Ackman"
  SNES_GAME_VERSION="1.0.1" SNESRECOMP_CLOCKED_BEAM=1)
snesrecomp_rom_identity(AckmanRecomp "${CMAKE_CURRENT_SOURCE_DIR}/rom_identity.txt")
snesrecomp_target_generated_code(AckmanRecomp "${CMAKE_CURRENT_SOURCE_DIR}/src/gen")
# Mods are supplied by users at runtime; release builds have no bundled catalog.
snesrecomp_target_mod_catalog(AckmanRecomp NONE)
snesrecomp_target_sdl(AckmanRecomp)
if(ACKMAN_FLATPAK)
  set(RECOMP_MENU_FLATPAK ON)
  set(RECOMP_MENU_FLATPAK_APP_ID "${ACKMAN_APPLICATION_ID}")
  set(RECOMP_MENU_INSTALLED_ASSETS "/app/share/${ACKMAN_APPLICATION_ID}")
  target_compile_definitions(AckmanRecomp PRIVATE ACKMAN_FLATPAK=1
    ACKMAN_APPLICATION_ID="${ACKMAN_APPLICATION_ID}")
endif()
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/RecompMenuCore.cmake")
target_link_libraries(AckmanRecomp PRIVATE SNES::MenuCore)
install(TARGETS AckmanRecomp RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/AckmanInstall.cmake")
  ackman_install_linux_assets("${CMAKE_CURRENT_SOURCE_DIR}" "${ACKMAN_APPLICATION_ID}" "${ACKMAN_PACKAGE_DATADIR}")
endif()
snesrecomp_target_desktop_host(AckmanRecomp TIER2)
option(ACKMAN_ASAN "Address sanitizer (use a separate build tree)" OFF)
if(ACKMAN_ASAN)
  if(MSVC)
    target_compile_options(AckmanRecomp PRIVATE /fsanitize=address /Zi)
    target_link_options(AckmanRecomp PRIVATE /INCREMENTAL:NO)
  else()
    target_compile_options(AckmanRecomp PRIVATE -fsanitize=address,undefined -fno-omit-frame-pointer -g)
    target_link_options(AckmanRecomp PRIVATE -fsanitize=address,undefined)
  endif()
endif()
if(BUILD_TESTING)
if(WIN32)
  add_test(NAME windows_gui_icon COMMAND "${ACKMAN_ICON_PYTHON}"
    "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_windows_artifact.py"
    "$<TARGET_FILE:AckmanRecomp>" "${ACKMAN_ICON_DIR}/icon.ico")
endif()
add_executable(ackman_config_test tests/test_config.c src/ackman_config.c src/recomp_menu_paths.c
  "${SNESRECOMP_ROOT}/runner/src/desktop/mmx_config.c"
  "${SNESRECOMP_ROOT}/runner/src/util.c"
  "${SNESRECOMP_ROOT}/runner/src/keybinds.c"
  "${SNESRECOMP_ROOT}/runner/src/launcher_cache.c")
target_include_directories(ackman_config_test PRIVATE src "${SNESRECOMP_ROOT}/runner/src")
snesrecomp_target_sdl(ackman_config_test)
if(MSVC)
  target_compile_options(ackman_config_test PRIVATE /UNDEBUG)
else()
  target_compile_options(ackman_config_test PRIVATE -UNDEBUG)
endif()
add_executable(ackman_flatpak_paths_test tests/test_flatpak_paths.c src/recomp_menu_paths.c)
target_include_directories(ackman_flatpak_paths_test PRIVATE src "${SNESRECOMP_ROOT}/runner/src")
snesrecomp_target_sdl(ackman_flatpak_paths_test)
target_compile_definitions(ackman_flatpak_paths_test PRIVATE RECOMP_MENU_FLATPAK=1
  RECOMP_MENU_FLATPAK_APP_ID="${ACKMAN_APPLICATION_ID}"
  RECOMP_MENU_INSTALLED_ASSETS="/app/share/${ACKMAN_APPLICATION_ID}")
if(MSVC)
  target_compile_options(ackman_flatpak_paths_test PRIVATE /UNDEBUG)
else()
  target_compile_options(ackman_flatpak_paths_test PRIVATE -UNDEBUG)
endif()
add_test(NAME unified_configuration COMMAND ${CMAKE_COMMAND}
  "-DCONFIG=$<TARGET_FILE:ackman_config_test>" "-DPATHS=$<TARGET_FILE:ackman_flatpak_paths_test>"
  -P "${CMAKE_CURRENT_SOURCE_DIR}/tests/config_paths_suite.cmake")
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" AND NOT MSVC)
  add_executable(ackman_raster_test tests/test_raster.c "${SNESRECOMP_ROOT}/runner/src/snes/ppu.c" "${SNESRECOMP_ROOT}/runner/src/snes/ppu_legacy.c" "${SNESRECOMP_ROOT}/runner/src/snes/ws_shadow.c")
  target_include_directories(ackman_raster_test PRIVATE "${SNESRECOMP_ROOT}/runner/src")
  target_compile_options(ackman_raster_test PRIVATE -ffunction-sections -fdata-sections)
  target_link_options(ackman_raster_test PRIVATE -Wl,--gc-sections)
  add_test(NAME raster_scroll_windows COMMAND ackman_raster_test)
endif()
add_executable(ackman_log_test tests/test_log.c src/ackman_log.c)
target_include_directories(ackman_log_test PRIVATE src "${SNESRECOMP_ROOT}/runner/src")
snesrecomp_target_sdl(ackman_log_test)
add_test(NAME buffered_logging COMMAND ackman_log_test)
add_executable(ackman_translation_test tests/test_translation_driver.c src/ackman_menu.c src/ackman_ips.c)
target_include_directories(ackman_translation_test PRIVATE src)
target_compile_definitions(ackman_translation_test PRIVATE RECOMP_MENU_TRANSLATION_ONLY=1)
snesrecomp_target_sdl(ackman_translation_test)
if(MSVC)
  target_compile_options(ackman_translation_test PRIVATE /UNDEBUG)
else()
  target_compile_options(ackman_translation_test PRIVATE -UNDEBUG)
endif()
add_test(NAME rom_and_trace_tools COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_tools.py" "$<TARGET_FILE:ackman_translation_test>")
add_executable(ackman_audio_test tests/test_audio.c src/ackman_audio.c src/ackman_pcm.c)
target_include_directories(ackman_audio_test PRIVATE src "${SNESRECOMP_ROOT}/runner/src")
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" AND NOT APPLE)
  set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
    "${SNESRECOMP_ROOT}/runner/src/common_rtl.c" "${SNESRECOMP_ROOT}/runner/src/snes/dsp.c"
    "${CMAKE_CURRENT_SOURCE_DIR}/tests/extract_audio_core.py")
  execute_process(COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/tests/extract_audio_core.py"
    "${SNESRECOMP_ROOT}/runner/src" "${CMAKE_CURRENT_BINARY_DIR}/audio-core.inc"
    COMMAND_ERROR_IS_FATAL ANY)
  add_executable(ackman_audio_timeline_test tests/test_audio_timeline.c)
  target_include_directories(ackman_audio_timeline_test PRIVATE
    "${SNESRECOMP_ROOT}/runner/src" "${SNESRECOMP_ROOT}/runner/src/desktop" "${CMAKE_CURRENT_BINARY_DIR}")
  snesrecomp_target_sdl(ackman_audio_timeline_test)
  target_compile_options(ackman_audio_timeline_test PRIVATE -UNDEBUG)
  # Keep the audio suite as one CTest, exercising routing and the actual core.
  add_test(NAME audio_routing COMMAND ${CMAKE_COMMAND}
    "-DROUTING=$<TARGET_FILE:ackman_audio_test>"
    "-DTIMELINE=$<TARGET_FILE:ackman_audio_timeline_test>"
    -P "${CMAKE_CURRENT_SOURCE_DIR}/tests/audio_suite.cmake")
else()
  add_test(NAME audio_routing COMMAND ackman_audio_test)
endif()
add_executable(ackman_debug_keys_test tests/test_debug_keys.c src/ackman_debug.c)
target_sources(ackman_debug_keys_test PRIVATE src/recomp_menu_cursor.c src/recomp_menu_checkpoint.c)
target_sources(ackman_debug_keys_test PRIVATE src/recomp_menu_devices.c)
target_include_directories(ackman_debug_keys_test PRIVATE src "${SNESRECOMP_ROOT}/runner/src")
snesrecomp_target_sdl(ackman_debug_keys_test)
add_test(NAME debug_keys COMMAND ackman_debug_keys_test)
if(WIN32 AND CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
  add_executable(ackman_cursor_test tests/test_cursor.c src/recomp_menu_cursor.c)
  target_include_directories(ackman_cursor_test PRIVATE src)
  snesrecomp_target_sdl(ackman_cursor_test)
  target_compile_options(ackman_cursor_test PRIVATE -UNDEBUG)
  target_link_options(ackman_cursor_test PRIVATE -Wl,--wrap=SDL_GetTicks -Wl,--wrap=SDL_WasInit
    -Wl,--wrap=SDL_ShowCursor -Wl,--wrap=SDL_HideCursor -Wl,--wrap=SDL_CursorVisible)
  add_test(NAME cursor_idle_timer COMMAND ackman_cursor_test)
endif()
add_executable(ackman_video_test tests/test_video.c src/ackman_video.c
  "${SNESRECOMP_ROOT}/runner/src/snes_overlay_draw.c"
  "${SNESRECOMP_ROOT}/runner/src/snes_osd.c")
snesrecomp_target_sdl(ackman_video_test)
target_include_directories(ackman_video_test PRIVATE src "${SNESRECOMP_ROOT}/runner/src" "${SNESRECOMP_ROOT}/runner/src/desktop")
add_executable(ackman_rewind_test tests/test_rewind.c "${SNESRECOMP_ROOT}/runner/src/snes_rewind.c")
snesrecomp_target_sdl(ackman_rewind_test)
target_include_directories(ackman_rewind_test PRIVATE src "${SNESRECOMP_ROOT}/runner/src" "${SNESRECOMP_ROOT}/runner/src/desktop")
if(MSVC)
  target_compile_options(ackman_rewind_test PRIVATE /UNDEBUG)
else()
  target_compile_options(ackman_rewind_test PRIVATE -UNDEBUG)
endif()
add_test(NAME video_margins COMMAND ${CMAKE_COMMAND}
  "-DVIDEO=$<TARGET_FILE:ackman_video_test>" "-DREWIND=$<TARGET_FILE:ackman_rewind_test>"
  -P "${CMAKE_CURRENT_SOURCE_DIR}/tests/video_rewind_suite.cmake")
set_tests_properties(video_margins PROPERTIES ENVIRONMENT "ACKMAN_WIDE_EXPERIMENTAL=1;ACKMAN_WIDE_FORCE=1;ACKMAN_VIDEO_TRACE=")

add_executable(ackman_flow_test tests/test_flow.c tests/test_rumble.c src/ackman_flow.c src/ackman_rumble.c)
target_sources(ackman_flow_test PRIVATE src/recomp_menu_devices.c tests/test_devices.c)
if(WIN32 AND CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
  target_compile_definitions(ackman_flow_test PRIVATE ACK_TEST_DEVICE_DELAY=1)
  target_link_options(ackman_flow_test PRIVATE -Wl,--wrap=SDL_OpenGamepad -Wl,--wrap=SDL_CloseGamepad)
endif()
target_include_directories(ackman_flow_test PRIVATE src "${SNESRECOMP_ROOT}/runner/src")
snesrecomp_target_sdl(ackman_flow_test)
if(MSVC)
  target_compile_options(ackman_flow_test PRIVATE /UNDEBUG)
else()
  target_compile_options(ackman_flow_test PRIVATE -UNDEBUG)
endif()
add_test(NAME final_score_reset COMMAND ackman_flow_test)
if(WIN32 AND CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
  add_executable(ackman_menu_test tests/test_menu.c tests/test_menu_imgui.cpp src/ackman_menu.c src/ackman_config.c "${SNESRECOMP_ROOT}/runner/src/desktop/mmx_config.c" "${SNESRECOMP_ROOT}/runner/src/util.c" "${SNESRECOMP_ROOT}/runner/src/snes_osd.c")
  target_sources(ackman_menu_test PRIVATE src/ackman_rumble.c src/ackman_ips.c  "${SNESRECOMP_ROOT}/runner/src/keybinds.c")
  target_sources(ackman_menu_test PRIVATE "${SNESRECOMP_ROOT}/runner/src/crc32.c")
  target_link_libraries(ackman_menu_test PRIVATE recomp_menu_core)
  target_include_directories(ackman_menu_test PRIVATE src "${SNESRECOMP_ROOT}/runner/src")
  snesrecomp_target_sdl(ackman_menu_test)
  target_compile_options(ackman_menu_test PRIVATE -UNDEBUG)
  target_link_options(ackman_menu_test PRIVATE -Wl,--wrap=SDL_ShowOpenFileDialog -Wl,--wrap=SDL_ShowSaveFileDialog -Wl,--wrap=SDL_GetSystemTheme -Wl,--wrap=SDL_GetWindowDisplayScale -Wl,--wrap=SDL_GetGlobalMouseState)
  add_test(NAME menu_persistence COMMAND ackman_menu_test)
  set_tests_properties(menu_persistence PROPERTIES ENVIRONMENT "SDL_VIDEODRIVER=dummy")
  add_executable(ackman_presentation_test tests/test_presentation.c src/ackman_shader.c src/ackman_capture.c
    "${SNESRECOMP_ROOT}/runner/src/util.c" "${SNESRECOMP_ROOT}/third_party/gl_core/gl_core_3_1.c")
  target_include_directories(ackman_presentation_test PRIVATE src "${SNESRECOMP_ROOT}/runner/src")
  snesrecomp_target_sdl(ackman_presentation_test)
  snesrecomp_target_glsl_shader(ackman_presentation_test)
  target_link_libraries(ackman_presentation_test PRIVATE OpenGL::GL ZLIB::ZLIB)
  target_compile_options(ackman_presentation_test PRIVATE -UNDEBUG)
  add_test(NAME menu_sdl_fullscreen COMMAND ${CMAKE_COMMAND}
    "-DMENU=$<TARGET_FILE:ackman_menu_test>" "-DPRESENTATION=$<TARGET_FILE:ackman_presentation_test>"
    -P "${CMAKE_CURRENT_SOURCE_DIR}/tests/menu_native_suite.cmake")
  set_tests_properties(menu_sdl_fullscreen PROPERTIES ENVIRONMENT "SDL_VIDEODRIVER=windows" TIMEOUT 35)
endif()

# Only Open Sans and its license are distributed. System fonts stay on the host.
foreach(font_target AckmanRecomp ackman_menu_test)
  if(TARGET ${font_target})
    add_custom_command(TARGET ${font_target} POST_BUILD
      COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:${font_target}>/assets/fonts"
      COMMAND ${CMAKE_COMMAND} -E copy_if_different
        "${CMAKE_CURRENT_SOURCE_DIR}/assets/fonts/OpenSans-Regular.ttf"
        "${CMAKE_CURRENT_SOURCE_DIR}/assets/fonts/OFL.txt"
        "$<TARGET_FILE_DIR:${font_target}>/assets/fonts")
  endif()
endforeach()
if(TARGET ackman_menu_test)
  add_test(NAME menu_open_sans_fallback COMMAND ackman_menu_test)
  set_tests_properties(menu_open_sans_fallback PROPERTIES ENVIRONMENT "SDL_VIDEODRIVER=dummy;ACKMAN_TEST_FONT_FALLBACK=1")
  add_test(NAME menu_embedded_open_sans COMMAND ackman_menu_test)
  set_tests_properties(menu_embedded_open_sans PROPERTIES ENVIRONMENT "SDL_VIDEODRIVER=dummy;ACKMAN_TEST_FONT_NO_FILES=1")
endif()

endif() # BUILD_TESTING
