cmake_minimum_required (VERSION 3.11)
include (FetchContent)

# Declarations
FetchContent_Declare (
  ftxui
  GIT_REPOSITORY https://github.com/ArthurSonzogni/FTXUI
  GIT_TAG 62fb6298bef19618a43aff9f09401309c307a156
)

FetchContent_Declare (
  treesitter
  GIT_REPOSITORY https://github.com/tree-sitter/tree-sitter.git
  GIT_TAG ccd6bf554d922596ce905730d98a77af368bba5c
)

FetchContent_Declare (
  doctest
  GIT_REPOSITORY https://github.com/doctest/doctest.git
  GIT_TAG 7b9885133108ae301ddd16e2651320f54cafeba7
)

# Populate
set (BUILD_TESTING OFF)
FetchContent_GetProperties (ftxui)
if (NOT ftxui_POPULATED)
  FetchContent_Populate (ftxui)
  add_subdirectory (${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL)
endif ()

FetchContent_Populate (treesitter)
set (BUILD_TESTING OFF)
enable_language (C)
add_library (tree-sitter STATIC "${treesitter_SOURCE_DIR}/lib/src/lib.c")
target_include_directories (tree-sitter
  PRIVATE
    "${treesitter_SOURCE_DIR}/lib/src"
  PUBLIC
    "${treesitter_SOURCE_DIR}/lib/include"
)

set (BUILD_TESTING OFF)
FetchContent_GetProperties (doctest)
if (NOT doctest_POPULATED)
  FetchContent_Populate (doctest)
  add_subdirectory (${doctest_SOURCE_DIR})
endif ()
