Files
ocp/CMakeLists.txt
stroblme 0ce43a94aa 10C Inc 2: feature tail
119 of the app's 138 symbols now resolve; only the I/O modules and the Inc 4
tail are left. New: GCE2d, GCPnts, BRepFilletAPI, BRepOffsetAPI,
ShapeAnalysis, ShapeFix, ShapeUpgrade, BRepCheck, BRepTools, BRepLib,
BRepExtrema, BRepClass3d, IntCurvesFace, plus TopTools_HSequenceOfShape.

The fillet and chamfer builders derive BRepBuilderAPI_MakeShape, so their
history comes from the base bound in Inc 1 — which is what lets the app read a
blend's provenance the same way it reads a boolean's. The Inc 2 gate compares
that history exactly, alongside the splitter's, which is what sketch-region
attribution depends on.

Two shapes of deviation, both commented where they are bound:

- Trailing enum arguments are left off four constructors (fillet's
  ChFi3d_FilletShape, MakeThickSolidByJoin's mode/join pair, BRepExtrema's
  Extrema flags, and Inc 1's GeomAPI_ProjectPointOnSurf). An unregistered enum
  cannot serve as a default argument — nanobind converts defaults at binding
  time, so it fails the whole module's import with std::bad_cast. The app never
  overrides any of them, so OCCT's own defaults apply and behaviour is
  unchanged.
- ShapeAnalysis_FreeBounds.ConnectEdgesToWires reassigns a Handle& out
  parameter, which the caster cannot honour because it hands C++ a copy of the
  handle. The lambda splices the result into the sequence the caller passed, so
  the pass-empty-then-read shape the app uses still works. This is the one
  place upstream's holder semantics and ours differ observably.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DfriM8XUkn7uYf5Dwe2xo6
2026-08-10 20:09:29 +02:00

75 lines
2.3 KiB
CMake

cmake_minimum_required(VERSION 3.20)
project(n3xd_ocp LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# Match the kernel's flags: -O2, no fast-math, no -march=native. OCCT's
# version is a determinism input for assay's committed goldens, so the binding
# has no business introducing a different FP contract than the kernel it wraps.
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
find_package(Python 3.12 REQUIRED
COMPONENTS Interpreter Development.Module Development.SABIModule)
find_package(nanobind CONFIG REQUIRED)
find_package(OpenCASCADE REQUIRED)
# The version scheme is enforced, not merely conventional: a wheel labelled
# 7.9.3.N must actually wrap OCCT 7.9.3.
set(_occt_ver "${OpenCASCADE_MAJOR_VERSION}.${OpenCASCADE_MINOR_VERSION}.${OpenCASCADE_MAINTENANCE_VERSION}")
if(DEFINED SKBUILD_PROJECT_VERSION)
if(NOT SKBUILD_PROJECT_VERSION MATCHES "^${_occt_ver}\\.")
message(FATAL_ERROR
"Version '${SKBUILD_PROJECT_VERSION}' does not match the OCCT found "
"(${_occt_ver}). The scheme is <occt-version>.N — see pyproject.toml.")
endif()
endif()
message(STATUS "Building n3xd-ocp against OCCT ${_occt_ver}")
file(GLOB OCP_MODULE_SOURCES CONFIGURE_DEPENDS "src/modules/*.cpp")
file(GLOB OCP_EXT_SOURCES CONFIGURE_DEPENDS "src/ext/*.cpp")
nanobind_add_module(_OCP
STABLE_ABI
NB_STATIC
src/core.cpp
src/common/occt_module.cpp
src/common/occt_exceptions.cpp
${OCP_MODULE_SOURCES}
${OCP_EXT_SOURCES}
)
target_include_directories(_OCP PRIVATE ${OpenCASCADE_INCLUDE_DIR})
# Only the toolkits the bound surface actually reaches. Grows with each
# coverage increment; auditwheel bundles whatever the linker records.
target_link_libraries(_OCP PRIVATE
TKernel
TKMath
TKG2d
TKG3d
TKGeomBase
TKBRep
TKTopAlgo
# Inc 1
TKGeomAlgo # GeomAPI, GCPnts
TKPrim # BRepPrimAPI
TKBO # BRepAlgoAPI, BOPAlgo
TKMesh # BRepMesh
# Inc 2
TKFillet # BRepFilletAPI
TKOffset # BRepOffsetAPI
TKShHealing # ShapeFix, ShapeAnalysis, ShapeUpgrade
TKBool # BRepAlgo helpers pulled in by the above
)
target_compile_definitions(_OCP PRIVATE
N3XD_OCP_VERSION="${SKBUILD_PROJECT_VERSION}"
)
install(TARGETS _OCP LIBRARY DESTINATION OCP)