# Ftxui.cmake - provide FTXUI (https://github.com/ArthurSonzogni/FTXUI) via
# FetchContent, mirroring cmake/Paho.cmake. FTXUI powers the optional terminal
# dashboard (TuiUi); headless builds (-DWITH_TUI=OFF) never fetch it.
#
# HARDENING (recommended): the tag below is a mutable ref. For maximum integrity
# pin FTXUI_TAG to a full commit SHA (immutable), or switch to URL + URL_HASH
# (SHA256) of the signed release tarball and verify out-of-band. Bump the version
# deliberately, not silently.

include(FetchContent)

set(FTXUI_TAG "v5.0.0" CACHE STRING "FTXUI git tag/commit")

# Keep the dependency lean: we only need the libraries, not its examples/docs/tests.
set(FTXUI_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(FTXUI_BUILD_DOCS     OFF CACHE BOOL "" FORCE)
set(FTXUI_BUILD_TESTS    OFF CACHE BOOL "" FORCE)
set(FTXUI_ENABLE_INSTALL OFF CACHE BOOL "" FORCE)

# FTXUI's bundled CMakeLists declares a cmake_minimum_required below CMake 4's
# floor; allow it to configure under modern CMake (same shim used for Paho/doctest).
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)

FetchContent_Declare(ftxui
  GIT_REPOSITORY https://github.com/ArthurSonzogni/FTXUI.git
  GIT_TAG        ${FTXUI_TAG}
  GIT_SHALLOW    TRUE
)
FetchContent_MakeAvailable(ftxui)

unset(CMAKE_POLICY_VERSION_MINIMUM)
