CMake find_package version range fails matching 5.0.0

Summary

I'm trying to compile a project that is compatible with both Eigen v3.4 and v5 using CMake

find_package (Eigen3 3.4 REQUIRED NO_MODULE)

which typically means "3.4 or any later version". However due to some custom version matching in Eigen's generated Eigen3ConfigVersion.cmake this fails with

CMake Error at CMakeLists.txt:2 (find_package):
  Could not find a configuration file for package "Eigen3" that is compatible
  with requested version "3.4".

  The following configuration files were considered but not accepted:

    /usr/share/eigen3/cmake/Eigen3Config.cmake, version: 5.0.0

Changing the version range to any of these didn't help:

  • 3.4...5.0
  • 3.4...<6.0

Setting it to only 5.0 works but will throw an error if only 3.4 is present.

Environment

  • Operating System : Arch Linux
  • Architecture : x86_64
  • Eigen Version : 5.0.0
  • Compiler Version : gcc 15.2.1
  • Compile Flags :
  • Vector Extension :

Minimal Example

Steps to reproduce

create a src/CMakeLists.txt:

cmake_minimum_required(VERSION 3.15)
find_package (Eigen3 3.4 REQUIRED NO_MODULE)

then run

cmake -B build src

What is the current bug behavior?

CMake doesn't find a matching Eigen version despite 5.0.0 being installed.

What is the expected correct behavior?

CMake should successfully find and accept the installed Eigen version.

  • Have a plan to fix this issue.