cmake_minimum_required(VERSION 3.16)
project(vurus LANGUAGES CXX)
option(VURUS_ACTOR_SYNC_PROFILE "Enable actor synchronization audit counters" OFF)
if(VURUS_ACTOR_SYNC_PROFILE)
  add_compile_definitions(VURUS_ACTOR_SYNC_PROFILE=1)
endif()

# Validation-only reference implementation; normal builds contain no extra bounds index.
option(VURUS_COLLISION_INDEX_ORACLE "Enable the legacy collision-index comparison audit" OFF)
if(VURUS_COLLISION_INDEX_ORACLE)
  add_compile_definitions(VURUS_COLLISION_INDEX_ORACLE=1)
endif()

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Release)
endif()

# x86-64 handheld builds must not pick up glibc 2.43's new math defaults
# merely because the build host is newer than the target device.
option(VYRUZ_GLIBC_COMPAT "Use established x86-64 glibc math symbols" ON)
set(VYRUZ_MAX_GLIBC "2.42" CACHE STRING "Highest allowed direct glibc requirement")
if(VYRUZ_GLIBC_COMPAT AND CMAKE_SYSTEM_NAME STREQUAL "Linux"
   AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64|AMD64)$"
   AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
  add_compile_options(-include "${CMAKE_CURRENT_SOURCE_DIR}/src/platform/glibc_compat.h")
  find_program(VYRUZ_READELF readelf)
  if(NOT VYRUZ_READELF)
    message(FATAL_ERROR "readelf is required for the glibc compatibility check")
  endif()
  set(VYRUZ_CHECK_GLIBC TRUE)
endif()

include(cmake/Platform.cmake)
if(VYRUZ_SDL_SOURCE)
  set(SDL_SHARED OFF CACHE BOOL "" FORCE)
  set(SDL_STATIC ON CACHE BOOL "" FORCE)
  set(SDL_TEST OFF CACHE BOOL "" FORCE)
  set(SDL_TESTS OFF CACHE BOOL "" FORCE)
  set(SDL2_DISABLE_INSTALL ON CACHE BOOL "" FORCE)
  add_subdirectory("${VYRUZ_SDL_SOURCE}" "${CMAKE_BINARY_DIR}/sdl" EXCLUDE_FROM_ALL)
  if(NOT TARGET SDL2::SDL2)
    add_library(SDL2::SDL2 ALIAS SDL2-static)
  endif()
else()
  find_package(SDL2 REQUIRED)
endif()
# Save compression is linked statically in release CI; no extra DLL is shipped.
set(VYRUZ_ZLIB_SOURCE "" CACHE PATH "Optional zlib source tree for static builds")
if(VYRUZ_ZLIB_SOURCE)
  set(ZLIB_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
  add_subdirectory("${VYRUZ_ZLIB_SOURCE}" "${CMAKE_BINARY_DIR}/zlib" EXCLUDE_FROM_ALL)
  add_library(ZLIB::ZLIB ALIAS zlibstatic)
else()
  set(ZLIB_USE_STATIC_LIBS ON)
  find_package(ZLIB REQUIRED)
endif()
# All application/audit targets that compile save_file share this dependency.
link_libraries(ZLIB::ZLIB)
if(VYRUZ_GLES)
  find_library(VYRUZ_GLES_LIBRARY NAMES GLESv2 REQUIRED)
  add_library(vurus_gles STATIC src/render/gles_compat.cpp)
  target_include_directories(vurus_gles PUBLIC src)
  target_link_libraries(vurus_gles PUBLIC "${VYRUZ_GLES_LIBRARY}")
  add_library(OpenGL::GL ALIAS vurus_gles)
else()
  find_package(OpenGL REQUIRED)
endif()
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/render/shaders/mame_psgs.vert" CRT_VERTEX)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/render/shaders/mame_psgs.frag" CRT_FRAGMENT)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/third_party/mame-psgs/LICENSE" CRT_LICENSE)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/render/shaders/scene_effects.vert" SCENE_VERTEX)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/render/shaders/scene_effects.frag" SCENE_FRAGMENT)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS src/render/shaders/scene_effects.vert src/render/shaders/scene_effects.frag src/render/shaders/mame_psgs.vert src/render/shaders/mame_psgs.frag third_party/mame-psgs/LICENSE)
configure_file(src/render/crt_shaders.h.in generated/crt_shaders.h @ONLY)
configure_file(src/render/crt_license.h.in generated/crt_license.h @ONLY)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/third_party/smaa/SMAA.hlsl" SMAA_SOURCE)
# MSVC limits individual string literals; keep shader bytes unchanged in chunks.
string(LENGTH "${SMAA_SOURCE}" _smaa_length)
set(SMAA_SOURCE_CHUNKS "")
set(_smaa_offset 0)
while(_smaa_offset LESS _smaa_length)
  math(EXPR _smaa_remaining "${_smaa_length} - ${_smaa_offset}")
  set(_smaa_count 8000)
  if(_smaa_remaining LESS _smaa_count)
    set(_smaa_count ${_smaa_remaining})
  endif()
  string(SUBSTRING "${SMAA_SOURCE}" ${_smaa_offset} ${_smaa_count} _smaa_chunk)
  string(APPEND SMAA_SOURCE_CHUNKS "R\"SMAASOURCE(${_smaa_chunk})SMAASOURCE\",\n")
  math(EXPR _smaa_offset "${_smaa_offset} + ${_smaa_count}")
endwhile()
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/third_party/smaa/LICENSE.txt" SMAA_LICENSE)
configure_file(src/render/smaa_shader.h.in generated/smaa_shader.h @ONLY)
configure_file(src/render/smaa_license.h.in generated/smaa_license.h @ONLY)
include_directories("${CMAKE_CURRENT_BINARY_DIR}/generated")

include(cmake/Indeo.cmake)

add_executable(vurus
  src/game/controller.cpp
  src/game/options.cpp
  src/game/difficulty.cpp
  src/game/high_scores.cpp
  src/main.cpp
  src/game/save_catalog.cpp
  src/assets/intro_video.cpp
  src/io/disc_import.cpp
  src/io/rsc.cpp
  src/io/vfs.cpp
  src/assets/tga.cpp
  src/assets/wav.cpp
  src/assets/gaf_audio.cpp
  src/audio/mixer.cpp src/audio/wav_stream.cpp
  src/audio/game_audio.cpp
  src/audio/music_playback.cpp
  src/assets/gaf.cpp
  src/assets/content_text.cpp
  src/assets/lzss.cpp
  src/assets/gaf_font.cpp
  src/assets/gaf_sprite.cpp
  src/assets/gob.cpp
  src/game/level.cpp
  src/game/content.cpp
  src/game/controls.cpp
  src/game/world_gates.cpp
  src/game/gates.cpp
  src/game/inventory.cpp
  src/game/menu.cpp
  src/game/hud_stats.cpp
  src/game/radar.cpp
  src/render/level_map.cpp
  src/game/world.cpp src/game/world_awake.cpp src/game/world_pool.cpp src/game/tile_body_native.cpp src/game/tile_body_resources.cpp src/game/world_grenade_contacts.cpp src/game/world_actor_contacts.cpp src/game/world_ammo_damage.cpp src/game/world_ordinary_enemy_ai.cpp src/game/ordinary_enemy_ai_native.cpp src/game/world_spider.cpp src/game/world_spider_navigation.cpp src/game/spider_brain.cpp src/game/native_navigation.cpp src/game/world_guidance.cpp src/game/projectile_guidance.cpp src/game/missile_guidance.cpp
  src/game/world_contacts.cpp
  src/game/world_body_graphics.cpp src/game/world_explosions.cpp src/game/world_projectile_fx.cpp src/game/world_actor_create.cpp src/game/world_codes.cpp src/game/world_held.cpp src/game/world_generators.cpp
  src/game/world_surprise.cpp
  src/game/world_save.cpp
  src/game/save_file.cpp
  src/game/navigation.cpp
  src/game/brain.cpp
  src/game/combat.cpp
  src/game/interactions.cpp
  src/render/hud.cpp
  src/render/loading_screen.cpp
  src/render/gfx.cpp src/render/crt.cpp src/render/smaa.cpp
  src/render/occlusion.cpp
  src/render/animation.cpp
  src/render/scene.cpp
)

target_include_directories(vurus PRIVATE src)
target_link_libraries(vurus PRIVATE SDL2::SDL2 OpenGL::GL indeo)
if(VYRUZ_CHECK_GLIBC)
  set_property(TARGET vurus APPEND PROPERTY LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CheckGlibc.cmake")
  add_custom_command(TARGET vurus POST_BUILD
    COMMAND "${CMAKE_COMMAND}" "-DBINARY=$<TARGET_FILE:vurus>"
      "-DREADELF=${VYRUZ_READELF}" "-DMAX_GLIBC=${VYRUZ_MAX_GLIBC}"
      -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CheckGlibc.cmake"
    VERBATIM)
endif()


if(MSVC)
  target_compile_options(vurus PRIVATE /W4)
else()
  target_compile_options(vurus PRIVATE -Wall -Wextra)
endif()

if(MSVC)
  target_sources(vurus PRIVATE packaging/windows.manifest)
endif()
# The game menu and optional standalone executable use the same benchmark runner.
target_sources(vurus PRIVATE src/benchmark/report.cpp)
set(_benchmark_revision "unversioned")
if(DEFINED ENV{GITHUB_SHA})
  set(_benchmark_revision "$ENV{GITHUB_SHA}")
endif()
set(VURUS_BENCH_BUILD "${_benchmark_revision}" CACHE STRING "Source revision recorded in benchmark reports")
target_compile_definitions(vurus PRIVATE VURUS_BENCH_BUILD="${VURUS_BENCH_BUILD}")
option(VURUS_BUILD_BENCHMARK "Build the standalone performance benchmark" OFF)
if(VURUS_BUILD_BENCHMARK)
  get_target_property(VURUS_BENCH_SOURCES vurus SOURCES)
  list(REMOVE_ITEM VURUS_BENCH_SOURCES src/main.cpp packaging/windows.manifest)
  add_executable(vurus-bench src/benchmark_main.cpp ${VURUS_BENCH_SOURCES})
  target_include_directories(vurus-bench PRIVATE src)
  target_link_libraries(vurus-bench PRIVATE SDL2::SDL2 OpenGL::GL indeo)
  target_compile_definitions(vurus-bench PRIVATE VURUS_BENCH_BUILD="${VURUS_BENCH_BUILD}")
  if(VYRUZ_CHECK_GLIBC)
    add_custom_command(TARGET vurus-bench POST_BUILD
      COMMAND "${CMAKE_COMMAND}" "-DBINARY=$<TARGET_FILE:vurus-bench>"
        "-DREADELF=${VYRUZ_READELF}" "-DMAX_GLIBC=${VYRUZ_MAX_GLIBC}"
        -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CheckGlibc.cmake" VERBATIM)
  endif()
  if(MSVC)
    target_sources(vurus-bench PRIVATE packaging/windows.manifest)
  endif()
endif()

include(cmake/DesktopPackage.cmake)

include(CTest)
if(BUILD_TESTING)
  add_executable(sprite_envelope_test tests/sprite_envelope_test.cpp)
  target_include_directories(sprite_envelope_test PRIVATE src)
  add_test(NAME sprite_envelope COMMAND sprite_envelope_test)
  add_executable(benchmark_report_test tests/benchmark_report_test.cpp src/benchmark/report.cpp)
  target_include_directories(benchmark_report_test PRIVATE src)
  target_compile_options(benchmark_report_test PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,/UNDEBUG,-UNDEBUG>)
  add_test(NAME benchmark_report COMMAND benchmark_report_test)
  add_executable(texture_residency_test tests/texture_residency_test.cpp)
  target_include_directories(texture_residency_test PRIVATE src)
  target_compile_options(texture_residency_test PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,/UNDEBUG,-UNDEBUG>)
  add_test(NAME texture_residency COMMAND texture_residency_test)
  add_executable(hud_layout_test tests/hud_layout_test.cpp)
  target_include_directories(hud_layout_test PRIVATE src)
  add_test(NAME hud_layout COMMAND hud_layout_test)
  add_executable(attached_altitude_test tests/attached_altitude_test.cpp)
  target_include_directories(attached_altitude_test PRIVATE src)
  add_test(NAME attached_altitude COMMAND attached_altitude_test)
  add_executable(voice_schedule_test tests/voice_schedule_test.cpp)
  target_include_directories(voice_schedule_test PRIVATE src)
  add_test(NAME voice_schedule COMMAND voice_schedule_test)
  add_executable(portable_storage_test tests/portable_storage_test.cpp)
  target_include_directories(portable_storage_test PRIVATE src)
  add_test(NAME portable_storage COMMAND portable_storage_test)
  add_executable(motion_contact_test tests/motion_contact_test.cpp)
  target_include_directories(motion_contact_test PRIVATE src)
  add_test(NAME motion_contact COMMAND motion_contact_test)
  add_executable(intro_video_test tests/intro_video_test.cpp src/assets/intro_video.cpp src/assets/wav.cpp)
  target_include_directories(intro_video_test PRIVATE src)
  target_link_libraries(intro_video_test PRIVATE indeo)
  add_test(NAME intro_video COMMAND intro_video_test)
  add_executable(notifications_test tests/notifications_test.cpp)
  target_include_directories(notifications_test PRIVATE src)
  add_test(NAME notifications COMMAND notifications_test)
  # Opt-in real-asset audit: no original assets are required by ordinary CTest.
  add_executable(crt_geometry_test tests/crt_geometry_test.cpp)
  target_include_directories(crt_geometry_test PRIVATE src)
  add_test(NAME crt_geometry COMMAND crt_geometry_test)
  if(VYRUZ_CHECK_GLIBC)
    add_executable(runtime_math_test tests/runtime_math_test.cpp)
    add_test(NAME runtime_math COMMAND runtime_math_test)
    add_test(NAME runtime_glibc COMMAND "${CMAKE_COMMAND}"
      "-DBINARY=$<TARGET_FILE:vurus>" "-DREADELF=${VYRUZ_READELF}"
      "-DMAX_GLIBC=${VYRUZ_MAX_GLIBC}" -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CheckGlibc.cmake")
  endif()
  # Opt-in bootstrap and original-resource audio/UI checks; no assets bundled.
  add_executable(first_run_screen_audit EXCLUDE_FROM_ALL tests/first_run_screen_audit.cpp
    src/game/controller.cpp src/game/controls.cpp src/io/disc_import.cpp src/io/rsc.cpp src/io/vfs.cpp)
  target_include_directories(first_run_screen_audit PRIVATE src)
  target_link_libraries(first_run_screen_audit PRIVATE SDL2::SDL2)
  get_target_property(VURUS_AUDIO_AUDIT_SOURCES vurus SOURCES)
  list(REMOVE_ITEM VURUS_AUDIO_AUDIT_SOURCES src/main.cpp)
  add_library(vurus_audio_audit_core OBJECT EXCLUDE_FROM_ALL ${VURUS_AUDIO_AUDIT_SOURCES})
  target_include_directories(vurus_audio_audit_core PRIVATE src)
  target_link_libraries(vurus_audio_audit_core PRIVATE SDL2::SDL2 OpenGL::GL indeo)
  foreach(audit audio_menu_native_audit audio_pipeline_app_audit)
    add_executable(${audit} EXCLUDE_FROM_ALL tests/${audit}.cpp $<TARGET_OBJECTS:vurus_audio_audit_core>)
    target_include_directories(${audit} PRIVATE src)
    target_link_libraries(${audit} PRIVATE SDL2::SDL2 OpenGL::GL indeo)
  endforeach()
  add_executable(first_run_controller_test tests/first_run_controller_test.cpp src/game/controller.cpp src/game/controls.cpp)
  target_include_directories(first_run_controller_test PRIVATE src)
  target_link_libraries(first_run_controller_test PRIVATE SDL2::SDL2)
  add_test(NAME first_run_controller COMMAND first_run_controller_test)
  add_executable(disc_import_test tests/disc_import_test.cpp src/io/disc_import.cpp src/io/rsc.cpp src/io/vfs.cpp)
  target_include_directories(disc_import_test PRIVATE src)
  find_package(Threads REQUIRED)
  target_link_libraries(disc_import_test PRIVATE Threads::Threads)
  add_test(NAME disc_import COMMAND disc_import_test)
  if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  add_executable(import_reliability_test tests/import_reliability_test.cpp src/io/disc_import.cpp src/io/rsc.cpp src/io/vfs.cpp)
  target_include_directories(import_reliability_test PRIVATE src)
  target_link_options(import_reliability_test PRIVATE -Wl,--wrap=statvfs -Wl,--wrap=fsync)
  add_test(NAME import_reliability COMMAND import_reliability_test)
  endif()
  add_executable(menu_hold_test tests/menu_hold_test.cpp)
  target_include_directories(menu_hold_test PRIVATE src)
  add_test(NAME menu_hold COMMAND menu_hold_test)
  add_executable(controller_test tests/controller_test.cpp src/game/controller.cpp src/game/controls.cpp)
  target_include_directories(controller_test PRIVATE src)
  target_link_libraries(controller_test PRIVATE SDL2::SDL2)
  add_test(NAME controller COMMAND controller_test)
  add_executable(wav_test tests/wav_test.cpp src/assets/wav.cpp)
  target_include_directories(wav_test PRIVATE src)
  add_test(NAME wav COMMAND wav_test)
  add_executable(audio_mixer_test tests/audio_mixer_test.cpp src/audio/mixer.cpp src/audio/wav_stream.cpp)
  target_include_directories(audio_mixer_test PRIVATE src)
  target_link_libraries(audio_mixer_test PRIVATE SDL2::SDL2)
  add_test(NAME audio_mixer COMMAND audio_mixer_test)
  add_executable(audio_pipeline_test tests/audio_pipeline_test.cpp src/audio/mixer.cpp src/audio/wav_stream.cpp)
  target_include_directories(audio_pipeline_test PRIVATE src)
  target_link_libraries(audio_pipeline_test PRIVATE SDL2::SDL2)
  add_test(NAME audio_pipeline COMMAND audio_pipeline_test)
  add_executable(game_audio_test tests/game_audio_test.cpp src/audio/game_audio.cpp src/audio/music_playback.cpp src/audio/mixer.cpp src/audio/wav_stream.cpp src/assets/gaf_audio.cpp src/assets/wav.cpp)
  target_include_directories(game_audio_test PRIVATE src)
  target_link_libraries(game_audio_test PRIVATE SDL2::SDL2)
  add_test(NAME game_audio COMMAND game_audio_test)
  foreach(audio_helper native_audio input_commentary_native weapon_audio_native shield_alarm_native)
    add_executable(${audio_helper}_test tests/${audio_helper}_test.cpp)
    target_include_directories(${audio_helper}_test PRIVATE src)
    add_test(NAME ${audio_helper} COMMAND ${audio_helper}_test)
  endforeach()
  add_executable(full_hud_shield_alarm_native_test tests/full_hud_shield_alarm_native_test.cpp src/render/animation.cpp)
  target_include_directories(full_hud_shield_alarm_native_test PRIVATE src)
  add_test(NAME full_hud_shield_alarm_native COMMAND full_hud_shield_alarm_native_test)
  add_executable(native_audio_mixer_test tests/native_audio_mixer_test.cpp src/audio/mixer.cpp src/audio/wav_stream.cpp)
  target_include_directories(native_audio_mixer_test PRIVATE src)
  target_link_libraries(native_audio_mixer_test PRIVATE SDL2::SDL2)
  add_test(NAME native_audio_mixer COMMAND native_audio_mixer_test)
  add_executable(music_playback_test tests/music_playback_test.cpp src/audio/music_playback.cpp src/audio/mixer.cpp src/audio/wav_stream.cpp src/assets/wav.cpp)
  target_include_directories(music_playback_test PRIVATE src)
  target_link_libraries(music_playback_test PRIVATE SDL2::SDL2)
  add_test(NAME music_playback COMMAND music_playback_test)
  add_executable(gaf_audio_test tests/gaf_audio_test.cpp src/assets/gaf_audio.cpp src/assets/gaf.cpp src/assets/lzss.cpp)
  target_include_directories(gaf_audio_test PRIVATE src)
  add_test(NAME gaf_audio COMMAND gaf_audio_test)
  add_executable(native_graph_pivot_test tests/native_graph_pivot_test.cpp src/game/native_navigation.cpp)
  target_include_directories(native_graph_pivot_test PRIVATE src)
  add_test(NAME native_graph_pivot COMMAND native_graph_pivot_test)
  add_executable(save_file_test tests/save_file_test.cpp src/game/save_file.cpp src/game/native_navigation.cpp src/game/navigation.cpp src/game/level.cpp src/assets/gaf.cpp src/assets/gob.cpp src/assets/lzss.cpp)
  target_include_directories(save_file_test PRIVATE src)
  add_test(NAME save_file COMMAND save_file_test)
  add_executable(hud_stats_test tests/hud_stats_test.cpp src/game/hud_stats.cpp src/game/content.cpp src/assets/content_text.cpp)
  target_include_directories(hud_stats_test PRIVATE src)
  add_test(NAME hud_stats COMMAND hud_stats_test)
  add_executable(presentation_test tests/presentation_test.cpp)
  target_include_directories(presentation_test PRIVATE src)
  add_test(NAME presentation COMMAND presentation_test)
  add_executable(window_mode_contract_test tests/window_mode_contract_test.cpp)
  target_include_directories(window_mode_contract_test PRIVATE src)
  target_link_libraries(window_mode_contract_test PRIVATE SDL2::SDL2)
  add_test(NAME window_mode_contract COMMAND window_mode_contract_test)
  add_executable(window_mode_test tests/window_mode_test.cpp)
  target_include_directories(window_mode_test PRIVATE src)
  target_link_libraries(window_mode_test PRIVATE SDL2::SDL2)
  add_test(NAME window_mode COMMAND window_mode_test)
  set_tests_properties(window_mode PROPERTIES ENVIRONMENT "SDL_VIDEODRIVER=dummy")
  option(VURUS_TEST_X11_MODES "Run display-mode tests with an available Xvfb server" OFF)
  if(VURUS_TEST_X11_MODES)
    find_program(VURUS_XVFB_RUN xvfb-run REQUIRED)
    add_test(NAME window_mode_x11 COMMAND ${VURUS_XVFB_RUN} -a -s "-screen 0 1920x1080x24 -nolisten tcp" $<TARGET_FILE:window_mode_test>)
    set_tests_properties(window_mode_x11 PROPERTIES ENVIRONMENT "SDL_VIDEODRIVER=x11;LIBGL_ALWAYS_SOFTWARE=1;LP_NUM_THREADS=2")
  endif()
  add_executable(options_test tests/options_test.cpp src/game/options.cpp)
  target_include_directories(options_test PRIVATE src)
  add_test(NAME options COMMAND options_test)
  add_executable(menu_test tests/menu_test.cpp src/game/menu.cpp)
  target_include_directories(menu_test PRIVATE src)
  add_test(NAME menu COMMAND menu_test)
  add_executable(map_billing_world_test tests/map_billing_world_test.cpp $<TARGET_OBJECTS:vyruz_world_test_core>)
  target_include_directories(map_billing_world_test PRIVATE src)
  add_test(NAME map_billing_world COMMAND map_billing_world_test)
  add_executable(map_radar_test tests/map_radar_test.cpp src/game/radar.cpp src/render/level_map.cpp src/game/content.cpp src/assets/content_text.cpp)
  target_include_directories(map_radar_test PRIVATE src)
  add_test(NAME map_radar COMMAND map_radar_test)
  add_executable(radar_cache_test tests/radar_cache_test.cpp src/game/radar.cpp src/game/content.cpp src/assets/content_text.cpp)
  target_include_directories(radar_cache_test PRIVATE src)
  add_test(NAME radar_cache COMMAND radar_cache_test)
  add_executable(native_font_text_test tests/native_font_text_test.cpp)
  target_include_directories(native_font_text_test PRIVATE src)
  add_test(NAME native_font_text COMMAND native_font_text_test)
  add_executable(inventory_test tests/inventory_test.cpp src/game/inventory.cpp)
  target_include_directories(inventory_test PRIVATE src)
  add_test(NAME inventory COMMAND inventory_test)
  add_executable(gates_test tests/gates_test.cpp src/game/gates.cpp src/game/content.cpp src/assets/content_text.cpp)
  target_include_directories(gates_test PRIVATE src)
  add_test(NAME gates COMMAND gates_test)
  add_executable(lifts_test tests/lifts_test.cpp src/game/content.cpp src/assets/content_text.cpp)
  target_include_directories(lifts_test PRIVATE src)
  add_test(NAME lifts COMMAND lifts_test)
  add_executable(gaf_font_test tests/gaf_font_test.cpp src/assets/gaf_font.cpp src/assets/gaf.cpp src/assets/lzss.cpp)
  target_include_directories(gaf_font_test PRIVATE src)
  add_test(NAME gaf_font COMMAND gaf_font_test)
  add_executable(interactions_test tests/interactions_test.cpp src/game/interactions.cpp)
  target_include_directories(interactions_test PRIVATE src)
  add_test(NAME interactions COMMAND interactions_test)
  add_executable(combat_test tests/combat_test.cpp src/game/combat.cpp)
  target_include_directories(combat_test PRIVATE src)
  add_test(NAME combat COMMAND combat_test)
  add_executable(ammo_contact_test tests/ammo_contact_test.cpp)
  target_include_directories(ammo_contact_test PRIVATE src)
  add_test(NAME ammo_contact COMMAND ammo_contact_test)
  add_executable(ammo_filter_native_test tests/ammo_filter_native_test.cpp)
  target_include_directories(ammo_filter_native_test PRIVATE src)
  add_test(NAME ammo_filter_native COMMAND ammo_filter_native_test)
  add_executable(ammo_collision_native_test tests/ammo_collision_native_test.cpp)
  target_include_directories(ammo_collision_native_test PRIVATE src)
  add_test(NAME ammo_collision_native COMMAND ammo_collision_native_test)
  add_executable(ammo_radial_native_test tests/ammo_radial_native_test.cpp)
  target_include_directories(ammo_radial_native_test PRIVATE src)
  add_test(NAME ammo_radial_native COMMAND ammo_radial_native_test)
  add_executable(ordinary_enemy_ai_native_test tests/ordinary_enemy_ai_native_test.cpp src/game/ordinary_enemy_ai_native.cpp src/game/native_navigation.cpp)
  target_include_directories(ordinary_enemy_ai_native_test PRIVATE src)
  add_test(NAME ordinary_enemy_ai_native COMMAND ordinary_enemy_ai_native_test)
  foreach(contract health_damage_native ammo_radial_contract_native actor_ammo_contact_native native_actor_cells_original ammo_owner_cells_native ammo_singular_native awake_manager_native native_body_shape_native)
    add_executable(${contract}_test tests/${contract}_test.cpp)
    target_include_directories(${contract}_test PRIVATE src)
    add_test(NAME ${contract} COMMAND ${contract}_test)
  endforeach()
  add_executable(native_initial_graph_native_test tests/native_initial_graph_native_test.cpp src/game/native_navigation.cpp)
  target_include_directories(native_initial_graph_native_test PRIVATE src)
  add_test(NAME native_initial_graph_native COMMAND native_initial_graph_native_test)
  add_executable(native_contact_graph_native_test tests/native_contact_graph_native_test.cpp src/game/native_navigation.cpp)
  target_include_directories(native_contact_graph_native_test PRIVATE src)
  add_test(NAME native_contact_graph_native COMMAND native_contact_graph_native_test)
  add_executable(brain_test tests/brain_test.cpp src/game/brain.cpp src/game/controls.cpp
    src/game/content.cpp src/assets/content_text.cpp)
  target_include_directories(brain_test PRIVATE src)
  add_test(NAME brain COMMAND brain_test)
  add_executable(navigation_test tests/navigation_test.cpp src/game/navigation.cpp src/game/level.cpp
    src/assets/gaf.cpp src/assets/gob.cpp src/assets/lzss.cpp)
  target_include_directories(navigation_test PRIVATE src)
  add_test(NAME navigation COMMAND navigation_test)
  add_executable(world_test tests/world_test.cpp src/game/difficulty.cpp src/game/world_save.cpp src/game/save_file.cpp src/game/hud_stats.cpp src/game/world.cpp src/game/world_awake.cpp src/game/world_pool.cpp src/game/tile_body_native.cpp src/game/tile_body_resources.cpp src/game/world_grenade_contacts.cpp src/game/world_actor_contacts.cpp src/game/world_ammo_damage.cpp src/game/world_ordinary_enemy_ai.cpp src/game/ordinary_enemy_ai_native.cpp src/game/world_spider.cpp src/game/world_spider_navigation.cpp src/game/spider_brain.cpp src/game/native_navigation.cpp src/game/world_guidance.cpp src/game/projectile_guidance.cpp src/game/missile_guidance.cpp src/game/world_contacts.cpp src/game/world_body_graphics.cpp src/game/world_explosions.cpp src/game/world_projectile_fx.cpp src/game/world_actor_create.cpp src/game/world_codes.cpp src/game/world_held.cpp src/game/world_generators.cpp src/render/animation.cpp src/assets/gaf_sprite.cpp src/game/world_surprise.cpp src/game/world_gates.cpp src/game/gates.cpp src/game/navigation.cpp src/game/brain.cpp
    src/game/combat.cpp src/game/interactions.cpp src/game/controls.cpp src/game/content.cpp
    src/game/level.cpp src/assets/content_text.cpp src/assets/gaf.cpp src/assets/gob.cpp src/assets/lzss.cpp)
  get_target_property(VYRUZ_WORLD_TEST_SOURCES world_test SOURCES)
  list(REMOVE_ITEM VYRUZ_WORLD_TEST_SOURCES tests/world_test.cpp)
  # World integration tests share the same production simulation objects.
  # Compile them once so a shared scheduler/header change does not rebuild
  # the entire simulation separately for every fixture.
  add_library(vyruz_world_test_core OBJECT ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(vyruz_world_test_core PRIVATE src)
  set_property(TARGET world_test PROPERTY SOURCES tests/world_test.cpp $<TARGET_OBJECTS:vyruz_world_test_core>)
  set(VYRUZ_WORLD_TEST_SOURCES $<TARGET_OBJECTS:vyruz_world_test_core>)
  add_executable(player_speed_mode_world_test tests/player_speed_mode_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(player_speed_mode_world_test PRIVATE src)
  add_test(NAME player_speed_mode_world COMMAND player_speed_mode_world_test)
  add_executable(panel_help_native_test tests/panel_help_native_test.cpp)
  target_include_directories(panel_help_native_test PRIVATE src)
  add_test(NAME panel_help_native COMMAND panel_help_native_test)
  add_executable(enemy_weapon_readiness_test tests/enemy_weapon_readiness_test.cpp src/game/ordinary_enemy_ai_native.cpp src/game/native_navigation.cpp)
  target_include_directories(enemy_weapon_readiness_test PRIVATE src)
  add_test(NAME enemy_weapon_readiness COMMAND enemy_weapon_readiness_test)
  add_executable(enemy_readiness_resource_audit EXCLUDE_FROM_ALL tests/enemy_readiness_resource_audit.cpp ${VYRUZ_WORLD_TEST_SOURCES} src/io/vfs.cpp src/io/rsc.cpp)
  target_include_directories(enemy_readiness_resource_audit PRIVATE src tests)
  add_executable(enemy_weapon_readiness_world_test tests/enemy_weapon_readiness_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(enemy_weapon_readiness_world_test PRIVATE src)
  add_test(NAME enemy_weapon_readiness_world COMMAND enemy_weapon_readiness_world_test)
  add_executable(spatial_dirty_world_test tests/spatial_dirty_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(spatial_dirty_world_test PRIVATE src)
  add_test(NAME spatial_dirty_world COMMAND spatial_dirty_world_test)
  add_executable(lazy_projectile_publication_test tests/lazy_projectile_publication_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(lazy_projectile_publication_test PRIVATE src)
  add_test(NAME lazy_projectile_publication COMMAND lazy_projectile_publication_test)
  add_executable(gate_sensing_world_test tests/gate_sensing_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(gate_sensing_world_test PRIVATE src)
  add_test(NAME gate_sensing_world COMMAND gate_sensing_world_test)
  add_executable(saving_role_index_test tests/saving_role_index_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(saving_role_index_test PRIVATE src)
  add_test(NAME saving_role_index COMMAND saving_role_index_test)
  add_executable(pickup_candidate_index_test tests/pickup_candidate_index_test.cpp)
  target_include_directories(pickup_candidate_index_test PRIVATE src)
  add_test(NAME pickup_candidate_index COMMAND pickup_candidate_index_test)
  add_executable(navigation_item_cache_test tests/navigation_item_cache_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(navigation_item_cache_test PRIVATE src)
  add_test(NAME navigation_item_cache COMMAND navigation_item_cache_test)
  add_executable(class_name_index_test tests/class_name_index_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(class_name_index_test PRIVATE src)
  add_test(NAME class_name_index COMMAND class_name_index_test)
  add_executable(legacy_navigation_scheduler_test tests/legacy_navigation_scheduler_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(legacy_navigation_scheduler_test PRIVATE src)
  add_test(NAME legacy_navigation_scheduler COMMAND legacy_navigation_scheduler_test)
  # Audio clip bindings are exercised through live World weapon state.
  target_sources(game_audio_test PRIVATE ${VYRUZ_WORLD_TEST_SOURCES})
  add_executable(shield_regeneration_test tests/shield_regeneration_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(shield_regeneration_test PRIVATE src)
  add_test(NAME shield_regeneration COMMAND shield_regeneration_test)
  add_executable(actor_update_camera_test tests/actor_update_camera_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(actor_update_camera_test PRIVATE src)
  add_test(NAME actor_update_camera COMMAND actor_update_camera_test)
  add_executable(weapon_muzzle_test tests/weapon_muzzle_test.cpp ${VYRUZ_WORLD_TEST_SOURCES} src/game/menu.cpp src/io/vfs.cpp src/io/rsc.cpp)
  target_include_directories(weapon_muzzle_test PRIVATE src)
  add_test(NAME weapon_muzzle COMMAND weapon_muzzle_test)
  add_executable(saw_contact_test tests/saw_contact_test.cpp ${VYRUZ_WORLD_TEST_SOURCES} src/game/menu.cpp src/io/vfs.cpp src/io/rsc.cpp)
  target_include_directories(saw_contact_test PRIVATE src)
  add_test(NAME saw_contact COMMAND saw_contact_test)
  add_executable(ammo_absorption_test tests/ammo_absorption_test.cpp ${VYRUZ_WORLD_TEST_SOURCES} src/game/menu.cpp src/io/vfs.cpp src/io/rsc.cpp)
  target_include_directories(ammo_absorption_test PRIVATE src)
  add_test(NAME ammo_absorption COMMAND ammo_absorption_test)
  add_executable(grenade_native_contacts_test tests/grenade_native_contacts_audit.cpp ${VYRUZ_WORLD_TEST_SOURCES} src/game/menu.cpp src/io/vfs.cpp src/io/rsc.cpp)
  target_include_directories(grenade_native_contacts_test PRIVATE src)
  add_test(NAME grenade_native_contacts COMMAND grenade_native_contacts_test)
  add_executable(ammo_lifecycle_world_test tests/ammo_lifecycle_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES} src/game/menu.cpp src/io/vfs.cpp src/io/rsc.cpp)
  target_include_directories(ammo_lifecycle_world_test PRIVATE src)
  add_test(NAME ammo_lifecycle_world COMMAND ammo_lifecycle_world_test)
  add_executable(fx_radial_world_test tests/fx_radial_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(fx_radial_world_test PRIVATE src)
  add_test(NAME fx_radial_world COMMAND fx_radial_world_test)
  add_executable(n3_rng_world_test tests/n3_rng_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(n3_rng_world_test PRIVATE src)
  add_test(NAME n3_rng_world COMMAND n3_rng_world_test)
  add_executable(actor_ammo_continuation_native_test tests/actor_ammo_continuation_native_test.cpp)
  target_include_directories(actor_ammo_continuation_native_test PRIVATE src)
  add_test(NAME actor_ammo_continuation_native COMMAND actor_ammo_continuation_native_test)
  add_executable(transient_record_reuse_test tests/transient_record_reuse_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(transient_record_reuse_test PRIVATE src)
  add_test(NAME transient_record_reuse COMMAND transient_record_reuse_test)
  add_executable(actor_ammo_continuation_world_test tests/actor_ammo_continuation_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(actor_ammo_continuation_world_test PRIVATE src)
  add_test(NAME actor_ammo_continuation_world COMMAND actor_ammo_continuation_world_test)
  add_executable(mine_arming_world_test tests/mine_arming_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES} src/game/menu.cpp src/io/vfs.cpp src/io/rsc.cpp)
  target_include_directories(mine_arming_world_test PRIVATE src)
  add_test(NAME mine_arming_world COMMAND mine_arming_world_test)
  add_executable(touch_contact_world_test tests/touch_contact_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(touch_contact_world_test PRIVATE src)
  add_test(NAME touch_contact_world COMMAND touch_contact_world_test)
  add_executable(enemy_interaction_transitions_world_test tests/enemy_interaction_transitions_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(enemy_interaction_transitions_world_test PRIVATE src)
  add_test(NAME enemy_interaction_transitions_world COMMAND enemy_interaction_transitions_world_test)
  add_executable(generator_occupancy_world_test tests/generator_occupancy_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(generator_occupancy_world_test PRIVATE src)
  add_test(NAME generator_occupancy_world COMMAND generator_occupancy_world_test)
  add_executable(ammo_impact_native_test tests/ammo_impact_native_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(ammo_impact_native_test PRIVATE src)
  add_test(NAME ammo_impact_native COMMAND ammo_impact_native_test)
  add_executable(ammo_hit_order_world_test tests/ammo_hit_order_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES} src/game/menu.cpp src/io/vfs.cpp src/io/rsc.cpp)
  target_include_directories(ammo_hit_order_world_test PRIVATE src)
  add_test(NAME ammo_hit_order_world COMMAND ammo_hit_order_world_test)
  add_executable(actor_ammo_world_handoff_test tests/actor_ammo_world_handoff_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(actor_ammo_world_handoff_test PRIVATE src)
  add_test(NAME actor_ammo_world_handoff COMMAND actor_ammo_world_handoff_test)
  add_executable(actor_ammo_world_query_test tests/actor_ammo_world_query_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(actor_ammo_world_query_test PRIVATE src)
  add_test(NAME actor_ammo_world_query COMMAND actor_ammo_world_query_test)
  add_executable(ordinary_cop_burner_ai_world_test tests/ordinary_cop_burner_ai_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(ordinary_cop_burner_ai_world_test PRIVATE src)
  add_test(NAME ordinary_cop_burner_ai_world COMMAND ordinary_cop_burner_ai_world_test)
  add_executable(burner_turn_command_world_test tests/burner_turn_command_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(burner_turn_command_world_test PRIVATE src)
  add_test(NAME burner_turn_command_world COMMAND burner_turn_command_world_test)
  add_executable(ordinary_jeep_ai_world_test tests/ordinary_jeep_ai_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(ordinary_jeep_ai_world_test PRIVATE src)
  add_test(NAME ordinary_jeep_ai_world COMMAND ordinary_jeep_ai_world_test)
  add_executable(jeep_navigation_precision_world_test tests/jeep_navigation_precision_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(jeep_navigation_precision_world_test PRIVATE src)
  add_test(NAME jeep_navigation_precision_world COMMAND jeep_navigation_precision_world_test)
  add_executable(ordinary_roller_ai_world_test tests/ordinary_roller_ai_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(ordinary_roller_ai_world_test PRIVATE src)
  add_test(NAME ordinary_roller_ai_world COMMAND ordinary_roller_ai_world_test)
  add_executable(ordinary_heli_ai_world_test tests/ordinary_heli_ai_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(ordinary_heli_ai_world_test PRIVATE src)
  add_test(NAME ordinary_heli_ai_world COMMAND ordinary_heli_ai_world_test)
  add_executable(ordinary_remaining_ai_world_test tests/ordinary_remaining_ai_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(ordinary_remaining_ai_world_test PRIVATE src)
  add_test(NAME ordinary_remaining_ai_world COMMAND ordinary_remaining_ai_world_test)
  add_executable(ordinary_tank_route_heading_test tests/ordinary_tank_route_heading_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(ordinary_tank_route_heading_test PRIVATE src)
  add_test(NAME ordinary_tank_route_heading COMMAND ordinary_tank_route_heading_test)
  add_executable(ordinary_enemy_ai_world_test tests/ordinary_enemy_ai_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(ordinary_enemy_ai_world_test PRIVATE src)
  add_test(NAME ordinary_enemy_ai_world COMMAND ordinary_enemy_ai_world_test)
  add_executable(native_projection_cache_test tests/native_projection_cache_test.cpp)
  target_include_directories(native_projection_cache_test PRIVATE src)
  add_test(NAME native_projection_cache COMMAND native_projection_cache_test)
  add_executable(native_projection_cache_world_test tests/native_projection_cache_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(native_projection_cache_world_test PRIVATE src)
  add_test(NAME native_projection_cache_world COMMAND native_projection_cache_world_test)
  add_executable(cop_terrain_corner_test tests/cop_terrain_corner_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(cop_terrain_corner_test PRIVATE src)
  add_test(NAME cop_terrain_corner COMMAND cop_terrain_corner_test)
  add_executable(onhit_fx_test tests/onhit_fx_test.cpp ${VYRUZ_WORLD_TEST_SOURCES} src/game/menu.cpp src/io/vfs.cpp src/io/rsc.cpp)
  target_include_directories(onhit_fx_test PRIVATE src)
  add_test(NAME onhit_fx COMMAND onhit_fx_test)
  add_executable(effect_camera_test tests/effect_camera_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(effect_camera_test PRIVATE src)
  add_test(NAME effect_camera COMMAND effect_camera_test)
  add_executable(enemy_turn_native_test tests/enemy_turn_native_test.cpp)
  target_include_directories(enemy_turn_native_test PRIVATE src)
  add_test(NAME enemy_turn_native COMMAND enemy_turn_native_test)
  add_executable(enemy_turn_world_test tests/enemy_turn_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(enemy_turn_world_test PRIVATE src)
  add_test(NAME enemy_turn_world COMMAND enemy_turn_world_test)
  add_executable(spider_turn_native_test tests/spider_turn_native_test.cpp)
  target_include_directories(spider_turn_native_test PRIVATE src)
  add_test(NAME spider_turn_native COMMAND spider_turn_native_test)
  add_executable(spider_turn_world_test tests/spider_turn_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(spider_turn_world_test PRIVATE src)
  add_test(NAME spider_turn_world COMMAND spider_turn_world_test)
  add_executable(spider_ai_world_test tests/spider_ai_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(spider_ai_world_test PRIVATE src)
  add_test(NAME spider_ai_world COMMAND spider_ai_world_test)
  add_executable(enemy_idle_native_test tests/enemy_idle_native_test.cpp)
  target_include_directories(enemy_idle_native_test PRIVATE src)
  add_test(NAME enemy_idle_native COMMAND enemy_idle_native_test)
  add_executable(enemy_idle_world_test tests/enemy_idle_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(enemy_idle_world_test PRIVATE src)
  add_test(NAME enemy_idle_world COMMAND enemy_idle_world_test)
  add_executable(enemy_aim_test tests/enemy_aim_test.cpp src/game/combat.cpp src/game/controls.cpp)
  target_include_directories(enemy_aim_test PRIVATE src)
  add_test(NAME enemy_aim COMMAND enemy_aim_test)
  foreach(native_check event_random hit_latch player_facing actor_pool)
    add_executable(${native_check}_native_test tests/${native_check}_native_test.cpp)
    target_include_directories(${native_check}_native_test PRIVATE src)
    target_compile_options(${native_check}_native_test PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,/UNDEBUG,-UNDEBUG>)
    add_test(NAME ${native_check}_native COMMAND ${native_check}_native_test)
  endforeach()
  add_executable(tile_body_native_test tests/tile_body_native_test.cpp src/game/tile_body_native.cpp)
  target_include_directories(tile_body_native_test PRIVATE src)
  target_compile_options(tile_body_native_test PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,/UNDEBUG,-UNDEBUG>)
  add_test(NAME tile_body_native COMMAND tile_body_native_test)
  add_executable(ammo_constructor_create_world_test tests/ammo_constructor_create_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(ammo_constructor_create_world_test PRIVATE src)
  add_test(NAME ammo_constructor_create_world COMMAND ammo_constructor_create_world_test)
  add_executable(world_pool_context_test tests/world_pool_context_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(world_pool_context_test PRIVATE src)
  add_test(NAME world_pool_context COMMAND world_pool_context_test)
  add_executable(hit_latch_world_test tests/hit_latch_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(hit_latch_world_test PRIVATE src)
  add_test(NAME hit_latch_world COMMAND hit_latch_world_test)
  add_executable(attached_protection_world_test tests/attached_protection_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(attached_protection_world_test PRIVATE src)
  add_test(NAME attached_protection_world COMMAND attached_protection_world_test)
  add_executable(awake_scheduler_world_test tests/awake_scheduler_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(awake_scheduler_world_test PRIVATE src)
  add_test(NAME awake_scheduler_world COMMAND awake_scheduler_world_test)
  add_executable(surprise_event_rng_world_test tests/surprise_event_rng_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(surprise_event_rng_world_test PRIVATE src)
  add_test(NAME surprise_event_rng_world COMMAND surprise_event_rng_world_test)
  add_executable(death_drop_test tests/death_drop_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(death_drop_test PRIVATE src)
  add_test(NAME death_drop COMMAND death_drop_test)
  add_executable(generator_test tests/generator_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(generator_test PRIVATE src)
  add_test(NAME generator COMMAND generator_test)

  add_executable(generator_native_world_test tests/generator_native_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(generator_native_world_test PRIVATE src)
  add_test(NAME generator_native_world COMMAND generator_native_world_test)
  add_executable(timed_code_test tests/timed_code_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(timed_code_test PRIVATE src)
  add_test(NAME timed_code COMMAND timed_code_test)
  add_executable(explosion_test tests/explosion_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(explosion_test PRIVATE src)
  add_test(NAME explosion COMMAND explosion_test)
  add_executable(surprise_test tests/surprise_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(surprise_test PRIVATE src)
  add_test(NAME surprise COMMAND surprise_test)
  add_executable(difficulty_test tests/difficulty_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(difficulty_test PRIVATE src)
  add_test(NAME difficulty COMMAND difficulty_test)
  target_include_directories(world_test PRIVATE src)
  add_test(NAME world COMMAND world_test)
  add_executable(gaf_sprite_test tests/gaf_sprite_test.cpp src/assets/gaf_sprite.cpp
    src/assets/gaf.cpp src/assets/lzss.cpp)
  target_include_directories(gaf_sprite_test PRIVATE src)
  add_test(NAME gaf_sprite COMMAND gaf_sprite_test)
  add_executable(sprite_filter_test tests/sprite_filter_test.cpp)
  target_include_directories(sprite_filter_test PRIVATE src)
  add_test(NAME sprite_filter COMMAND sprite_filter_test)
  add_executable(sprite_properties_test tests/sprite_properties_test.cpp
    src/game/content.cpp src/assets/content_text.cpp)
  target_include_directories(sprite_properties_test PRIVATE src)
  add_test(NAME sprite_properties COMMAND sprite_properties_test)
  add_executable(sprite_reachability_test tests/sprite_reachability_test.cpp
    src/game/content.cpp src/assets/content_text.cpp)
  target_include_directories(sprite_reachability_test PRIVATE src)
  add_test(NAME sprite_reachability COMMAND sprite_reachability_test)

  add_executable(animation_test tests/animation_test.cpp src/render/animation.cpp)
  target_include_directories(animation_test PRIVATE src)
  add_test(NAME animation COMMAND animation_test)
  add_executable(controls_test tests/controls_test.cpp src/game/controls.cpp)
  target_include_directories(controls_test PRIVATE src)
  add_test(NAME controls COMMAND controls_test)

  add_executable(terrain_test tests/terrain_test.cpp src/game/level.cpp
    src/assets/gaf.cpp src/assets/gob.cpp src/assets/lzss.cpp)
  target_include_directories(terrain_test PRIVATE src)
  add_test(NAME terrain COMMAND terrain_test)

  add_executable(occlusion_test tests/occlusion_test.cpp src/render/occlusion.cpp)
  target_include_directories(occlusion_test PRIVATE src)
  add_test(NAME occlusion COMMAND occlusion_test)

  add_executable(content_text_test tests/content_text_test.cpp src/assets/content_text.cpp)
  target_include_directories(content_text_test PRIVATE src)
  add_test(NAME content_text COMMAND content_text_test)

  add_executable(content_test tests/content_test.cpp src/game/content.cpp src/assets/content_text.cpp)
  target_include_directories(content_test PRIVATE src)
  add_test(NAME content COMMAND content_test)
  add_executable(enemy_behavior_test tests/enemy_behavior_test.cpp src/game/content.cpp src/assets/content_text.cpp src/game/brain.cpp src/game/controls.cpp)
  target_include_directories(enemy_behavior_test PRIVATE src)
  add_test(NAME enemy_behavior COMMAND enemy_behavior_test)
endif()

if(BUILD_TESTING)
  add_executable(fire_death_test tests/fire_death_test.cpp ${VYRUZ_WORLD_TEST_SOURCES} src/io/vfs.cpp src/io/rsc.cpp)
  target_include_directories(fire_death_test PRIVATE src)
  add_test(NAME fire_death COMMAND fire_death_test)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
  add_executable(held_items_test tests/held_items_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(held_items_test PRIVATE src)
  add_test(NAME held_items COMMAND held_items_test)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
  add_executable(actor_create_test tests/actor_create_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(actor_create_test PRIVATE src)
  add_test(NAME actor_create COMMAND actor_create_test)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
  add_executable(spider_brain_test tests/spider_brain_test.cpp src/game/spider_brain.cpp)
  target_include_directories(spider_brain_test PRIVATE src)
  add_test(NAME spider_brain COMMAND spider_brain_test)
  add_executable(native_navigation_test tests/native_navigation_test.cpp src/game/native_navigation.cpp)
  target_include_directories(native_navigation_test PRIVATE src)
  add_test(NAME native_navigation COMMAND native_navigation_test)
  add_executable(native_graph_coordinate_cache_test tests/native_graph_coordinate_cache_test.cpp src/game/native_navigation.cpp)
  target_include_directories(native_graph_coordinate_cache_test PRIVATE src)
  add_test(NAME native_graph_coordinate_cache COMMAND native_graph_coordinate_cache_test)
  add_executable(native_insertion_hint_test tests/native_insertion_hint_test.cpp src/game/native_navigation.cpp)
  target_include_directories(native_insertion_hint_test PRIVATE src)
  add_test(NAME native_insertion_hint COMMAND native_insertion_hint_test)
  add_executable(missile_native_navigation_test tests/missile_native_navigation_test.cpp src/game/native_navigation.cpp)
  target_include_directories(missile_native_navigation_test PRIVATE src)
  add_test(NAME missile_native_navigation COMMAND missile_native_navigation_test)
  add_executable(spider_contact_native_test tests/spider_contact_native_test.cpp src/game/controls.cpp)
  target_include_directories(spider_contact_native_test PRIVATE src)
  add_test(NAME spider_contact_native COMMAND spider_contact_native_test)
  add_executable(actor_contact_native_test tests/actor_contact_native_test.cpp src/game/controls.cpp)
  target_include_directories(actor_contact_native_test PRIVATE src)
  add_test(NAME actor_contact_native COMMAND actor_contact_native_test)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
  add_executable(turret_death_test tests/turret_death_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(turret_death_test PRIVATE src)
  add_test(NAME turret_death COMMAND turret_death_test)
  add_executable(tank_death_test tests/tank_death_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(tank_death_test PRIVATE src)
  add_test(NAME tank_death COMMAND tank_death_test)
  add_executable(combat_bonus_test tests/combat_bonus_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(combat_bonus_test PRIVATE src)
  add_test(NAME combat_bonus COMMAND combat_bonus_test)
  add_executable(audio_events_test tests/audio_events_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(audio_events_test PRIVATE src)
  add_test(NAME audio_events COMMAND audio_events_test)
  add_executable(pinball_contact_world_test tests/pinball_contact_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(pinball_contact_world_test PRIVATE src)
  add_test(NAME pinball_contact_world COMMAND pinball_contact_world_test)
  add_executable(audio_precision_world_test tests/audio_precision_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(audio_precision_world_test PRIVATE src)
  add_test(NAME audio_precision_world COMMAND audio_precision_world_test)
  add_executable(projectile_guidance_test tests/projectile_guidance_test.cpp src/game/projectile_guidance.cpp src/game/controls.cpp)
  target_include_directories(projectile_guidance_test PRIVATE src)
  add_test(NAME projectile_guidance COMMAND projectile_guidance_test)
  add_executable(guidance_order_world_test tests/guidance_order_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(guidance_order_world_test PRIVATE src)
  add_test(NAME guidance_order_world COMMAND guidance_order_world_test)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
  add_executable(demo_world_test tests/demo_world_test.cpp)
  target_include_directories(demo_world_test PRIVATE src)
  target_link_libraries(demo_world_test PRIVATE vyruz_world_test_core)
  add_test(NAME demo_world COMMAND demo_world_test)
  add_executable(demo_replay_test tests/demo_replay_test.cpp)
  target_include_directories(demo_replay_test PRIVATE src)
  add_test(NAME demo_replay COMMAND demo_replay_test)
endif()

if(BUILD_TESTING)
  add_executable(high_scores_test tests/high_scores_test.cpp src/game/high_scores.cpp)
  target_include_directories(high_scores_test PRIVATE src)
  add_test(NAME high_scores COMMAND high_scores_test)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
  add_executable(player_circular_turn_test tests/player_circular_turn_test.cpp)
  target_include_directories(player_circular_turn_test PRIVATE src)
  add_test(NAME player_circular_turn COMMAND player_circular_turn_test)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
  add_executable(menu_effects_test tests/menu_effects_test.cpp src/render/animation.cpp)
  target_include_directories(menu_effects_test PRIVATE src)
  target_compile_options(menu_effects_test PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,/UNDEBUG,-UNDEBUG>)
  add_test(NAME menu_effects COMMAND menu_effects_test)
endif()

if(BUILD_TESTING)
  add_executable(enemy_motion_test tests/enemy_motion_test.cpp src/game/controls.cpp)
  target_include_directories(enemy_motion_test PRIVATE src)
  add_test(NAME enemy_motion COMMAND enemy_motion_test)
endif()

if(BUILD_TESTING)
endif()
if(BUILD_TESTING)
endif()
if(BUILD_TESTING)
  add_executable(missile_guidance_test tests/missile_guidance_test.cpp src/game/missile_guidance.cpp)
  target_include_directories(missile_guidance_test PRIVATE src)
  add_test(NAME missile_guidance COMMAND missile_guidance_test)
endif()

if(BUILD_TESTING)
  add_executable(save_catalog_test tests/save_catalog_test.cpp src/game/save_catalog.cpp src/game/save_file.cpp src/game/navigation.cpp src/game/level.cpp src/assets/gaf.cpp src/assets/gob.cpp src/assets/lzss.cpp)
  target_include_directories(save_catalog_test PRIVATE src)
  if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
    target_link_options(save_catalog_test PRIVATE -Wl,--wrap=syscall)
  endif()
  add_test(NAME save_catalog COMMAND save_catalog_test)
endif()
if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING)
endif()

if(BUILD_TESTING AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
  # Exercise the descriptor-relative non-/proc path used by macOS on Linux too.
  add_executable(save_catalog_portable_test tests/save_catalog_test.cpp src/game/save_catalog.cpp src/game/save_file.cpp src/game/navigation.cpp src/game/level.cpp src/assets/gaf.cpp src/assets/gob.cpp src/assets/lzss.cpp)
  target_include_directories(save_catalog_portable_test PRIVATE src)
  target_compile_definitions(save_catalog_portable_test PRIVATE VYRUZ_PORTABLE_POSIX_FILES=1)
  target_link_options(save_catalog_portable_test PRIVATE -Wl,--wrap=syscall)
  add_test(NAME save_catalog_portable COMMAND save_catalog_portable_test)
endif()

if(BUILD_TESTING)
  add_executable(platform_files_test tests/platform_files_test.cpp)
  target_include_directories(platform_files_test PRIVATE src)
  add_test(NAME platform_files COMMAND platform_files_test)
endif()

if(BUILD_TESTING)
  add_executable(aim_assist_test tests/aim_assist_test.cpp)
  target_include_directories(aim_assist_test PRIVATE src)
  add_test(NAME aim_assist COMMAND aim_assist_test)
endif()
if(BUILD_TESTING)
  add_executable(tile_atlas_test tests/tile_atlas_test.cpp)
  target_include_directories(tile_atlas_test PRIVATE src)
  add_test(NAME tile_atlas COMMAND tile_atlas_test)
endif()

if(BUILD_TESTING)
  add_executable(save_compression_test tests/save_compression_test.cpp src/game/save_file.cpp src/game/navigation.cpp src/game/level.cpp src/assets/gaf.cpp src/assets/gob.cpp src/assets/lzss.cpp)
  target_include_directories(save_compression_test PRIVATE src)
  add_test(NAME save_compression COMMAND save_compression_test)
endif()

# Opt-in real-GL check; ordinary unit tests do not require a graphics driver.
if(BUILD_TESTING)
  add_executable(render_backend_test EXCLUDE_FROM_ALL tests/render_backend_test.cpp src/render/gfx.cpp src/render/crt.cpp src/render/smaa.cpp)
  target_include_directories(render_backend_test PRIVATE src)
  target_link_libraries(render_backend_test PRIVATE SDL2::SDL2 OpenGL::GL)
endif()

if(BUILD_TESTING)
  add_executable(process_memory_test tests/process_memory_test.cpp)
  target_include_directories(process_memory_test PRIVATE src)
  add_test(NAME process_memory COMMAND process_memory_test)
endif()

if(BUILD_TESTING)
  add_executable(wav_stream_test tests/wav_stream_test.cpp src/audio/wav_stream.cpp src/audio/mixer.cpp src/audio/music_playback.cpp)
  target_include_directories(wav_stream_test PRIVATE src)
  target_link_libraries(wav_stream_test PRIVATE SDL2::SDL2)
  add_test(NAME wav_stream COMMAND wav_stream_test)
endif()

# Opt-in native animation and synchronization audit; uses user-supplied data.
if(BUILD_TESTING)
  get_target_property(VYRUZ_PHASE_AUDIT_SOURCES vurus SOURCES)
  list(REMOVE_ITEM VYRUZ_PHASE_AUDIT_SOURCES src/main.cpp)
  add_executable(enemy_animation_phase_audit EXCLUDE_FROM_ALL
    tests/enemy_animation_phase_audit.cpp ${VYRUZ_PHASE_AUDIT_SOURCES})
  target_include_directories(enemy_animation_phase_audit PRIVATE src)
  target_link_libraries(enemy_animation_phase_audit PRIVATE SDL2::SDL2 OpenGL::GL indeo)
  add_executable(spider_animation_clock_audit EXCLUDE_FROM_ALL
    tests/spider_animation_clock_audit.cpp ${VYRUZ_PHASE_AUDIT_SOURCES})
  target_include_directories(spider_animation_clock_audit PRIVATE src)
  target_link_libraries(spider_animation_clock_audit PRIVATE SDL2::SDL2 OpenGL::GL indeo)
endif()

# Opt-in App save/browser checks; require the user's original game resources.
if(BUILD_TESTING)
  add_library(vyruz_save_audit_core OBJECT EXCLUDE_FROM_ALL ${VYRUZ_PHASE_AUDIT_SOURCES})
  target_include_directories(vyruz_save_audit_core PRIVATE src)
  target_link_libraries(vyruz_save_audit_core PRIVATE SDL2::SDL2 OpenGL::GL indeo)
  foreach(audit IN ITEMS save_browser_audit save_async_audit transition_audio_audit pause_redraw_audit)
    add_executable(${audit} EXCLUDE_FROM_ALL tests/${audit}.cpp $<TARGET_OBJECTS:vyruz_save_audit_core>)
    target_include_directories(${audit} PRIVATE src)
    target_link_libraries(${audit} PRIVATE SDL2::SDL2 OpenGL::GL indeo)
  endforeach()
endif()

if(BUILD_TESTING)
  add_executable(cop_navigation_world_test tests/cop_navigation_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(cop_navigation_world_test PRIVATE src)
  add_test(NAME cop_navigation_query COMMAND cop_navigation_world_test query)
  add_test(NAME cop_navigation_corridor COMMAND cop_navigation_world_test corridor)
  add_test(NAME cop_navigation_heading COMMAND cop_navigation_world_test heading)
  add_executable(walker_navigation_world_test tests/walker_navigation_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(walker_navigation_world_test PRIVATE src)
  add_test(NAME walker_navigation_heading COMMAND walker_navigation_world_test heading)
  add_test(NAME walker_navigation_query COMMAND walker_navigation_world_test query)
endif()

if(BUILD_TESTING)
  add_executable(spider_navigation_graph_test tests/spider_navigation_graph_test.cpp src/game/native_navigation.cpp)
  target_include_directories(spider_navigation_graph_test PRIVATE src)
  add_test(NAME spider_navigation_graph COMMAND spider_navigation_graph_test)
  add_executable(spider_navigation_patrol_test tests/spider_navigation_patrol_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(spider_navigation_patrol_test PRIVATE src)
  add_test(NAME spider_navigation_patrol COMMAND spider_navigation_patrol_test)
  add_executable(spider_navigation_player_test tests/spider_navigation_player_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(spider_navigation_player_test PRIVATE src)
  add_test(NAME spider_navigation_player COMMAND spider_navigation_player_test)
endif()

if(BUILD_TESTING)
  add_executable(native_render_cells_test tests/native_render_cells_test.cpp)
  target_include_directories(native_render_cells_test PRIVATE src)
  add_test(NAME native_render_cells COMMAND native_render_cells_test)
  # Opt-in real-resource camera, audio and save/reload regression probe.
  add_executable(native_cell_camera_audit EXCLUDE_FROM_ALL tests/native_cell_camera_audit.cpp $<TARGET_OBJECTS:vyruz_save_audit_core>)
  target_include_directories(native_cell_camera_audit PRIVATE src)
  target_link_libraries(native_cell_camera_audit PRIVATE SDL2::SDL2 OpenGL::GL indeo)
endif()

if(BUILD_TESTING)
  foreach(contract projectile_contact_world ammo_point_contact_native native_cell_collision_coverage)
    if(contract STREQUAL "ammo_point_contact_native")
      add_executable(${contract}_test tests/${contract}_test.cpp)
    else()
      add_executable(${contract}_test tests/${contract}_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
    endif()
    target_include_directories(${contract}_test PRIVATE src)
    add_test(NAME ${contract} COMMAND ${contract}_test)
  endforeach()
  if(VURUS_COLLISION_INDEX_ORACLE)
    add_executable(collision_index_equivalence_audit EXCLUDE_FROM_ALL
      tests/collision_index_equivalence_audit.cpp $<TARGET_OBJECTS:vyruz_save_audit_core>)
    target_include_directories(collision_index_equivalence_audit PRIVATE src)
    target_link_libraries(collision_index_equivalence_audit PRIVATE SDL2::SDL2 OpenGL::GL indeo)
  endif()
endif()

if(BUILD_TESTING AND VURUS_ACTOR_SYNC_PROFILE)
  add_executable(actor_channel_sync_audit EXCLUDE_FROM_ALL tests/actor_channel_sync_audit.cpp $<TARGET_OBJECTS:vyruz_save_audit_core>)
  target_include_directories(actor_channel_sync_audit PRIVATE src)
  target_link_libraries(actor_channel_sync_audit PRIVATE SDL2::SDL2 OpenGL::GL indeo)
endif()

# Original-resource animation audits: opt-in; require tester-supplied game data.
if(BUILD_TESTING)
  add_executable(item_animation_phase_audit EXCLUDE_FROM_ALL tests/item_animation_phase_audit.cpp $<TARGET_OBJECTS:vyruz_save_audit_core>)
  target_include_directories(item_animation_phase_audit PRIVATE src)
  target_link_libraries(item_animation_phase_audit PRIVATE SDL2::SDL2 OpenGL::GL indeo)
  if(VURUS_ACTOR_SYNC_PROFILE)
    add_executable(item_animation_gameplay_audit EXCLUDE_FROM_ALL tests/item_animation_gameplay_audit.cpp $<TARGET_OBJECTS:vyruz_save_audit_core>)
    target_include_directories(item_animation_gameplay_audit PRIVATE src)
    target_link_libraries(item_animation_gameplay_audit PRIVATE SDL2::SDL2 OpenGL::GL indeo)
  endif()
endif()

if(BUILD_TESTING)
  add_executable(player_collision_native_world_test tests/player_collision_native_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(player_collision_native_world_test PRIVATE src)
  target_link_libraries(player_collision_native_world_test PRIVATE ZLIB::ZLIB)
  add_test(NAME player_collision_native_world COMMAND player_collision_native_world_test)
endif()

if(BUILD_TESTING)
  add_executable(player_contact_native_test tests/player_contact_native_test.cpp src/game/controls.cpp src/game/native_navigation.cpp)
  target_include_directories(player_contact_native_test PRIVATE src)
  add_test(NAME player_contact_native COMMAND player_contact_native_test)
endif()

# Circular emitter ammo/completion controls exercise the live World path.
if(BUILD_TESTING)
  add_executable(circular_ammo_world_test tests/circular_ammo_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(circular_ammo_world_test PRIVATE src)
  add_test(NAME circular_ammo_world COMMAND circular_ammo_world_test)
endif()

# Triple emitter stock/order regression and optional original-resource visual check.
if(BUILD_TESTING)
  add_executable(triple_ammo_world_test tests/triple_ammo_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(triple_ammo_world_test PRIVATE src)
  add_test(NAME triple_ammo_world COMMAND triple_ammo_world_test)
  add_executable(triple_visual_audit EXCLUDE_FROM_ALL
    tests/triple_visual_audit.cpp $<TARGET_OBJECTS:vyruz_save_audit_core>)
  target_include_directories(triple_visual_audit PRIVATE src)
  target_link_libraries(triple_visual_audit PRIVATE SDL2::SDL2 OpenGL::GL indeo)
endif()

if(BUILD_TESTING)
  add_executable(shared_sample_audio_test tests/shared_sample_audio_test.cpp $<TARGET_OBJECTS:vyruz_save_audit_core>)
  target_include_directories(shared_sample_audio_test PRIVATE src)
  target_link_libraries(shared_sample_audio_test PRIVATE SDL2::SDL2 OpenGL::GL indeo)
  add_test(NAME shared_sample_audio COMMAND shared_sample_audio_test)
endif()

if(BUILD_TESTING)
  add_executable(contact_create_world_test tests/contact_create_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(contact_create_world_test PRIVATE src)
  target_link_libraries(contact_create_world_test PRIVATE ZLIB::ZLIB)
  add_test(NAME contact_create_world COMMAND contact_create_world_test)
endif()

if(BUILD_TESTING)
  add_executable(native_body_graphics_test tests/native_body_graphics_test.cpp src/render/animation.cpp)
  target_include_directories(native_body_graphics_test PRIVATE src)
  add_test(NAME native_body_graphics COMMAND native_body_graphics_test)
  add_executable(native_body_graphics_world_test tests/native_body_graphics_world_test.cpp ${VYRUZ_WORLD_TEST_SOURCES})
  target_include_directories(native_body_graphics_world_test PRIVATE src tests)
  add_test(NAME native_body_graphics_world COMMAND native_body_graphics_world_test)
  add_executable(body_graphics_resource_audit EXCLUDE_FROM_ALL tests/body_graphics_resource_audit.cpp ${VYRUZ_WORLD_TEST_SOURCES} src/io/vfs.cpp src/io/rsc.cpp src/game/menu.cpp)
  target_include_directories(body_graphics_resource_audit PRIVATE src tests)
  add_executable(debug_commander_audit EXCLUDE_FROM_ALL tests/debug_commander_audit.cpp $<TARGET_OBJECTS:vyruz_save_audit_core>)
  target_include_directories(debug_commander_audit PRIVATE src)
  target_link_libraries(debug_commander_audit PRIVATE SDL2::SDL2 OpenGL::GL indeo)
  add_executable(native_body_graphics_app_audit EXCLUDE_FROM_ALL tests/native_body_graphics_app_audit.cpp $<TARGET_OBJECTS:vyruz_save_audit_core>)
  target_include_directories(native_body_graphics_app_audit PRIVATE src tests)
  target_link_libraries(native_body_graphics_app_audit PRIVATE SDL2::SDL2 OpenGL::GL indeo)
endif()
