cmake_minimum_required(VERSION 3.18)
project(ntsc_encoder LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
find_package(pybind11 CONFIG REQUIRED)

# Build the extension without linking against OpenCV.
# The Python side still can use cv2, but this module only needs raw RGB bytes.
pybind11_add_module(ntsc_encoder src/wrapper.cpp)

# scikit-build-core builds wheels from CMake install() output.
# The extension must be installed into the Python platlib directory.
if (DEFINED SKBUILD_PLATLIB_DIR)
  set(_PY_PLATLIB_DIR "${SKBUILD_PLATLIB_DIR}")
else()
  set(_PY_PLATLIB_DIR ".")
endif()

install(TARGETS ntsc_encoder
  LIBRARY DESTINATION "${_PY_PLATLIB_DIR}"
  RUNTIME DESTINATION "${_PY_PLATLIB_DIR}"
)
