cmake_minimum_required(VERSION 3.15)
project(poreflow_changepoint)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Find Python
find_package(Python 3.11 COMPONENTS Interpreter Development.Module REQUIRED)

# Find NumPy
execute_process(
  COMMAND "${Python_EXECUTABLE}" -c "import numpy; print(numpy.get_include())"
  OUTPUT_VARIABLE Python_NumPy_INCLUDE_DIR
  OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Fetch Eigen
include(FetchContent)
FetchContent_Declare(
  Eigen3
  GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
  GIT_TAG 3.4.0
  GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(Eigen3)

# Define the extension module
python_add_library(_changepoint MODULE src/poreflow/feature_extraction/_changepoint.cpp)

# Include directories
target_include_directories(_changepoint PRIVATE 
    ${Python_NumPy_INCLUDE_DIR}
    ${Eigen3_SOURCE_DIR}
)

# Install location
install(TARGETS _changepoint DESTINATION poreflow/feature_extraction)
