Skip to content

Commit 53a357d

Browse files
committed
Switch to Eigen/CMake's FindEigen3.
1 parent 705a05e commit 53a357d

File tree

2 files changed

+16
-111
lines changed

2 files changed

+16
-111
lines changed

CMakeLists.txt

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -802,34 +802,22 @@ endif(UDUNITS2)
802802
# -DEIGEN3=ON|OFF
803803
# -DEIGEN3DIR=DIR
804804
if(EIGEN3)
805-
# cleaning Cache ...
806-
if (EIGEN3DIR)
807-
unset(EIGEN3_INCLUDE_DIR CACHE)
808-
endif(EIGEN3DIR)
809-
#
810-
set(CMAKE_PREFIX_PATH ${EIGEN3DIR})
811-
find_package(Eigen3 3.2.4 QUIET)
812-
if(EIGEN3_TOO_OLD)
813-
# on iCore 3/5/7 we must have Eigen >=3.2.4 to avoid fatal error in "test_matrix_multiply.pro"
814-
message(FATAL_ERROR "\nEIGEN3 is required but the version found is TOO OLD."
815-
" Please download a recent version (>=3.2.4) in a local directory."
816-
" Then use -DEIGEN3DIR=DIR to specify the Eigen3 local directory tree.\n"
817-
"Use -DEIGEN3=OFF to not use it.\n")
818-
else(EIGEN3_TOO_OLD)
819-
set(USE_EIGEN ${EIGEN3_FOUND})
820-
if(EIGEN3_FOUND)
821-
include_directories(${EIGEN3_INCLUDE_DIR})
822-
if(MINGW)
823-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-ipa-cp-clone")
824-
endif(MINGW)
825-
else(EIGEN3_FOUND)
826-
message(FATAL_ERROR "EIGEN3 is required but was not found.\n"
827-
"Use -DEIGEN3DIR=DIR to specify the Eigen3 directory tree.\n"
828-
"Use -DEIGEN3=OFF to not use it.\n"
829-
"(suitable Fedora/CentOS package: eigen3-devel)\n"
830-
"(suitable Debian/Ubuntu package: libeigen3-dev)")
831-
endif(EIGEN3_FOUND)
832-
endif(EIGEN3_TOO_OLD)
805+
find_package(Eigen3 QUIET REQUIRED NO_MODULE)
806+
# Note: Eigen3 moved to semantic versioning in 5.0.0; so WORLD.MAJOR.MINOR
807+
# becomes MAJOR.MINOR.PATCH, WORLD will forever be 3
808+
# see: https://gitlab.com/libeigen/eigen/-/releases/5.0.0
809+
810+
# we need at least version 3.2.4, => world 3, major 2, minor 4
811+
if(${Eigen3_VERSION_MAJOR} VERSION_LESS 2
812+
OR (
813+
${Eigen3_VERSION_MAJOR} VERSION_EQUAL 2 AND ${Eigen3_VERSION_MINOR} VERSION_LESS 4
814+
)
815+
)
816+
message(FATAL_ERROR
817+
"Found Eigen3 version '${Eigen3_VERSION}' when needing at least version 3.2.4.\n"
818+
"Consider installing a newer version or switch off Eigen3 by setting '-DEIGEN3=OFF'"
819+
)
820+
endif()
833821
endif(EIGEN3)
834822

835823
# grib

CMakeModules/FindEigen3.cmake

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)