cmake_minimum_required(VERSION 3.27...3.31) # min required because of VTK::x11

project(${SKBUILD_PROJECT_NAME}
  VERSION ${SKBUILD_PROJECT_VERSION}
  LANGUAGES CXX
)

# Find the VTK-SDK provided VTK package
# It will be found in a temporary folder generated by scikit-build-core
# thanks to the [entry-point mecanism](https://github.com/Kitware/vtk-sdk-python-distributions)
find_package(VTK CONFIG REQUIRED COMPONENTS CommonCore Python)
# this is a workaround for a VTK-SDK issue on Windows, caused by vtkRenderingOpenXR module.
# This should later become the only find_package, and it should be REQUIRED!
# See https://gitlab.kitware.com/vtk/vtk/-/merge_requests/12363 for more info
find_package(VTK CONFIG QUIET)

list(REMOVE_ITEM VTK_LIBRARIES 
  # Public dependency to OpenXR loader makes these hard to import, ignore them
  VTK::RenderingOpenXR
  VTK::RenderingOpenXRRemoting
)

list(JOIN VTK_LIBRARIES "\n  " VTK_LIBRARIES)
configure_file(
  ${CMAKE_CURRENT_SOURCE_DIR}/vtk.module.in
  ${CMAKE_CURRENT_SOURCE_DIR}/Dummy/vtk.module
  @ONLY
)

set(modules Dummy::Dummy)

include(VTKSDKPythonWheelHelper)
vtksdk_build_modules(${SKBUILD_PROJECT_NAME} MODULES ${modules})
vtksdk_generate_package_init(${SKBUILD_PROJECT_NAME} MODULES ${modules})
