cmake_minimum_required(VERSION 3.20)
project(AlienTrilogyRecompiled LANGUAGES C CXX)
get_filename_component(PSXRECOMP_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../psxrecomp" ABSOLUTE)
set(PSX_RECOMP_UI OFF CACHE BOOL "Use the collection launcher" FORCE)
set(PSX_NETPLAY OFF CACHE BOOL "Local single player" FORCE)
include("${PSXRECOMP_ROOT}/runtime/runtime.cmake")
psxrecomp_add_game_runtime(psx-runtime
    PRELOADED_MODS_DIR "NONE"
    WINDOW_TITLE "Alien Trilogy Recompiled"
    DEFAULT_GAME_CONFIG_PATH "game.toml"
    MAX_PLAYERS 1
    GEN_MARKER "generated/SLUS_000.07_dispatch.c"
    GEN_FULL_GLOB "generated/SLUS_000.07_full_*.c"
)
if(WIN32)
    set_target_properties(psx-runtime PROPERTIES OUTPUT_NAME "psx-runtime")
else()
    set_target_properties(psx-runtime PROPERTIES OUTPUT_NAME "psx-runtime.x86_64")
endif()
target_sources(psx-runtime PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../launcher/runtime_preferences.cpp")
target_link_options(psx-runtime PRIVATE "-Wl,--wrap=host_volume_get")

if(NOT PSX_SDL3 OR NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
    message(FATAL_ERROR "Alien mouse integration requires SDL3 and GNU-compatible linker wrapping")
endif()
target_sources(psx-runtime PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/controls.cpp")
target_link_options(psx-runtime PRIVATE
    "-Wl,--wrap=SDL_PollEvent" "-Wl,--wrap=sio_set_pad_state_slot"
    "-Wl,--wrap=mod_runtime_on_dispatch")
