cmake_minimum_required(VERSION 3.21...4.0) # Propagate version dermined by scikit-build-core project( vtk-pyext VERSION ${SKBUILD_PROJECT_VERSION} DESCRIPTION "VTK SDK python distributions example" HOMEPAGE_URL "https://gitlab.kitware.com/vtk/vtk" 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) include(GNUInstallDirs) set(BUILD_SHARED_LIBS ON) set(CMAKE_INSTALL_LIBDIR ".") set(_vtk_module_library_destination "${CMAKE_INSTALL_LIBDIR}/vtk_pyext") set(_vtk_module_module_destination "${CMAKE_INSTALL_LIBDIR}") set(_vtk_module_runtime_destination "${CMAKE_INSTALL_BINDIR}") if (WIN32) # Ensure the dlls end up in lib/vtkmodules as well set(_vtk_module_runtime_destination "${CMAKE_INSTALL_LIBDIR}/vtk_pyext") elseif(APPLE) # These two rpaths are required, always add them list(APPEND CMAKE_INSTALL_RPATH "@loader_path" "@loader_path/../vtkmodules") else() # assumes Linux + GNU-based toolchain # required as the VTK wheels are build with the C++98 ABI list(APPEND CMAKE_CXX_FLAGS "-D_GLIBCXX_USE_CXX11_ABI=0") # These two rpaths are required, always add them list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN" "$ORIGIN/../vtkmodules") endif () # Search for "vtk.module" files in all subdirectories. vtk_module_find_modules(vtk_module_files ${CMAKE_CURRENT_SOURCE_DIR}) # Scan the module files. vtk_module_scan( MODULE_FILES ${vtk_module_files} REQUEST_MODULES Dummy::Dummy PROVIDES_MODULES my_modules ENABLE_TESTS "${BUILD_TESTING}" ) # Set up the module build. vtk_module_build( MODULES ${my_modules} INSTALL_EXPORT ${PROJECT_NAME}Python ARCHIVE_DESTINATION "lib" HEADERS_DESTINATION "include/vtk_pyext-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}" CMAKE_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/vtkDummy" LICENSE_DESTINATION "${CMAKE_INSTALL_LIBDIR}/vtk_pyext" HIERARCHY_DESTINATION "${CMAKE_INSTALL_LIBDIR}/vtk_pyext/hierarchy/${CMAKE_PROJECT_NAME}" RUNTIME_DESTINATION "${_vtk_module_runtime_destination}" LIBRARY_DESTINATION "${_vtk_module_library_destination}" VERSION ${PROJECT_VERSION} SOVERSION "1" ) # Perform the wrapping vtk_module_wrap_python( MODULES ${my_modules} INSTALL_EXPORT ${PROJECT_NAME}Python PYTHON_PACKAGE "vtk_pyext" SOABI "${Python${VTK_PYTHON_VERSION}_SOABI}" CMAKE_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/vtkDummy" LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}" MODULE_DESTINATION "${_vtk_module_module_destination}" BUILD_STATIC OFF )