cmake_minimum_required(VERSION 3.20)
project(DieHardRecompiled 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 "Die Hard Trilogy 2: Viva Las Vegas (Europe) Recompiled"
    DEFAULT_GAME_CONFIG_PATH "game.toml"
    MAX_PLAYERS 1
    GEN_MARKER "generated/SLES_027.46_dispatch.c"
    GEN_FULL_GLOB "generated/SLES_027.46_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")
target_sources(psx-runtime PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/compat.cpp")
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
    message(FATAL_ERROR "DHT2's exact OpenBIOS compatibility adapter requires GNU-compatible linker wrapping")
endif()
target_link_options(psx-runtime PRIVATE "-Wl,--wrap=mod_runtime_on_dispatch")
target_sources(psx-runtime PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/mouse.cpp")
target_link_options(psx-runtime PRIVATE "-Wl,--wrap=SDL_PollEvent" "-Wl,--wrap=sio_set_pad_state_slot")
target_link_options(psx-runtime PRIVATE "-Wl,--wrap=gl_renderer_set_display_aspect")
