cmake_minimum_required(VERSION 3.25)
project(python_simple_frames)

set(CMAKE_CXX_STANDARD 14)

SET( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/config" )

find_package(PkgConfig)
find_package(FrameCPP REQUIRED)
find_package(Python COMPONENTS Interpreter Development)
find_package(pybind11 CONFIG)

# generate relative python install directories
get_filename_component(Python_PKG_ARCH_DIR ${Python_SITEARCH} NAME)
get_filename_component(Python_ARCH_BASE_DIR ${Python_SITEARCH} DIRECTORY)
get_filename_component(Python_PYTHON_ARCH_DIR ${Python_ARCH_BASE_DIR} NAME)
SET(Python_ARCH_INSTALL_DIR lib/${Python_PYTHON_ARCH_DIR}/${Python_PKG_ARCH_DIR})

MESSAGE(STATUS "Python version: ${Python_VERSION}")
MESSAGE(STATUS "Python site arch: ${Python_SITEARCH}")
MESSAGE(STATUS "Python arch install dir: ${Python_ARCH_INSTALL_DIR}")
MESSAGE(STATUS "Python include dirs: ${Python_INCLUDE_DIRS}")
MESSAGE(STATUS "Python libraries: ${Python_LIBRARIES}")
MESSAGE(STATUS "Python library dirs: ${Python_LIBRARY_DIRS}")
MESSAGE(STATUS "Python sitelib: ${Python_SITELIB}")
MESSAGE(STATUS "Python development found: ${Python_Development_FOUND}")

pybind11_add_module(simple_frames MODULE simple_frames.cc)
target_link_libraries(simple_frames PRIVATE ldastools::framecpp)

install(TARGETS simple_frames DESTINATION "${Python_ARCH_INSTALL_DIR}")