find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
set(PYBIND11_FINDPYTHON ON)

# Prefer a pybind11 provided by the environment (e.g. the build backend installs it as a build dependency); fall back to
# fetching it for standalone CMake builds.
find_package(pybind11 CONFIG QUIET)
if(NOT pybind11_FOUND)
	include(FetchContent)
	fetchcontent_declare(
		pybind11
		GIT_REPOSITORY https://github.com/pybind/pybind11.git
		GIT_TAG v2.13.6)
	fetchcontent_makeavailable(pybind11)
endif()

pybind11_add_module(aeveon_decoder_py MODULE aeveon_decoder.cpp)

set_target_properties(aeveon_decoder_py PROPERTIES OUTPUT_NAME aeveon_decoder)

target_link_libraries(aeveon_decoder_py PRIVATE aeveon_decoder::core aeveon_decoder::sinks Python3::Module)

target_compile_definitions(aeveon_decoder_py PRIVATE AEVEON_DECODER_VERSION="${VERSION}")

install(TARGETS aeveon_decoder_py DESTINATION ${Python3_SITEARCH})
