Skip to content

fix CMake not finding MPI#179

Open
s-ol wants to merge 2 commits into
CadQuery:masterfrom
s-ol:fix-cmake-mpi
Open

fix CMake not finding MPI#179
s-ol wants to merge 2 commits into
CadQuery:masterfrom
s-ol:fix-cmake-mpi

Conversation

@s-ol

@s-ol s-ol commented Aug 18, 2025

Copy link
Copy Markdown

Building OCP 7.8.1.2 on Arch Linux against vtk 9.5.0 currently fails in the CMake Configuration stage:

CMake Error at /usr/lib/cmake/vtk/VTK-targets.cmake:1897 (set_target_properties):
  The link interface of target "VTK::mpi" contains:

    MPI::MPI_C

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  /usr/lib/cmake/vtk/vtk-config.cmake:147 (include)
  CMakeLists.txt:8 (find_package)

This patch adds mpi to the VTK components to search for, resolving this issue.

@adam-urbanczyk

Copy link
Copy Markdown
Member

Does fail CI, so not mergable as-is.

elliejs added a commit to elliejs/pywrap that referenced this pull request Jun 25, 2026
Several bugs in the binding generator caused incorrect or missing C++
code in the generated pybind11 bindings. These affect all platforms.

header.py — type resolution (_underlying_type):
  Nested types defined inside template classes (typedefs like
  value_type, enums like BehaviorOnTransform, POD types like
  size_type) were emitted as bare names without their enclosing class
  qualification. In generated static_cast expressions, the compiler
  cannot resolve a bare "value_type" — it needs the fully qualified
  "NCollection_Array1<T>::value_type". Three new blocks handle this:
  non-POD typedefs (134 types), POD typedefs (3 types), and nested
  enums/records (17 types). The non-POD typedef block also fixes a
  corruption pattern where the upstream replace() call could produce
  "X<T>::typename X<T>::Y", and prevents double typename prefixes.

header.py — default values (_default_value):
  Fix a typo in the ArgInfo dataclass field name: "arg_defualt" was
  never matching what Jinja2 templates reference as "arg_default".
  This silently dropped every default parameter value for every
  function on every platform. Also strip "const" from brace-init
  defaults — "const gp_Pnt{ }" is a syntax error (8 parameters).

macros.j2 — default value emission:
  The argnames macro had {% if d %} where d is undefined in Jinja2
  (always falsy), so default values were never emitted even if
  header.py produced them. Fixed to {% if arg.arg_default %}.

  New default_value macro handles null pointer defaults correctly:
  pybind11 expects py::none() for optional pointer arguments, not
  static_cast<T*>(0) which was previously emitted (40 parameters).

  Fix arg.name → arg.arg_name in init_outputs_byref — the ArgInfo
  dataclass field is arg_name. The undefined arg.name produced empty
  variable names in generated C++ for by-reference smart pointer
  methods.

macros.j2 — template type qualification:
  arg_type_with_template_params had a bug where it checked the raw
  input string t instead of ns.t, and only handled types starting
  with the bare class name (ClassName::member). Types where the class
  name already had template params (ClassName<T>::Iterator) were not
  qualified with typename, causing compile failures. Added a second
  branch for this case. Same fix applied to template_return_type.

  New argtypes_for_template macro applies template type qualification
  to py::init<> type lists. Without this, template class constructor
  argument types were emitted without typename qualification, causing
  dependent name lookup failures.

  Removed dead inline type-expansion code in argnames_template that
  computed a namespace variable ns.t which was never used — the
  actual default emission already called arg_type_with_template_params.

macros.j2 — trampoline class deduplication:
  Pure virtual method deduplication compared by short name (m.name),
  so overloaded virtuals like Values(Vec&, Real&, Vec&) and
  Values(Vec&, Real&, Vec&, Mat&) were treated as duplicates. Changed
  to use m.full_name (full signature). Also added the missing
  methods.append call for private virtuals, which allowed parent-class
  loops to re-emit methods already overridden. 20 classes affected.

CMakeLists.j2 (all-platform changes):
  Bump cmake_minimum_required to 3.17. Add enable_language(C) on
  non-Windows platforms (required when VTK links MPI::MPI_C). Add
  find_package(MPI QUIET) so cmake can resolve MPI::MPI_C and
  MPI::MPI_CXX targets referenced by VTK builds that include MPI
  support (resolves CadQuery/OCP#179). Add find_package(fmt) and link
  fmt::fmt — FreeBSD's OCCT port links against libfmt externally,
  while conda builds bundle it statically so this is a no-op there.
  Add status messages for Python lib path and VTK version to aid CI
  debugging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
elliejs added a commit to elliejs/pywrap that referenced this pull request Jun 25, 2026
Several bugs in the binding generator caused incorrect or missing C++
code in the generated pybind11 bindings. These affect all platforms.

header.py — type resolution (_underlying_type):
  Nested types defined inside template classes (typedefs like
  value_type, enums like BehaviorOnTransform, POD types like
  size_type) were emitted as bare names without their enclosing class
  qualification. In generated static_cast expressions, the compiler
  cannot resolve a bare "value_type" — it needs the fully qualified
  "NCollection_Array1<T>::value_type". Three new blocks handle this:
  non-POD typedefs (134 types), POD typedefs (3 types), and nested
  enums/records (17 types). The non-POD typedef block also fixes a
  corruption pattern where the upstream replace() call could produce
  "X<T>::typename X<T>::Y", and prevents double typename prefixes.

header.py — default values (_default_value):
  Fix a typo in the ArgInfo dataclass field name: "arg_defualt" was
  never matching what Jinja2 templates reference as "arg_default".
  This silently dropped every default parameter value for every
  function on every platform. Also strip "const" from brace-init
  defaults — "const gp_Pnt{ }" is a syntax error (8 parameters).

macros.j2 — default value emission:
  The argnames macro had {% if d %} where d is undefined in Jinja2
  (always falsy), so default values were never emitted even if
  header.py produced them. Fixed to {% if arg.arg_default %}.

  New default_value macro handles null pointer defaults correctly:
  pybind11 expects py::none() for optional pointer arguments, not
  static_cast<T*>(0) which was previously emitted (40 parameters).

  Fix arg.name → arg.arg_name in init_outputs_byref — the ArgInfo
  dataclass field is arg_name. The undefined arg.name produced empty
  variable names in generated C++ for by-reference smart pointer
  methods.

macros.j2 — template type qualification:
  arg_type_with_template_params had a bug where it checked the raw
  input string t instead of ns.t, and only handled types starting
  with the bare class name (ClassName::member). Types where the class
  name already had template params (ClassName<T>::Iterator) were not
  qualified with typename, causing compile failures. Added a second
  branch for this case. Same fix applied to template_return_type.

  New argtypes_for_template macro applies template type qualification
  to py::init<> type lists. Without this, template class constructor
  argument types were emitted without typename qualification, causing
  dependent name lookup failures.

  Removed dead inline type-expansion code in argnames_template that
  computed a namespace variable ns.t which was never used — the
  actual default emission already called arg_type_with_template_params.

macros.j2 — trampoline class deduplication:
  Pure virtual method deduplication compared by short name (m.name),
  so overloaded virtuals like Values(Vec&, Real&, Vec&) and
  Values(Vec&, Real&, Vec&, Mat&) were treated as duplicates. Changed
  to use m.full_name (full signature). Also added the missing
  methods.append call for private virtuals, which allowed parent-class
  loops to re-emit methods already overridden. 20 classes affected.

CMakeLists.j2:
  Bump cmake_minimum_required to 3.17. Enable C language (needed when
  VTK links against MPI::MPI_C). Add find_package(MPI QUIET) so cmake
  can resolve MPI::MPI_C and MPI::MPI_CXX targets on platforms where
  VTK is built with MPI support (resolves CadQuery/OCP#179). Add
  find_package(fmt) and link fmt::fmt — FreeBSD's OCCT port links
  against libfmt externally, while conda builds bundle it statically
  so this is a no-op there. Add status messages for Python lib path
  and VTK version to aid CI debugging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants