cmake_minimum_required(VERSION 3.14)
project(arboris VERSION 0.1.0 LANGUAGES CXX)

# Project settings
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# include Modules
include(FetchContent)
include(CTest)

# Set up compile commands JSON for clang-tidy
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Download dependencies
if (NOT NO_TESTS)
  FetchContent_Declare(
    googletest
    URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
  )
  if (WIN32)
    set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
  endif()
  # googletest is a test dependency, not part of what `cmake --install` ships.
  set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
  FetchContent_MakeAvailable(googletest)
endif()

# html5lib-tests (https://github.com/html5lib/html5lib-tests), used by the tokenizer
# conformance test and the benchmark. Declared here so both use the same commit.
FetchContent_Declare(
  html5lib_tests
  URL https://github.com/html5lib/html5lib-tests/archive/224991ec10db04f056a89eed8b0bd8695fd2950e.zip
)

# Add subdirectories
add_subdirectory(src)

if (NOT NO_TESTS)
  add_subdirectory(tests)
endif()

# The benchmark needs uv and downloads its corpus, so it stays out of the default build.
option(ARBORIS_BENCHMARK "Build the tokenizer benchmark (benchmark/)" OFF)
if (ARBORIS_BENCHMARK)
  add_subdirectory(benchmark)
endif()

option(ARBORIS_PYTHON "Build the Python extension module (python/)" OFF)
if (ARBORIS_PYTHON)
  add_subdirectory(python)
endif()
