cmake_minimum_required(VERSION 3.22.1)
project(deckengine C)

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)

# Repo root, three levels up from android/app/src/main/jni/.
get_filename_component(REPO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../../../.." ABSOLUTE)

# Same engine + interpreter source files the watch app links (see
# watch/wscript's ENGINE_SRCS/INTERP_SRCS and its own comment on why -
# except astro.c is paired with the real, full-precision
# engine/third_party/astronomy/astronomy.c here, not the watch's
# lowprec_ephemeris.c substitute: that substitute exists solely for
# Pebble's 64KB code+data+bss budget, which Android has no equivalent
# of. json.c/reading_io.c are not linked - like the watch, this is one
# process computing and rendering its own reading, no JSON pipe between
# separate binaries.
add_library(deckengine SHARED
    deck_jni.c
    reading_json.c
    ${REPO_ROOT}/engine/src/rng.c
    ${REPO_ROOT}/engine/src/tarot.c
    ${REPO_ROOT}/engine/src/tarot_data.c
    ${REPO_ROOT}/engine/src/astro.c
    ${REPO_ROOT}/engine/src/i18n.c
    ${REPO_ROOT}/engine/src/reading.c
    ${REPO_ROOT}/engine/third_party/astronomy/astronomy.c
    ${REPO_ROOT}/interpreter/src/significance.c
    ${REPO_ROOT}/interpreter/src/narrative.c
    ${REPO_ROOT}/interpreter/src/guidance.c
)

target_link_libraries(deckengine m)
