Skip to content

Fix build on modern CMake 4 / pybind11 / conda toolchains#114

Open
Wenri wants to merge 3 commits into
fwilliams:masterfrom
Wenri:fix/manifold-target-compile-options
Open

Fix build on modern CMake 4 / pybind11 / conda toolchains#114
Wenri wants to merge 3 commits into
fwilliams:masterfrom
Wenri:fix/manifold-target-compile-options

Conversation

@Wenri

@Wenri Wenri commented Jun 23, 2026

Copy link
Copy Markdown

Building point-cloud-utils (v0.35.0) on a current toolchain — Linux
x86_64, Python 3.14, a conda GCC 13.2 toolchain, CMake 4, torch 2.12 /
numpy 2 — hits three independent build failures. Each commit fixes one.

1. manifold target_compile_options passes CMAKE_CXX_FLAGS as one arg

target_compile_options(manifold PRIVATE "${CMAKE_CXX_FLAGS} -DWITH_OMP ")

target_compile_options treats each argument as a single option, so the
quoted string is handed to the compiler as one bogus argument. When
CMAKE_CXX_FLAGS is non-empty (e.g. conda exports
CXXFLAGS="-fvisibility-inlines-hidden -march=nocona ...") the build fails:

g++: error: unrecognized command-line option
     '-fvisibility-inlines-hidden -fmessage-length=0 ... -DWITH_OMP '

CMAKE_CXX_FLAGS is already applied to every target by CMake, so
re-injecting it here is redundant as well as broken. Pass the
manifold-specific flags unquoted as separate options.

2. pybind11 dtype::elsize() removed — use itemsize()

pybind11::dtype::elsize() is not present in current pybind11 (required
for Python 3.14 / NumPy 2 support). src/common/ply_loader.h fails with:

error: 'class pybind11::dtype' has no member named 'elsize'; did you mean 'itemsize'?

itemsize() is the equivalent accessor.

3. Pin build-time CMake < 4

The numpyeigen dependency fetched at configure time declares
cmake_minimum_required below 3.5, support for which CMake 4 removed
(hard error). Constraining the build-system requirement lets an isolated
build resolve a 3.x CMake. (Happy to drop this commit if you'd rather fix
the policy version on the numpyeigen side instead.)

With all three, the wheel builds cleanly and pcu.chamfer_distance etc.
work on Python 3.14.

Wenri added 3 commits June 23, 2026 14:57
target_compile_options() treats each argument as a single compiler
option, so "${CMAKE_CXX_FLAGS} -DWITH_OMP" is handed to the compiler as
one bogus argument. When CMAKE_CXX_FLAGS is non-empty (e.g. conda's
compilers export CXXFLAGS="-fvisibility-inlines-hidden -march=nocona
...") the manifold build fails with:

  g++: error: unrecognized command-line option
       '-fvisibility-inlines-hidden -fmessage-length=0 ... -DWITH_OMP '

CMAKE_CXX_FLAGS is already applied to every target by CMake, so
re-injecting it via target_compile_options is both redundant and broken.
Pass the manifold-specific flags unquoted as separate options instead.
The numpyeigen dependency fetched at configure time declares
cmake_minimum_required below 3.5, support for which CMake 4 removed
(hard error). Constrain the build-system requirement so an isolated
build resolves a 3.x CMake that still accepts those projects.
pybind11::dtype::elsize() is not present in current pybind11 (required
for Python 3.14 / NumPy 2 support); the equivalent accessor is
itemsize(). Fixes the meshio build:
  ply_loader.h:77: error: 'class pybind11::dtype' has no member named
  'elsize'; did you mean 'itemsize'?
Copilot AI review requested due to automatic review settings June 23, 2026 15:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses three independent build failures encountered when building point-cloud-utils with a modern Python/Numpy/pybind11 stack and conda toolchains, by updating pybind11 dtype usage, fixing a CMake target_compile_options misuse for the manifold dependency, and constraining the build-time CMake version used by PEP 517 builds.

Changes:

  • Replace deprecated/removed pybind11::dtype::elsize() usage with itemsize().
  • Fix manifold compile options so flags are passed as discrete options rather than as a single quoted string.
  • Pin PEP 517 build-system CMake requirement to <4 to avoid hard failures from a configure-time dependency with an outdated cmake_minimum_required.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/common/ply_loader.h Updates pybind11 dtype size accessor for newer pybind11/NumPy compatibility.
pyproject.toml Pins build-time CMake to <4 for isolated builds.
CMakeLists.txt Fixes manifold target compile options handling to avoid passing CMAKE_CXX_FLAGS as a single compiler argument.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/common/ply_loader.h
return pybind11::array(attrib_dtype, std::vector<size_t>({0, 0}));
}
size_t bytes_per_scalar = attrib_dtype.elsize();
size_t bytes_per_scalar = attrib_dtype.itemsize();
Comment thread pyproject.toml
@@ -1,3 +1,3 @@
[build-system]
requires = ["setuptools>=42", "wheel", "scipy", "numpy", "cmake>=3.2"]
requires = ["setuptools>=42", "wheel", "scipy", "numpy", "cmake>=3.2,<4"]
Comment thread CMakeLists.txt
target_include_directories(manifold PRIVATE ${EXTERNAL_DEP_DIR}/manifold/3rd)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(manifold PRIVATE "${CMAKE_CXX_FLAGS} -Wall -pthread -DWITH_OMP -Wno-int-in-bool-context -Wsign-compare -fsanitize=address")
target_compile_options(manifold PRIVATE -Wall -pthread -DWITH_OMP -Wno-int-in-bool-context -Wsign-compare -fsanitize=address)
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