cmake_minimum_required(VERSION 3.20)
# C as well as C++: XenonUtils pulls in C third party code (the PowerPC
# disassembler, LZX decompression, AES), and it has to use clang-cl too.
project("CoD3Recomp" C CXX)

# Call of Duty 3 (Xbox 360) static recompilation.
#
# CoD3RecompLib is the recompiled guest code, generated by XenonRecomp.
# CoD3Host is the program around it: first time setup, guest memory, and the
# Xbox 360 kernel imports. The imports are all stubs today, so the executable
# builds and runs but stops as soon as the game asks the kernel for anything.
# STATUS.md has the details.

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Every target has to agree on this, because the host links the recompiled
# code together with XenonUtils, and XenonRecomp's own CMake selects the
# static runtime.
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

add_subdirectory(CoD3RecompLib)

# Brings in XenonUtils, which the host reuses to parse the XEX. The recompiler
# and analyser targets come along with it but are not built by default.
add_subdirectory(tools/XenonRecomp "${CMAKE_BINARY_DIR}/XenonRecomp" EXCLUDE_FROM_ALL)

add_subdirectory(CoD3Host)

# Verification tooling. Not built by default: it is only needed when checking
# the recompiler against Xenia's instruction tests.
add_subdirectory(tools/PpcAsm "${CMAKE_BINARY_DIR}/PpcAsm" EXCLUDE_FROM_ALL)
add_subdirectory(tools/XenosDis "${CMAKE_BINARY_DIR}/XenosDis" EXCLUDE_FROM_ALL)
