@@ -198,46 +198,43 @@ find_package(nanobind CONFIG REQUIRED)
198198#
199199# Important: If you add a new .cpp file, you must rebuild the project with:
200200# pip install --no-build-isolation -ve . -Ceditable.rebuild=true
201- file (GLOB CPP_SOURCES
202- CONFIGURE_DEPENDS
203- "${CMAKE_CURRENT_SOURCE_DIR} /src/*.cpp"
204- )
205201
206- # Verify we found all expected source files and remind about type handling
207- message (STATUS "Found C++ source files (ensure proper type conversion in each):" )
202+ # Enhanced PCH configuration
203+ if (ENABLE_PRECOMPILED_HEADERS)
204+ set (CMAKE_PCH_INSTANTIATE_TEMPLATES ON )
205+ set (CMAKE_PCH_WARN_INVALID ON )
206+ endif ()
208207
209- foreach ( source ${CPP_SOURCES} )
210- message ( STATUS " ${source} " )
211- endforeach ( )
208+ # Function to add a nanobind module with include directories
209+ function (add_nanobind_module module_name source_file )
210+ nanobind_add_module( ${module_name} STABLE_ABI NB_STATIC ${source_file} )
212211
213- nanobind_add_module(
214- compas_cgal_ext
215- STABLE_ABI
216- NB_STATIC
217- ${CPP_SOURCES}
218- )
212+ target_include_directories (${module_name} PRIVATE
213+ ${CGAL_INCLUDE_DIR}
214+ ${BOOST_INCLUDE_DIR}
215+ ${EIGEN_INCLUDE_DIR}
216+ )
219217
220- # Set include directories for the extension
221- target_include_directories (compas_cgal_ext PRIVATE
222- ${CGAL_INCLUDE_DIR}
223- ${BOOST_INCLUDE_DIR}
224- ${EIGEN_INCLUDE_DIR}
225- )
218+ add_dependencies (${module_name} external_downloads)
226219
227- # Make sure external dependencies are downloaded before building the extension
228- add_dependencies (compas_cgal_ext external_downloads)
220+ if (ENABLE_PRECOMPILED_HEADERS)
221+ target_precompile_headers(${module_name} PRIVATE src/compas.h)
222+ endif ()
229223
230- if (ENABLE_PRECOMPILED_HEADERS)
231- # Enhanced PCH configuration
232- set (CMAKE_PCH_INSTANTIATE_TEMPLATES ON )
233- set (CMAKE_PCH_WARN_INVALID ON )
224+ install (TARGETS ${module_name} LIBRARY DESTINATION compas_cgal)
225+ endfunction ()
226+
227+ # Add new modules here
228+ add_nanobind_module(types_std src/types_std.cpp)
229+ add_nanobind_module(booleans_ext src/booleans.cpp)
230+ add_nanobind_module(meshing_ext src/meshing.cpp)
231+ add_nanobind_module(intersections_ext src/intersections.cpp)
232+ add_nanobind_module(measure_ext src/measure.cpp)
233+ add_nanobind_module(reconstruction_ext src/reconstruction.cpp)
234+ add_nanobind_module(skeletonization_ext src/skeletonization.cpp)
235+ add_nanobind_module(slicer_ext src/slicer.cpp)
236+ add_nanobind_module(straight_skeleton_2_ext src/straight_skeleton_2.cpp)
237+ add_nanobind_module(triangulation_ext src/triangulation.cpp)
238+ add_nanobind_module(subdivision_ext src/subdivision.cpp)
234239
235- # Configure PCH for the extension
236- target_precompile_headers(compas_cgal_ext
237- PRIVATE
238- src/compas.h
239- )
240- endif ()
241240
242- # Install directive for scikit-build-core
243- install (TARGETS compas_cgal_ext LIBRARY DESTINATION compas_cgal)
0 commit comments