build: support Eigen 5 (#6036)

* build: support Eigen 5

fix #6034

* build: probe Eigen 3 and 5 separately in CMake config mode

Avoid relying on package-specific handling of a bounded version range when discovering Eigen through Eigen3Config.cmake.

Made-with: Cursor

* build: clarify Eigen 5 module fallback comment

Explain that the MODULE-mode fallback only exists for older Eigen 3 setups so the remaining fallback path does not look like an unresolved Eigen 5 issue.

Made-with: Cursor

* docs: add Eigen 5 entry to v3.0.4 changelog

Document the Eigen 5 CMake package detection fix in the 3.0.4 release notes before merging the PR.

Made-with: Cursor

---------

Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
This commit is contained in:
Eisuke Kawashima
2026-04-19 07:10:30 +09:00
committed by Ralf W. Grosse-Kunstleve
parent 3d8aabc041
commit d03662f098
2 changed files with 10 additions and 0 deletions

View File

@@ -17,6 +17,9 @@ entry" block in pull request descriptions.
Bug fixes:
- Fixed test builds with installed Eigen 5 by improving `Eigen3` CMake package detection.
[#6036](https://github.com/pybind/pybind11/pull/6036)
- Fixed move semantics of `scoped_ostream_redirect` to preserve buffered output and avoid crashes when moved redirects restore stream buffers.
[#6033](https://github.com/pybind/pybind11/pull/6033)

View File

@@ -300,10 +300,17 @@ if(PYBIND11_TEST_FILES_EIGEN_I GREATER -1)
else()
find_package(Eigen3 3.2.7 QUIET CONFIG)
if(NOT Eigen3_FOUND)
find_package(Eigen3 5 QUIET CONFIG)
endif()
set(EIGEN3_FOUND ${Eigen3_FOUND})
set(EIGEN3_VERSION ${Eigen3_VERSION})
if(NOT EIGEN3_FOUND)
# Couldn't load via target, so fall back to allowing module mode finding, which will pick up
# tools/FindEigen3.cmake
# This MODULE-mode fallback is for older Eigen 3 setups; Eigen 5 is expected to be found
# via the CONFIG-mode probes above.
find_package(Eigen3 3.2.7 QUIET)
endif()
endif()