new file mode 100644
@@ -0,0 +1,91 @@
+From f9b7b6651b108136a16df44d91fb31735645f5a7 Mon Sep 17 00:00:00 2001
+From: Sergiu Deitsch <sergiu.deitsch@gmail.com>
+Date: Sun, 28 Sep 2025 08:35:06 +0200
+Subject: [PATCH] Support Eigen3 5.0.0
+
+Change-Id: I5cf476a6d8c090861f4ea4a254a35d39e36a6d68
+
+Adjusted for 2.2.0, which still requires Eigen 3.3 instead of 3.3.4.
+
+Upstream-Status: Backport [https://github.com/ceres-solver/ceres-solver/commit/f9b7b6651b108136a16df44d91fb31735645f5a7]
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+ CMakeLists.txt | 27 ++++++++++++++++++++++++++-
+ internal/ceres/covariance_impl.cc | 5 +++++
+ internal/ceres/invert_psd_matrix.h | 4 ++++
+ 3 files changed, 35 insertions(+), 1 deletion(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 8e49c19..a186e99 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -180,9 +180,34 @@ endif (IOS)
+
+ unset(CERES_COMPILE_OPTIONS)
+
++# We call find_package multiple time with different versioning scheme to support
++# both Eigen3 3.x and 5.x. If the first invocation fails and Eigen3_DIR was set
++# to a possible location, e.g., during cross-compilation, failure to locate the
++# package will unset the variable. To avoid losing the path hint, we save it and
++# reuse it in the second find_package call.
++set (_Ceres_Eigen3_DIR)
++
++if (Eigen3_DIR)
++ set (_Ceres_Eigen3_DIR "${Eigen3_DIR}")
++endif (Eigen3_DIR)
++
+ # Eigen.
+ # Eigen delivers Eigen3Config.cmake since v3.3.3
+-find_package(Eigen3 3.3 REQUIRED)
++find_package(Eigen3 3.3...5 NO_MODULE)
++
++if (NOT Eigen3_FOUND)
++ if (_Ceres_Eigen3_DIR)
++ set (Eigen3_DIR "${_Ceres_Eigen3_DIR}")
++ endif (_Ceres_Eigen3_DIR)
++ # Eigen3's CMake package config prior to 5.0.0 does not support version ranges
++ # with different major version components. To ensure backward compatibility,
++ # we locate the package using the previous version scheme as a fallback
++ # mechanism.
++ find_package(Eigen3 3.3 REQUIRED)
++endif (NOT Eigen3_FOUND)
++
++unset (_Ceres_Eigen3_DIR)
++
+ if (Eigen3_FOUND)
+ message("-- Found Eigen version ${Eigen3_VERSION}: ${Eigen3_DIR}")
+ if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)" AND
+diff --git a/internal/ceres/covariance_impl.cc b/internal/ceres/covariance_impl.cc
+index 6e8362d..deb0ce1 100644
+--- a/internal/ceres/covariance_impl.cc
++++ b/internal/ceres/covariance_impl.cc
+@@ -723,8 +723,13 @@ bool CovarianceImpl::ComputeCovarianceValuesUsingDenseSVD() {
+ }
+ event_logger.AddEvent("ConvertToDenseMatrix");
+
++#if EIGEN_VERSION_AT_LEAST(5, 0, 0)
++ Eigen::BDCSVD<Matrix, Eigen::ComputeThinU | Eigen::ComputeThinV> svd(
++ dense_jacobian);
++#else // !EIGEN_VERSION_AT_LEAST(5, 0, 0)
+ Eigen::BDCSVD<Matrix> svd(dense_jacobian,
+ Eigen::ComputeThinU | Eigen::ComputeThinV);
++#endif // EIGEN_VERSION_AT_LEAST(5, 0, 0)
+
+ event_logger.AddEvent("SingularValueDecomposition");
+
+diff --git a/internal/ceres/invert_psd_matrix.h b/internal/ceres/invert_psd_matrix.h
+index bc74900..34a4698 100644
+--- a/internal/ceres/invert_psd_matrix.h
++++ b/internal/ceres/invert_psd_matrix.h
+@@ -68,7 +68,11 @@ typename EigenTypes<kSize, kSize>::Matrix InvertPSDMatrix(
+
+ // For a thin SVD the number of columns of the matrix need to be dynamic.
+ using SVDMType = typename EigenTypes<kSize, Eigen::Dynamic>::Matrix;
++#if EIGEN_VERSION_AT_LEAST(5, 0, 0)
++ Eigen::JacobiSVD<SVDMType, Eigen::ComputeThinU | Eigen::ComputeThinV> svd(m);
++#else // !EIGEN_VERSION_AT_LEAST(5, 0, 0)
+ Eigen::JacobiSVD<SVDMType> svd(m, Eigen::ComputeThinU | Eigen::ComputeThinV);
++#endif // EIGEN_VERSION_AT_LEAST(5, 0, 0)
+ return svd.solve(MType::Identity(size, size));
+ }
+
@@ -5,8 +5,11 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=3585a26c9cd9ec0cb36a7d65542878ca"
DEPENDS = "libeigen"
-SRC_URI = "git://github.com/ceres-solver/ceres-solver.git;branch=master;protocol=https"
+SRC_URI = "git://github.com/ceres-solver/ceres-solver.git;branch=master;protocol=https \
+ file://0001-Support-Eigen3-5.0.0.patch \
+ "
SRCREV = "85331393dc0dff09f6fb9903ab0c4bfa3e134b01"
+UPSTREAM_CHECK_GITTAGREGEX = "^(?P<pver>\d+(\.\d+)+)$"
inherit cmake
Eigen 5.0 uses strict version matching in Eigen3ConfigVersion.cmake, so find_package(Eigen3 3.3) rejects 5.0.x and configure fails. Its runtime thin/full SVD options are also deprecated in favour of compile-time options. Backport the upstream fix, which searches for the version range 3.3...5 first and falls back to the old lookup for Eigen 3.x configs, and uses compile-time SVD options with Eigen >= 5. The CMake hunk is adjusted for 2.2.0, whose minimum is Eigen 3.3 instead of 3.3.4. Add UPSTREAM_CHECK_GITTAGREGEX matching release tags only. AI-Generated: Uses Claude Code Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com> --- .../0001-Support-Eigen3-5.0.0.patch | 91 +++++++++++++++++++ .../ceres-solver/ceres-solver_2.2.0.bb | 5 +- 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 meta-oe/recipes-support/ceres-solver/ceres-solver/0001-Support-Eigen3-5.0.0.patch