cmake_minimum_required(VERSION 3.28)

set(PROJECT_VER 0.1.5)

project(
  cecxx
  DESCRIPTION "An implementation of IEEE CECs benchmarks in C++23."
  LANGUAGES CXX
  VERSION ${PROJECT_VER}
)

option(
  CECXX_BUILD_COMPLIANCE_TESTS
  "Enable building compliance tests with original IEEE CEC implementations."
)

option(
  CECXX_BUILD_UNIT_TESTS
  "Enable building unit tests of cecxx."
)

option(
  CECXX_BUILD_EXAMPLES
  "Enable bulding cecxx's examples."
)

option(
  CECXX_BUILD_PYTHON_BINDINGS
  "Enable building python bindings to the cecxx library"
)

set(
  CECXX_BENCHMARK_DATA_STORAGE_INSTALL_DIR "$ENV{HOME}/.local/state/cecxx"
  CACHE PATH
  "Location of cecxx storage for benchmark's data (rotation matrix, etc.)"
)

add_library(cecxx)
add_library(cecxx::cecxx ALIAS cecxx)
set_target_properties(cecxx PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON)
add_subdirectory(src)

if (CECXX_BUILD_EXAMPLES)
  add_subdirectory(examples/cxx/evaluator)
endif()

if (CECXX_BUILD_PYTHON_BINDINGS)
  add_subdirectory(python)
endif()

if(CECXX_BUILD_UNIT_TESTS)
  enable_testing()
  add_subdirectory(tests/cxx/unit)
endif()

if(CECXX_BUILD_COMPLIANCE_TESTS)
  enable_testing()
  if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
    add_subdirectory(third-party/fuzztest)
  else()
    message(
      FATAL_ERROR
      "To build compliance tests, LLVM toolchain is required."
    )
  endif()
  add_subdirectory(tests/cxx/compliance)
endif()

include(infra/cmake/install-cecxx-library.cmake)
