# SPDX-License-Identifier: GPL-3.0-or-later
add_executable(realmrun-manifest-check manifest_check_main.c)
target_link_libraries(realmrun-manifest-check PRIVATE realmrun_core)
target_compile_options(realmrun-manifest-check PRIVATE -Wall -Wextra)
realmrun_apply_sanitize(realmrun-manifest-check)
realmrun_apply_tune(realmrun-manifest-check)

# realmrun-records: no SDL2, decodes fixed-size record files (T-M1-05).
add_executable(realmrun-records records_main.c)
target_link_libraries(realmrun-records PRIVATE realmrun_core)
target_compile_options(realmrun-records PRIVATE -Wall -Wextra)
realmrun_apply_sanitize(realmrun-records)
realmrun_apply_tune(realmrun-records)

# realmrun-rules: no SDL2, parses a .rul and dumps the typed S-M5-01 rules
# model (T-M5-02a). For owner L2 conformance runs over the real rulesets.
add_executable(realmrun-rules rules_main.c)
target_link_libraries(realmrun-rules PRIVATE realmrun_core)
target_compile_options(realmrun-rules PRIVATE -Wall -Wextra)
realmrun_apply_sanitize(realmrun-rules)
realmrun_apply_tune(realmrun-rules)

# realmrun-combat: no SDL2, headless deterministic battle simulation that prints
# the event log + result (T-M5-02b). Synthetic stacks only (no game data); for
# eyeballing the resolver and as a worked --battle example.
add_executable(realmrun-combat combat_main.c)
target_link_libraries(realmrun-combat PRIVATE realmrun_core)
target_compile_options(realmrun-combat PRIVATE -Wall -Wextra)
realmrun_apply_sanitize(realmrun-combat)
realmrun_apply_tune(realmrun-combat)

# realmrun-res: no SDL2, decodes SAGE [SAGE40] UI resource files (T-M3-02).
add_executable(realmrun-res res_main.c)
target_link_libraries(realmrun-res PRIVATE realmrun_core)
target_compile_options(realmrun-res PRIVATE -Wall -Wextra)
realmrun_apply_sanitize(realmrun-res)
realmrun_apply_tune(realmrun-res)

# realmrun-ui: no SDL2, walks the SAGE .RES layout-tree tail into screens +
# widget nodes and hit-tests a point (T-M3-03). For owner L2 runs.
add_executable(realmrun-ui ui_main.c)
target_link_libraries(realmrun-ui PRIVATE realmrun_ui)
target_compile_options(realmrun-ui PRIVATE -Wall -Wextra)
realmrun_apply_sanitize(realmrun-ui)
realmrun_apply_tune(realmrun-ui)

# realmrun-scn: no SDL2, opens a scenario directory and prints map/placement
# counts + per-file validation status (T-M4-02).
add_executable(realmrun-scn scenario_main.c)
target_link_libraries(realmrun-scn PRIVATE realmrun_core)
target_compile_options(realmrun-scn PRIVATE -Wall -Wextra)
realmrun_apply_sanitize(realmrun-scn)
realmrun_apply_tune(realmrun-scn)

# realmrun-campaign: no SDL2, opens a campaign directory and prints CAMPAIGN.DAT
# fields, per-episode scenario/sidecar status and the linear advance (T-M6-04a).
add_executable(realmrun-campaign campaign_main.c)
target_link_libraries(realmrun-campaign PRIVATE realmrun_core)
target_compile_options(realmrun-campaign PRIVATE -Wall -Wextra)
realmrun_apply_sanitize(realmrun-campaign)
realmrun_apply_tune(realmrun-campaign)

# realmrun-probe: no SDL2, SDL-free host probe -> probe.json (T-M2-06). The
# full SDL facts come from `realmrun --probe`; this is the headless/ARM64-CI
# fallback that still emits CPU/RAM/GPU + input-class facts.
add_executable(realmrun-probe probe_main.c)
target_link_libraries(realmrun-probe PRIVATE realmrun_core)
target_compile_options(realmrun-probe PRIVATE -Wall -Wextra)
realmrun_apply_sanitize(realmrun-probe)
realmrun_apply_tune(realmrun-probe)

if(SDL2_FOUND)
    add_executable(realmrun-view view_main.c)
    target_link_libraries(realmrun-view PRIVATE realmrun_core SDL2::SDL2)
    target_compile_options(realmrun-view PRIVATE -Wall -Wextra)
    realmrun_apply_sanitize(realmrun-view)
    realmrun_apply_tune(realmrun-view)
endif()

# realmrun-mapview: scenario map/terrain/minimap viewer (T-M4-03). Built ALWAYS:
# the headless `--dump-ppm OUT` mode needs no SDL (for CI / owner L2 runs); the
# interactive SDL mode is compiled in only when SDL2 is present.
add_executable(realmrun-mapview mapview_main.c)
target_link_libraries(realmrun-mapview PRIVATE realmrun_core)
target_compile_options(realmrun-mapview PRIVATE -Wall -Wextra)
if(SDL2_FOUND)
    target_compile_definitions(realmrun-mapview PRIVATE REALMRUN_HAVE_SDL)
    target_link_libraries(realmrun-mapview PRIVATE SDL2::SDL2)
endif()
realmrun_apply_sanitize(realmrun-mapview)
realmrun_apply_tune(realmrun-mapview)
