if(WIN32)
  set(uc_guest_mem_source guest_mem_win.cpp)
  set(uc_fatal_source fatal_win.cpp)
  set(uc_crash_report_source crash_report_win.cpp)
  set(uc_savefs_source savefs_win.cpp)
else()
  set(uc_savefs_source savefs_posix.cpp)
  set(uc_guest_mem_source guest_mem_posix.cpp)
  set(uc_fatal_source fatal_posix.cpp)
  set(uc_crash_report_source crash_report_posix.cpp)
endif()
add_library(uc_runtime STATIC ${uc_guest_mem_source} dispatch.cpp trace.cpp ${uc_fatal_source} guest_call.cpp hle/nop.cpp clock.cpp mmio.cpp lowmem.cpp sched.cpp hle/os_thread.cpp hle/os_sync.cpp hle/os_misc.cpp hle/format_guest.cpp dvdfs.cpp hle/dvd.cpp hle/vi.cpp hle/exi.cpp hle/ios.cpp hle/dsp.cpp)
if(UC_LINUX)   # by quote only: runtime/sched.h would shadow <sched.h>, which glibc's <pthread.h> includes
  target_compile_options(uc_runtime PUBLIC "-iquote${CMAKE_CURRENT_SOURCE_DIR}")
else()
  target_include_directories(uc_runtime PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
endif()
target_sources(uc_runtime PRIVATE gx_audit.cpp)
target_sources(uc_runtime PRIVATE hle/gx.cpp hle/sdk_math.cpp hle/sdk_regs.cpp hle/leaf_gen.cpp)
target_sources(uc_runtime PRIVATE ${uc_savefs_source} save_rollback.cpp hle/save.cpp)
target_sources(uc_runtime PRIVATE native_input.cpp mem_trace.cpp)
target_sources(uc_runtime PRIVATE ax_audio.cpp audio_gap_audit.cpp perf_counters.cpp)
target_sources(uc_runtime PRIVATE locked_copy.cpp)
target_sources(uc_runtime PRIVATE rollback_memory.cpp)
target_sources(uc_runtime PRIVATE ${uc_crash_report_source} gx_gap_audit.cpp)
target_sources(uc_runtime PRIVATE hle/game_math.cpp)
target_link_libraries(uc_runtime PUBLIC uc_gx uc_input uc_gamepad_config uc_wiimote_config PRIVATE uc_public_release uc_path_io)
if(UNIX)
  target_link_libraries(uc_runtime PUBLIC ${CMAKE_DL_LIBS})   # dladdr in the crash report
else()
  target_link_libraries(uc_runtime PRIVATE uc_windows_path)   # savefs_win.cpp: the saves folder behind a junction or a network path
endif()
# Real hook implementations for uc.exe (ppc::trap, mmio_*, timebase); tests use tests/mmio_stub.cpp instead.
add_library(uc_platform STATIC platform.cpp)
target_link_libraries(uc_platform PUBLIC uc_runtime)
