From d03662f0984f652b60e7ddce53d3868002275197 Mon Sep 17 00:00:00 2001 From: Eisuke Kawashima Date: Sun, 19 Apr 2026 07:10:30 +0900 Subject: [PATCH] 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 Co-authored-by: Ralf W. Grosse-Kunstleve --- docs/changelog.md | 3 +++ tests/CMakeLists.txt | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 37a3efbb3..ecff9705e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -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) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d5d597cdf..fc08a9056 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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()