cmake_minimum_required(VERSION 3.20)
project(ssa_native_core VERSION 0.8.0 LANGUAGES C)
add_library(ssa_settings STATIC src/settings.c)
target_include_directories(ssa_settings PUBLIC include)
target_compile_features(ssa_settings PUBLIC c_std_11)
add_library(ssa_soundfont STATIC src/audio/soundfont.c)
target_include_directories(ssa_soundfont PUBLIC include)
target_compile_features(ssa_soundfont PUBLIC c_std_11)
if(NOT MSVC)
    target_link_libraries(ssa_soundfont PUBLIC m)
endif()

# Recovered native subsystems and a geometry viewer; the game port is incomplete.
add_library(ssa_input STATIC src/input.c)
add_library(ssa_profile STATIC src/profile.c)
target_compile_features(ssa_profile PUBLIC c_std_11)
target_include_directories(ssa_profile PUBLIC include)
target_link_libraries(ssa_profile PUBLIC ssa_settings)
add_library(ssa_movement STATIC src/movement.c)
add_library(ssa_physics STATIC src/physics.c)
add_library(ssa_map_assets STATIC src/map_assets.c)
add_library(ssa_geometry STATIC src/geometry.c)
add_library(ssa_view STATIC src/view.c)
add_library(ssa_world STATIC src/world.c)
add_library(ssa_horizontal STATIC src/horizontal.c)
add_library(ssa_slide STATIC src/slide.c)
add_library(ssa_inventory STATIC src/inventory.c)
add_library(ssa_pickup STATIC src/pickup.c)
add_library(ssa_spawn STATIC src/spawn.c)
add_library(ssa_weapon_select STATIC src/weapon_select.c)
foreach(SSA_PLAYER_COMPONENT entity_timer player_spawn player_motion player_frame player_runtime
        respawn_select player_lifecycle player_hazards player_gameplay
        switches sector_movers level_script level_runtime entity_pool enemy_activation script_spawn
        enemy_motion enemy_navigation enemy_lifecycle enemy_cd enemy_cd_runtime
        enemy_targeting ray_traversal ray_intercepts enemy_ray enemy_queries
        combat_damage combat_explosion combat_rewards combat_runtime
        weapon_animation weapon_controller weapon_aim weapon_hit weapon_runtime
        projectile_create projectile_motion projectile_controller projectile_bounce projectile_effect projectile_runtime
        entity_dispatch entity_runtime weapon_loadout weapon_progress statistics native_statistics completion native_completion pause intermission campaign_story campaign_screen netricsa
        frame sprite_dispatch actor_animation actor_animation_runtime
        pickup_respawn pickup_respawn_runtime game_runtime
        input_dispatch pc_input pc_input_runtime sprite_assets mode_control raster_fill
        texture_assets map_texture_bindings world_raster render_view
        plane_renderer world_visibility wall_renderer world_scene
        map_actors actor_assets actor_raster actor_queue actor_projection actor_scene
        sprite_oam sprite_cache sprite_pool hud_sprites hud_notice display hud_scene palette_effect
        enemy_control enemy_ranged enemy_boss enemy_control_runtime particle_create projectile_target pickup_runtime projectile_extended sector_clip pc_renderer audio map_view menu)
    add_library(ssa_${SSA_PLAYER_COMPONENT} STATIC src/${SSA_PLAYER_COMPONENT}.c)
    target_include_directories(ssa_${SSA_PLAYER_COMPONENT} PUBLIC include)
    target_compile_features(ssa_${SSA_PLAYER_COMPONENT} PUBLIC c_std_11)
    if(MSVC)
        target_compile_options(ssa_${SSA_PLAYER_COMPONENT} PRIVATE /W4)
    else()
        target_compile_options(ssa_${SSA_PLAYER_COMPONENT} PRIVATE -Wall -Wextra -Wpedantic -Werror)
    endif()
endforeach()
target_link_libraries(ssa_map_view PUBLIC ssa_map_assets)
target_link_libraries(ssa_audio PUBLIC ssa_soundfont)
target_link_libraries(ssa_menu PUBLIC ssa_map_view)
target_link_libraries(ssa_player_motion PUBLIC ssa_world)
target_link_libraries(ssa_player_spawn PUBLIC ssa_player_motion)
target_link_libraries(ssa_player_frame PUBLIC ssa_world)
target_link_libraries(ssa_player_runtime PUBLIC ssa_player_spawn ssa_player_frame ssa_view)
target_link_libraries(ssa_respawn_select PUBLIC ssa_spawn ssa_movement)
target_link_libraries(ssa_player_lifecycle PUBLIC ssa_player_spawn ssa_player_frame ssa_weapon_select)
target_link_libraries(ssa_player_hazards PUBLIC ssa_world ssa_inventory)
target_link_libraries(ssa_player_gameplay PUBLIC ssa_player_runtime ssa_player_lifecycle
    ssa_player_hazards ssa_respawn_select)
target_link_libraries(ssa_switches PUBLIC ssa_map_assets)
target_link_libraries(ssa_sector_movers PUBLIC ssa_map_assets)
target_link_libraries(ssa_level_runtime PUBLIC ssa_player_gameplay ssa_switches
    ssa_sector_movers ssa_level_script)

target_link_libraries(ssa_enemy_activation PUBLIC ssa_world ssa_entity_timer)

target_link_libraries(ssa_script_spawn PUBLIC ssa_level_runtime ssa_entity_pool ssa_enemy_activation)

target_link_libraries(ssa_enemy_motion PUBLIC ssa_player_hazards ssa_world ssa_physics ssa_movement)
target_link_libraries(ssa_enemy_navigation PUBLIC ssa_world ssa_movement)
target_link_libraries(ssa_enemy_lifecycle PUBLIC ssa_enemy_activation)
target_link_libraries(ssa_enemy_cd PUBLIC ssa_enemy_navigation ssa_enemy_lifecycle ssa_enemy_motion)
target_link_libraries(ssa_enemy_cd_runtime PUBLIC ssa_enemy_cd ssa_script_spawn)
target_link_libraries(ssa_enemy_control PUBLIC ssa_enemy_navigation ssa_enemy_lifecycle ssa_enemy_motion)
target_link_libraries(ssa_enemy_ranged PUBLIC ssa_enemy_control)
target_link_libraries(ssa_enemy_boss PUBLIC ssa_enemy_control ssa_projectile_create ssa_slide)
target_link_libraries(ssa_enemy_control_runtime PUBLIC ssa_enemy_control ssa_enemy_ranged ssa_enemy_boss
    ssa_enemy_queries ssa_projectile_runtime ssa_weapon_aim)
target_link_libraries(ssa_ray_traversal PUBLIC ssa_slide)
target_link_libraries(ssa_ray_intercepts PUBLIC ssa_ray_traversal)
target_link_libraries(ssa_enemy_ray PUBLIC ssa_ray_intercepts)
target_link_libraries(ssa_enemy_queries PUBLIC ssa_enemy_ray ssa_enemy_targeting
    ssa_enemy_navigation ssa_script_spawn)
target_link_libraries(ssa_combat_explosion PUBLIC ssa_enemy_targeting)
target_link_libraries(ssa_combat_runtime PUBLIC ssa_combat_damage ssa_combat_explosion
    ssa_combat_rewards ssa_enemy_cd_runtime ssa_player_runtime)

target_link_libraries(ssa_weapon_animation PUBLIC ssa_weapon_select)
target_link_libraries(ssa_weapon_loadout PUBLIC ssa_weapon_animation)
target_link_libraries(ssa_weapon_progress PUBLIC ssa_weapon_animation)
target_link_libraries(ssa_weapon_controller PUBLIC ssa_weapon_animation ssa_world)
target_link_libraries(ssa_weapon_aim PUBLIC ssa_enemy_ray ssa_world)
target_link_libraries(ssa_weapon_hit PUBLIC ssa_weapon_aim)
target_link_libraries(ssa_projectile_create PUBLIC ssa_world)
target_link_libraries(ssa_projectile_motion PUBLIC ssa_world)
target_link_libraries(ssa_projectile_controller PUBLIC ssa_world)
target_link_libraries(ssa_projectile_bounce PUBLIC ssa_enemy_ray)
target_link_libraries(ssa_projectile_effect PUBLIC ssa_world)
target_link_libraries(ssa_sector_clip PUBLIC ssa_geometry ssa_movement)
target_link_libraries(ssa_projectile_runtime PUBLIC ssa_sector_clip ssa_projectile_create ssa_projectile_motion
    ssa_projectile_controller ssa_projectile_bounce ssa_projectile_effect ssa_combat_runtime ssa_particle_create ssa_projectile_target ssa_projectile_extended)
target_link_libraries(ssa_particle_create PUBLIC ssa_projectile_create)
target_link_libraries(ssa_projectile_target PUBLIC ssa_projectile_create ssa_enemy_motion ssa_slide)
target_link_libraries(ssa_projectile_extended PUBLIC ssa_movement)
target_link_libraries(ssa_weapon_runtime PUBLIC ssa_weapon_controller ssa_weapon_hit
    ssa_combat_runtime ssa_projectile_runtime ssa_weapon_loadout ssa_weapon_progress)
target_link_libraries(ssa_entity_dispatch PUBLIC ssa_entity_pool ssa_world)
target_link_libraries(ssa_entity_runtime PUBLIC ssa_entity_dispatch ssa_enemy_queries
    ssa_projectile_runtime ssa_combat_runtime ssa_level_runtime ssa_entity_timer ssa_enemy_control_runtime)
target_link_libraries(ssa_sprite_dispatch PUBLIC ssa_weapon_animation)
target_link_libraries(ssa_actor_animation PUBLIC ssa_entity_pool)
target_link_libraries(ssa_actor_animation_runtime PUBLIC ssa_actor_animation ssa_script_spawn)
target_link_libraries(ssa_pickup_respawn_runtime PUBLIC ssa_pickup_respawn ssa_combat_runtime)
target_link_libraries(ssa_pickup_runtime PUBLIC ssa_pickup ssa_combat_runtime)
target_link_libraries(ssa_game_runtime PUBLIC ssa_frame ssa_entity_runtime
    ssa_actor_animation_runtime ssa_pickup_respawn_runtime ssa_sprite_dispatch ssa_weapon_runtime)
target_link_libraries(ssa_pc_input_runtime PUBLIC ssa_pc_input ssa_input_dispatch ssa_game_runtime)
target_link_libraries(ssa_map_texture_bindings PUBLIC ssa_map_assets ssa_texture_assets)
target_link_libraries(ssa_render_view PUBLIC ssa_movement ssa_geometry)
target_link_libraries(ssa_plane_renderer PUBLIC ssa_raster_fill)
target_link_libraries(ssa_world_visibility PUBLIC ssa_map_assets ssa_movement
    ssa_geometry ssa_enemy_targeting ssa_plane_renderer)
target_link_libraries(ssa_wall_renderer PUBLIC ssa_map_texture_bindings
    ssa_plane_renderer ssa_world_raster)
target_link_libraries(ssa_world_scene PUBLIC ssa_world_visibility ssa_wall_renderer
    ssa_plane_renderer ssa_raster_fill)
target_link_libraries(ssa_map_actors PUBLIC ssa_spawn ssa_world ssa_actor_animation ssa_entity_pool)
target_link_libraries(ssa_actor_raster PUBLIC ssa_actor_assets)
target_link_libraries(ssa_actor_queue PUBLIC ssa_world_visibility ssa_actor_raster)
target_link_libraries(ssa_actor_projection PUBLIC ssa_actor_queue ssa_actor_assets ssa_movement)
target_link_libraries(ssa_actor_scene PUBLIC ssa_actor_projection ssa_world_scene ssa_world)
target_link_libraries(ssa_sprite_oam PUBLIC ssa_sprite_assets ssa_movement)
target_link_libraries(ssa_sprite_cache PUBLIC ssa_sprite_assets)
target_link_libraries(ssa_sprite_pool PUBLIC ssa_sprite_dispatch ssa_weapon_animation)
target_link_libraries(ssa_hud_sprites PUBLIC ssa_sprite_pool)
target_link_libraries(ssa_hud_notice PUBLIC ssa_hud_sprites ssa_weapon_animation)
target_link_libraries(ssa_display PUBLIC ssa_sprite_oam)
target_link_libraries(ssa_hud_scene PUBLIC ssa_hud_notice ssa_hud_sprites ssa_sprite_cache ssa_display
    ssa_weapon_loadout ssa_weapon_controller)
add_library(ssa_native_game_core STATIC src/native_game.c src/native_pickup_art.c)
target_include_directories(ssa_native_game_core PUBLIC include)
target_compile_features(ssa_native_game_core PUBLIC c_std_11)
if(MSVC)
    target_compile_options(ssa_native_game_core PRIVATE /W4)
else()
    target_compile_options(ssa_native_game_core PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()
target_link_libraries(ssa_native_game_core PUBLIC ssa_game_runtime ssa_pc_input_runtime
    ssa_actor_scene ssa_render_view ssa_hud_notice ssa_hud_sprites ssa_sprite_cache ssa_display ssa_pickup_runtime ssa_palette_effect)

target_link_libraries(ssa_native_statistics PUBLIC ssa_statistics ssa_native_game_core)
target_link_libraries(ssa_native_completion PUBLIC ssa_completion ssa_native_statistics)
target_link_libraries(ssa_intermission PUBLIC ssa_native_completion ssa_pause ssa_menu ssa_display)
target_link_libraries(ssa_pause PUBLIC ssa_mode_control)
target_link_libraries(ssa_campaign_screen PUBLIC ssa_campaign_story ssa_map_assets)
target_link_libraries(ssa_netricsa PUBLIC ssa_map_assets)
target_link_libraries(ssa_pc_renderer PUBLIC ssa_native_game_core)
option(SSA_BUILD_PLAYABILITY_CHECK "Build the normal-input first-level completion check" ON)
if(SSA_BUILD_PLAYABILITY_CHECK)
    add_executable(ssa_native_netricsa_check tests/test_netricsa.c)
    add_executable(ssa_native_gba_aim_check tests/test_gba_aim.c)
    add_executable(ssa_native_chase_aim_check tests/test_chase_aim.c)
    target_link_libraries(ssa_native_chase_aim_check PRIVATE ssa_pc_renderer)
    target_compile_features(ssa_native_chase_aim_check PRIVATE c_std_11)
    target_link_libraries(ssa_native_gba_aim_check PRIVATE ssa_native_game_core)
    target_compile_features(ssa_native_gba_aim_check PRIVATE c_std_11)
    target_link_libraries(ssa_native_netricsa_check PRIVATE ssa_netricsa)
    target_compile_features(ssa_native_netricsa_check PRIVATE c_std_11)
    add_executable(ssa_native_umt_audio_check tests/test_umt_audio.c)
    target_link_libraries(ssa_native_umt_audio_check PRIVATE ssa_audio ssa_pickup ssa_inventory)
    target_compile_features(ssa_native_umt_audio_check PRIVATE c_std_11)
    add_executable(ssa_native_campaign_screen_check tests/test_campaign_screen.c)
    target_link_libraries(ssa_native_campaign_screen_check PRIVATE ssa_campaign_screen)
    target_compile_features(ssa_native_campaign_screen_check PRIVATE c_std_11)
    add_executable(ssa_native_notices_check tests/test_native_notices.c)
    target_link_libraries(ssa_native_notices_check PRIVATE ssa_native_game_core ssa_pc_renderer)
    target_compile_features(ssa_native_notices_check PRIVATE c_std_11)
    add_executable(ssa_native_statistics_check tests/test_native_statistics.c)
    target_link_libraries(ssa_native_statistics_check PRIVATE ssa_native_statistics)
    target_compile_features(ssa_native_statistics_check PRIVATE c_std_11)
    add_executable(ssa_native_completion_check tests/test_native_completion.c)
    add_executable(ssa_native_intermission_check tests/test_intermission.c)
    target_link_libraries(ssa_native_intermission_check PRIVATE ssa_intermission ssa_audio)
    target_link_libraries(ssa_native_completion_check PRIVATE ssa_native_completion)
    target_compile_features(ssa_native_completion_check PRIVATE c_std_11)
    add_executable(ssa_native_weapon_fixes_check tests/test_weapon_fixes.c)
    target_link_libraries(ssa_native_weapon_fixes_check PRIVATE ssa_native_game_core ssa_audio)
    target_compile_features(ssa_native_weapon_fixes_check PRIVATE c_std_11)
    add_executable(ssa_native_boss_check tests/test_enemy_boss_runtime.c)
    add_executable(ssa_native_gunrilla_check tests/test_gunrilla.c)
    target_link_libraries(ssa_native_gunrilla_check PRIVATE ssa_native_game_core)
    target_compile_features(ssa_native_gunrilla_check PRIVATE c_std_11)
    target_link_libraries(ssa_native_boss_check PRIVATE ssa_native_game_core)
    target_compile_features(ssa_native_boss_check PRIVATE c_std_11)
    add_executable(ssa_native_menu_check tests/test_menu.c)
    add_executable(ssa_native_audio_settings_check tests/test_audio_settings.c)
    target_link_libraries(ssa_native_audio_settings_check PRIVATE ssa_audio ssa_soundfont ssa_menu ssa_settings)
    target_compile_features(ssa_native_audio_settings_check PRIVATE c_std_11)
    target_link_libraries(ssa_native_menu_check PRIVATE ssa_menu)
    target_compile_features(ssa_native_menu_check PRIVATE c_std_11)
    add_executable(ssa_native_profile_check tests/test_profile.c)
    target_link_libraries(ssa_native_profile_check PRIVATE ssa_profile ssa_menu)
    target_compile_features(ssa_native_profile_check PRIVATE c_std_11)
    if(WIN32)
        add_executable(ssa_native_intermission_win32_check tests/test_intermission_win32.c platform/win32/audio_win32.c platform/win32/profile_win32.c)
        target_compile_definitions(ssa_native_intermission_win32_check PRIVATE UNICODE _UNICODE)
        target_link_libraries(ssa_native_intermission_win32_check PRIVATE ssa_pc_renderer ssa_audio ssa_intermission ssa_campaign_screen ssa_netricsa ssa_profile user32 gdi32 bcrypt winmm)
        add_executable(ssa_native_profile_disk_check tests/test_profile_win32.c platform/win32/audio_win32.c platform/win32/profile_win32.c)
        target_include_directories(ssa_native_profile_disk_check PRIVATE platform/win32)
        target_compile_definitions(ssa_native_profile_disk_check PRIVATE UNICODE _UNICODE)
        target_link_libraries(ssa_native_profile_disk_check PRIVATE ssa_pc_renderer ssa_audio ssa_soundfont ssa_menu ssa_profile ssa_campaign_screen ssa_netricsa ssa_intermission user32 gdi32 bcrypt winmm)
        target_compile_features(ssa_native_profile_disk_check PRIVATE c_std_11)
    endif()
    add_executable(ssa_native_password_check tests/test_password_start.c)
    target_link_libraries(ssa_native_password_check PRIVATE ssa_native_game_core)
    target_compile_features(ssa_native_password_check PRIVATE c_std_11)
    add_executable(ssa_native_map_view_check tests/test_map_view.c)
    target_link_libraries(ssa_native_map_view_check PRIVATE ssa_map_view ssa_audio)
    target_compile_features(ssa_native_map_view_check PRIVATE c_std_11)
    add_executable(ssa_native_playability_check tests/test_native_playability.c)
    add_executable(ssa_native_second_level_check tests/test_second_level.c)
    add_executable(ssa_native_third_level_check tests/test_third_level.c)
    add_executable(ssa_native_campaign_check tests/test_campaign.c)
    target_link_libraries(ssa_native_campaign_check PRIVATE ssa_native_game_core ssa_pc_renderer ssa_audio)
    target_compile_features(ssa_native_campaign_check PRIVATE c_std_11)
    target_link_libraries(ssa_native_third_level_check PRIVATE ssa_native_game_core ssa_pc_renderer ssa_audio)
    target_compile_features(ssa_native_third_level_check PRIVATE c_std_11)
    target_link_libraries(ssa_native_second_level_check PRIVATE ssa_native_game_core ssa_pc_renderer ssa_audio)
    target_compile_features(ssa_native_second_level_check PRIVATE c_std_11)
    target_link_libraries(ssa_native_playability_check PRIVATE ssa_native_game_core)
    target_compile_features(ssa_native_playability_check PRIVATE c_std_11)
    add_executable(ssa_native_audio_check tests/test_audio.c)
    add_executable(ssa_native_weapon_cadence_check tests/test_weapon_cadence.c)
    add_executable(ssa_native_special_weapons_check tests/test_special_weapons.c)
    add_executable(ssa_native_prion_targeting_check tests/test_prion_targeting.c)
    target_link_libraries(ssa_native_prion_targeting_check PRIVATE ssa_native_game_core)
    target_compile_features(ssa_native_prion_targeting_check PRIVATE c_std_11)
    add_executable(ssa_native_enemy_crowd_check tests/test_enemy_crowd.c)
    target_link_libraries(ssa_native_enemy_crowd_check PRIVATE ssa_native_game_core)
    target_compile_features(ssa_native_enemy_crowd_check PRIVATE c_std_11)
    target_link_libraries(ssa_native_special_weapons_check PRIVATE ssa_pc_renderer ssa_audio)
    target_compile_features(ssa_native_special_weapons_check PRIVATE c_std_11)
    target_link_libraries(ssa_native_weapon_cadence_check PRIVATE ssa_native_game_core)
    target_compile_features(ssa_native_weapon_cadence_check PRIVATE c_std_11)
    target_link_libraries(ssa_native_audio_check PRIVATE ssa_native_game_core ssa_audio)
    target_compile_features(ssa_native_audio_check PRIVATE c_std_11)
    add_executable(ssa_native_audio_playability_check tests/test_audio_playability.c)
    target_link_libraries(ssa_native_audio_playability_check PRIVATE ssa_native_game_core ssa_audio)
    target_compile_features(ssa_native_audio_playability_check PRIVATE c_std_11)
endif()
if(WIN32)
    enable_language(CXX)
    add_library(ssa_midi_win32 STATIC platform/win32/midi_win32.c)
    target_include_directories(ssa_midi_win32 PUBLIC include platform/win32)
    target_compile_features(ssa_midi_win32 PUBLIC c_std_11)
    target_link_libraries(ssa_midi_win32 PUBLIC winmm)
    if(MSVC)
        target_compile_options(ssa_midi_win32 PRIVATE /W4 /WX)
    endif()
    target_link_libraries(ssa_audio PUBLIC ssa_midi_win32)
    add_executable(ssa_native_midi_sync_check tests/test_midi_sync_win32.cpp)
    target_compile_features(ssa_native_midi_sync_check PRIVATE cxx_std_11)
    target_link_libraries(ssa_native_midi_sync_check PRIVATE ssa_midi_win32 ole32 uuid mmdevapi)
    add_executable(ssa_native_midi_transition_check tests/test_midi_transition_win32.cpp platform/win32/audio_win32.c)
    target_compile_features(ssa_native_midi_transition_check PRIVATE cxx_std_11)
    target_link_libraries(ssa_native_midi_transition_check PRIVATE ssa_audio ssa_soundfont ole32 uuid mmdevapi)
    add_executable(ssa_native_weapon_wheel_check tests/test_weapon_wheel_win32.c platform/win32/audio_win32.c platform/win32/profile_win32.c)
    add_executable(ssa_native_settings_win32_check tests/test_settings_win32.c platform/win32/audio_win32.c platform/win32/profile_win32.c)
    target_include_directories(ssa_native_settings_win32_check PRIVATE platform/win32)
    target_compile_features(ssa_native_settings_win32_check PRIVATE c_std_11)
    target_compile_definitions(ssa_native_settings_win32_check PRIVATE UNICODE _UNICODE)
    target_link_libraries(ssa_native_settings_win32_check PRIVATE ssa_pc_renderer ssa_audio ssa_menu ssa_profile ssa_campaign_screen ssa_netricsa ssa_intermission user32 gdi32 bcrypt winmm)
    target_include_directories(ssa_native_weapon_wheel_check PRIVATE platform/win32)
    target_link_libraries(ssa_native_weapon_wheel_check PRIVATE ssa_pc_renderer ssa_audio ssa_soundfont ssa_menu ssa_profile ssa_campaign_screen ssa_netricsa ssa_intermission user32 gdi32 bcrypt winmm)
    target_compile_features(ssa_native_weapon_wheel_check PRIVATE c_std_11)
    add_executable(ssa_native_weapon_switch_check tests/test_weapon_switch.c)
    add_executable(ssa_native_alternate_weapons_check tests/test_alternate_weapons.c)
    target_link_libraries(ssa_native_alternate_weapons_check PRIVATE ssa_native_game_core ssa_pc_renderer)
    target_compile_features(ssa_native_alternate_weapons_check PRIVATE c_std_11)
    target_link_libraries(ssa_native_weapon_switch_check PRIVATE ssa_native_game_core)
    target_compile_features(ssa_native_weapon_switch_check PRIVATE c_std_11)
    add_executable(ssa_native_sector_clip_check tests/test_sector_clip_runtime.c)
    target_link_libraries(ssa_native_sector_clip_check PRIVATE ssa_native_game_core)
    target_compile_features(ssa_native_sector_clip_check PRIVATE c_std_11)
    add_executable(ssa_native_immediate_use_check tests/test_immediate_use.c)
    target_link_libraries(ssa_native_immediate_use_check PRIVATE ssa_native_game_core)
    target_compile_features(ssa_native_immediate_use_check PRIVATE c_std_11)
    add_executable(ssa_native_audio_timing_check tests/test_audio_win32_timing.c platform/win32/audio_win32.c)
    target_include_directories(ssa_native_audio_timing_check PRIVATE platform/win32)
    target_link_libraries(ssa_native_audio_timing_check PRIVATE ssa_audio winmm)
    target_compile_features(ssa_native_audio_timing_check PRIVATE c_std_11)
    if(MSVC)
        target_compile_options(ssa_native_audio_timing_check PRIVATE /W4 /WX)
    endif()
    add_executable(ssa_native_game platform/win32/game.c platform/win32/audio_win32.c platform/win32/profile_win32.c)
    target_compile_features(ssa_native_game PRIVATE c_std_11)
    target_compile_definitions(ssa_native_game PRIVATE UNICODE _UNICODE)
    target_link_libraries(ssa_native_game PRIVATE ssa_pc_renderer ssa_audio ssa_soundfont ssa_menu ssa_profile ssa_campaign_screen ssa_netricsa ssa_intermission user32 gdi32 bcrypt winmm)
    if(MSVC)
        target_compile_options(ssa_native_game PRIVATE /W4 /WX)
    endif()
    add_library(ssa_input_win32 STATIC platform/win32/input_win32.c)
    target_include_directories(ssa_input_win32 PUBLIC platform/win32)
    target_compile_features(ssa_input_win32 PUBLIC c_std_11)
    target_link_libraries(ssa_input_win32 PUBLIC ssa_pc_input_runtime user32)
    if(MSVC)
        target_compile_options(ssa_input_win32 PRIVATE /W4 /WX)
    endif()
    add_executable(ssa_native_viewer platform/win32/viewer.c)
    target_compile_features(ssa_native_viewer PRIVATE c_std_11)
    target_compile_definitions(ssa_native_viewer PRIVATE UNICODE _UNICODE)
    target_link_libraries(ssa_native_viewer PRIVATE ssa_world_scene ssa_render_view
        ssa_player_spawn ssa_player_motion ssa_pc_input ssa_view ssa_world ssa_slide
        ssa_sprite_assets ssa_map_actors ssa_actor_scene ssa_player_frame ssa_hud_scene user32 gdi32 bcrypt)
    if(MSVC)
        target_compile_options(ssa_native_viewer PRIVATE /W4 /WX)
    endif()
endif()
target_include_directories(ssa_weapon_select PUBLIC include)
target_compile_features(ssa_weapon_select PUBLIC c_std_11)
target_link_libraries(ssa_weapon_select PUBLIC ssa_inventory)
target_include_directories(ssa_inventory PUBLIC include)
target_compile_features(ssa_inventory PUBLIC c_std_11)
target_include_directories(ssa_pickup PUBLIC include)
target_compile_features(ssa_pickup PUBLIC c_std_11)
target_link_libraries(ssa_pickup PUBLIC ssa_inventory)
target_include_directories(ssa_spawn PUBLIC include)
target_compile_features(ssa_spawn PUBLIC c_std_11)
target_link_libraries(ssa_spawn PUBLIC ssa_world)
target_include_directories(ssa_slide PUBLIC include)
target_compile_features(ssa_slide PUBLIC c_std_11)
target_link_libraries(ssa_slide PUBLIC ssa_geometry ssa_movement)
target_include_directories(ssa_world PUBLIC include)
target_compile_features(ssa_world PUBLIC c_std_11)
target_link_libraries(ssa_world PUBLIC ssa_geometry ssa_slide ssa_horizontal)
target_include_directories(ssa_horizontal PUBLIC include)
target_compile_features(ssa_horizontal PUBLIC c_std_11)
target_link_libraries(ssa_horizontal PUBLIC ssa_physics)
target_include_directories(ssa_view PUBLIC include)
target_compile_features(ssa_view PUBLIC c_std_11)
target_link_libraries(ssa_view PUBLIC ssa_geometry)
target_include_directories(ssa_map_assets PUBLIC include)
target_compile_features(ssa_map_assets PUBLIC c_std_11)
target_include_directories(ssa_geometry PUBLIC include)
target_compile_features(ssa_geometry PUBLIC c_std_11)
target_link_libraries(ssa_geometry PUBLIC ssa_map_assets ssa_physics)
target_include_directories(ssa_physics PUBLIC include)
target_compile_features(ssa_physics PUBLIC c_std_11)
target_link_libraries(ssa_physics PUBLIC ssa_movement)
target_include_directories(ssa_movement PUBLIC include)
target_compile_features(ssa_movement PUBLIC c_std_11)
target_include_directories(ssa_input PUBLIC include)
target_compile_features(ssa_input PUBLIC c_std_11)
if(MSVC)
    target_compile_options(ssa_input PRIVATE /W4)
    target_compile_options(ssa_movement PRIVATE /W4)
    target_compile_options(ssa_physics PRIVATE /W4)
    target_compile_options(ssa_map_assets PRIVATE /W4)
    target_compile_options(ssa_geometry PRIVATE /W4)
    target_compile_options(ssa_view PRIVATE /W4)
    target_compile_options(ssa_world PRIVATE /W4)
    target_compile_options(ssa_horizontal PRIVATE /W4)
    target_compile_options(ssa_slide PRIVATE /W4)
    target_compile_options(ssa_inventory PRIVATE /W4)
    target_compile_options(ssa_pickup PRIVATE /W4)
    target_compile_options(ssa_spawn PRIVATE /W4)
    target_compile_options(ssa_weapon_select PRIVATE /W4)
else()
    target_compile_options(ssa_input PRIVATE -Wall -Wextra -Wpedantic)
    target_compile_options(ssa_movement PRIVATE -Wall -Wextra -Wpedantic)
    target_compile_options(ssa_physics PRIVATE -Wall -Wextra -Wpedantic)
    target_compile_options(ssa_map_assets PRIVATE -Wall -Wextra -Wpedantic)
    target_compile_options(ssa_geometry PRIVATE -Wall -Wextra -Wpedantic)
    target_compile_options(ssa_view PRIVATE -Wall -Wextra -Wpedantic)
    target_compile_options(ssa_world PRIVATE -Wall -Wextra -Wpedantic)
    target_compile_options(ssa_horizontal PRIVATE -Wall -Wextra -Wpedantic)
    target_compile_options(ssa_slide PRIVATE -Wall -Wextra -Wpedantic)
    target_compile_options(ssa_inventory PRIVATE -Wall -Wextra -Wpedantic)
    target_compile_options(ssa_pickup PRIVATE -Wall -Wextra -Wpedantic)
    target_compile_options(ssa_spawn PRIVATE -Wall -Wextra -Wpedantic)
    target_compile_options(ssa_spawn PRIVATE -Werror)
    target_compile_options(ssa_inventory PRIVATE -Werror)
    target_compile_options(ssa_pickup PRIVATE -Werror)
    target_compile_options(ssa_weapon_select PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()
