Fix build on modern CMake 4 / pybind11 / conda toolchains#114
Open
Wenri wants to merge 3 commits into
Open
Conversation
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'?
There was a problem hiding this comment.
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 withitemsize(). - Fix
manifoldcompile options so flags are passed as discrete options rather than as a single quoted string. - Pin PEP 517 build-system CMake requirement to
<4to avoid hard failures from a configure-time dependency with an outdatedcmake_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.
| 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(); |
| @@ -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"] | |||
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Building
point-cloud-utils(v0.35.0) on a current toolchain — Linuxx86_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.
manifoldtarget_compile_optionspassesCMAKE_CXX_FLAGSas one argtarget_compile_optionstreats each argument as a single option, so thequoted string is handed to the compiler as one bogus argument. When
CMAKE_CXX_FLAGSis non-empty (e.g. conda exportsCXXFLAGS="-fvisibility-inlines-hidden -march=nocona ...") the build fails:CMAKE_CXX_FLAGSis already applied to every target by CMake, sore-injecting it here is redundant as well as broken. Pass the
manifold-specific flags unquoted as separate options.
2. pybind11
dtype::elsize()removed — useitemsize()pybind11::dtype::elsize()is not present in current pybind11 (requiredfor Python 3.14 / NumPy 2 support).
src/common/ply_loader.hfails with:itemsize()is the equivalent accessor.3. Pin build-time CMake < 4
The
numpyeigendependency fetched at configure time declarescmake_minimum_requiredbelow 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_distanceetc.work on Python 3.14.