cmake_minimum_required(VERSION 3.24)
project(medwer LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(FetchContent)

# nlohmann/json (header-only; reads english.json + the golden fixtures).
FetchContent_Declare(
  json
  URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
FetchContent_MakeAvailable(json)

# utf8proc (Unicode NFKD + category + case mapping). Lets the C++ normalizer
# reproduce whisper-normalizer's Python diacritic folding exactly.
set(UTF8PROC_INSTALL OFF CACHE BOOL "" FORCE)
FetchContent_Declare(
  utf8proc
  GIT_REPOSITORY https://github.com/JuliaStrings/utf8proc.git
  GIT_TAG v2.9.0
  GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(utf8proc)

add_library(medwer STATIC src/normalizer.cpp src/wer.cpp)
target_include_directories(medwer PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(medwer PUBLIC nlohmann_json::nlohmann_json utf8proc)

enable_testing()
add_executable(test_parity tests/test_parity.cpp)
target_link_libraries(test_parity PRIVATE medwer nlohmann_json::nlohmann_json)
add_test(NAME parity COMMAND test_parity
  ${CMAKE_CURRENT_SOURCE_DIR}/../medwer/data/english.json
  ${CMAKE_CURRENT_SOURCE_DIR}/../fixtures/golden_wer.json)
