cmake_minimum_required(VERSION 3.25)
project(probe_recompiler LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(FetchContent)
set(ZYDIS_BUILD_TOOLS OFF CACHE BOOL "" FORCE)
set(ZYDIS_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(ZYDIS_BUILD_DOXYGEN OFF CACHE BOOL "" FORCE)
FetchContent_Declare(zydis GIT_REPOSITORY https://github.com/zyantific/zydis.git GIT_TAG v4.1.1 GIT_SHALLOW TRUE)
FetchContent_Declare(tomlplusplus GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git GIT_TAG v3.4.0 GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(zydis tomlplusplus)
get_filename_component(ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../.." ABSOLUTE)
file(GLOB RECOMP_SOURCES CONFIGURE_DEPENDS "${ROOT}/tools/recomp/*.cpp")
add_executable(xbe_recomp ${RECOMP_SOURCES})
target_include_directories(xbe_recomp PRIVATE "${ROOT}/src" "${ROOT}/tools/recomp")
target_link_libraries(xbe_recomp PRIVATE Zydis tomlplusplus::tomlplusplus)
# Android installs executable PIEs with the same packaging as the compiler tools.
set_target_properties(xbe_recomp PROPERTIES OUTPUT_NAME libprobe_recomp SUFFIX .so
    RUNTIME_OUTPUT_DIRECTORY "${ROOT}/out/on-device-probe/jniLibs/${ANDROID_ABI}")
