add_library(recovered_game_logic STATIC RecoveredLogic.cpp)
target_include_directories(recovered_game_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/src)
target_compile_features(recovered_game_logic PUBLIC cxx_std_20)
target_link_libraries(recovered_game_logic PRIVATE c4_warnings)
target_link_libraries(recovered_game_logic PUBLIC native_physics)
target_link_libraries(asset_inspector PRIVATE recovered_game_logic)

add_library(native_game STATIC GameState.cpp Bootstrap.cpp InputScenario.cpp
    VehicleController.cpp RobotController.cpp SourceMotion.cpp
    RaceCamera.cpp RaceLifecycle.cpp Ghost.cpp CameraProjection.cpp SourceTime.cpp
    WorldActors.cpp WorldPaths.cpp WorldAmbience.cpp WorldLeaves.cpp
    effects/SourceEffects.cpp effects/ParticleCallbacks.cpp)
target_include_directories(native_game PUBLIC ${PROJECT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_features(native_game PUBLIC cxx_std_20)
target_link_libraries(native_game PUBLIC native_assets native_physics native_audio recovered_game_logic PRIVATE c4_warnings)

if(BUILD_TESTING)
    set(C4_ORIGINAL_ASSET_ROOT "${PROJECT_SOURCE_DIR}/work/original/app" CACHE PATH
        "Read-only imported original resources for native source behavior checks")
endif()
add_subdirectory(ui)

if(BUILD_TESTING)
    add_executable(recovered_game_logic_tests ../../tests/test_game_logic.cpp)
    target_link_libraries(recovered_game_logic_tests PRIVATE recovered_game_logic c4_warnings)
    if(MSVC)
        target_compile_options(recovered_game_logic_tests PRIVATE /UNDEBUG)
    else()
        target_compile_options(recovered_game_logic_tests PRIVATE -UNDEBUG)
    endif()
    add_test(NAME recovered_game_logic_behavior COMMAND recovered_game_logic_tests)
    add_executable(c4_input_scenario_tests ../../tests/test_input_scenario.cpp)
    target_link_libraries(c4_input_scenario_tests PRIVATE native_game c4_warnings)
    add_test(NAME c4_input_scenario_boundary COMMAND c4_input_scenario_tests)
    add_executable(c4_ghost_tests ../../tests/test_ghost.cpp)
    target_link_libraries(c4_ghost_tests PRIVATE native_game c4_warnings)
    add_test(NAME c4_local_ghost_boundary COMMAND c4_ghost_tests)
    add_executable(c4_race_lifecycle_tests ../../tests/test_race_lifecycle.cpp)
    target_link_libraries(c4_race_lifecycle_tests PRIVATE native_game c4_warnings)
    add_test(NAME c4_race_lifecycle_boundary COMMAND c4_race_lifecycle_tests)
    add_executable(c4_vehicle_tests ../../tests/test_vehicle_behavior.cpp)
    target_link_libraries(c4_vehicle_tests PRIVATE native_game c4_warnings)
    add_executable(c4_race_camera_tests ../../tests/test_race_camera.cpp)
    target_link_libraries(c4_race_camera_tests PRIVATE native_game c4_warnings)
    add_executable(c4_robot_phase_tests RobotPhaseTest.cpp)
    target_link_libraries(c4_robot_phase_tests PRIVATE native_game c4_warnings)
    add_executable(c4_effect_lifecycle_tests ../../tests/test_effect_lifecycle.cpp)
    target_link_libraries(c4_effect_lifecycle_tests PRIVATE native_game c4_warnings)
    add_test(NAME c4_effect_lifecycle_boundary COMMAND c4_effect_lifecycle_tests)
    add_executable(c4_game_runtime_tests GameRuntimeTest.cpp)
    target_link_libraries(c4_game_runtime_tests PRIVATE native_game c4_game_ui c4_warnings)
    add_executable(c4_effect_system_tests ../../tests/test_effect_system.cpp)
    target_link_libraries(c4_effect_system_tests PRIVATE native_game c4_warnings)
    add_executable(c4_world_actor_tests ../../tests/test_world_actors.cpp)
    target_link_libraries(c4_world_actor_tests PRIVATE native_game c4_warnings)
    add_executable(c4_world_path_tests ../../tests/test_world_paths.cpp)
    target_link_libraries(c4_world_path_tests PRIVATE native_game c4_warnings)
    add_executable(c4_world_ambience_tests WorldAmbienceTest.cpp)
    target_link_libraries(c4_world_ambience_tests PRIVATE native_game c4_warnings)
    add_executable(c4_world_leaf_tests ../../tests/test_world_leaves.cpp)
    target_link_libraries(c4_world_leaf_tests PRIVATE native_game c4_warnings)
    add_test(NAME c4_vehicle_source_boundary COMMAND c4_vehicle_tests "${C4_ORIGINAL_ASSET_ROOT}")
    add_test(NAME c4_race_camera_source_boundary COMMAND c4_race_camera_tests "${C4_ORIGINAL_ASSET_ROOT}")
    add_test(NAME c4_robot_phase_source_boundary COMMAND c4_robot_phase_tests "${C4_ORIGINAL_ASSET_ROOT}")
    add_test(NAME c4_game_runtime_source_boundary COMMAND c4_game_runtime_tests "${C4_ORIGINAL_ASSET_ROOT}")
    add_test(NAME c4_effect_system_source_boundary COMMAND c4_effect_system_tests "${C4_ORIGINAL_ASSET_ROOT}")
    add_test(NAME c4_world_actor_source_boundary COMMAND c4_world_actor_tests "${C4_ORIGINAL_ASSET_ROOT}")
    add_test(NAME c4_world_path_source_boundary COMMAND c4_world_path_tests "${C4_ORIGINAL_ASSET_ROOT}")
    add_test(NAME c4_world_ambience_source_boundary COMMAND c4_world_ambience_tests "${C4_ORIGINAL_ASSET_ROOT}")
    add_test(NAME c4_world_leaf_source_boundary COMMAND c4_world_leaf_tests "${C4_ORIGINAL_ASSET_ROOT}")
    foreach(test_target c4_input_scenario_tests c4_ghost_tests c4_race_lifecycle_tests c4_vehicle_tests c4_race_camera_tests c4_robot_phase_tests c4_effect_lifecycle_tests c4_game_runtime_tests c4_effect_system_tests c4_world_actor_tests c4_world_path_tests c4_world_ambience_tests c4_world_leaf_tests)
        if(MSVC)
            target_compile_options(${test_target} PRIVATE /UNDEBUG)
        else()
            target_compile_options(${test_target} PRIVATE -UNDEBUG)
        endif()
    endforeach()
endif()
