| 1 |
# - Try to find Eigen3 lib |
| 2 |
# |
| 3 |
# This module supports requiring a minimum version, e.g. you can do |
| 4 |
# find_package(Eigen3 3.1.2) |
| 5 |
# to require version 3.1.2 or newer of Eigen3. |
| 6 |
# |
| 7 |
# Once done this will define |
| 8 |
# |
| 9 |
# EIGEN3_FOUND - system has eigen lib with correct version |
| 10 |
# EIGEN3_INCLUDE_DIR - the eigen include directory |
| 11 |
# EIGEN3_VERSION - eigen version |
| 12 |
# |
| 13 |
# This module reads hints about search locations from |
| 14 |
# the following enviroment variables: |
| 15 |
# |
| 16 |
# EIGEN3_ROOT |
| 17 |
# EIGEN3_ROOT_DIR |
| 18 |
|
| 19 |
# Copyright (c) 2006, 2007 Montel Laurent, <[email protected]> |
| 20 |
# Copyright (c) 2008, 2009 Gael Guennebaud, <[email protected]> |
| 21 |
# Copyright (c) 2009 Benoit Jacob <[email protected]> |
| 22 |
# Redistribution and use is allowed according to the terms of the 2-clause BSD license. |
| 23 |
|
| 24 |
# Modified by Garth N. Wells <[email protected]> to add EIGEN_DIR to |
| 25 |
# search path |
| 26 |
|
| 27 |
if(NOT Eigen3_FIND_VERSION) |
| 28 |
if(NOT Eigen3_FIND_VERSION_MAJOR) |
| 29 |
set(Eigen3_FIND_VERSION_MAJOR 2) |
| 30 |
endif(NOT Eigen3_FIND_VERSION_MAJOR) |
| 31 |
if(NOT Eigen3_FIND_VERSION_MINOR) |
| 32 |
set(Eigen3_FIND_VERSION_MINOR 91) |
| 33 |
endif(NOT Eigen3_FIND_VERSION_MINOR) |
| 34 |
if(NOT Eigen3_FIND_VERSION_PATCH) |
| 35 |
set(Eigen3_FIND_VERSION_PATCH 0) |
| 36 |
endif(NOT Eigen3_FIND_VERSION_PATCH) |
| 37 |
|
| 38 |
set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}") |
| 39 |
endif(NOT Eigen3_FIND_VERSION) |
| 40 |
|
| 41 |
macro(_eigen3_check_version) |
| 42 |
file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header) |
| 43 |
|
| 44 |
string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}") |
| 45 |
set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}") |
| 46 |
string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}") |
| 47 |
set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}") |
| 48 |
string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}") |
| 49 |
set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}") |
| 50 |
|
| 51 |
set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION}) |
| 52 |
if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) |
| 53 |
set(EIGEN3_VERSION_OK FALSE) |
| 54 |
else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) |
| 55 |
set(EIGEN3_VERSION_OK TRUE) |
| 56 |
endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) |
| 57 |
|
| 58 |
if(NOT EIGEN3_VERSION_OK) |
| 59 |
|
| 60 |
message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, " |
| 61 |
"but at least version ${Eigen3_FIND_VERSION} is required") |
| 62 |
endif(NOT EIGEN3_VERSION_OK) |
| 63 |
endmacro(_eigen3_check_version) |
| 64 |
|
| 65 |
if (EIGEN3_INCLUDE_DIR) |
| 66 |
|
| 67 |
# in cache already |
| 68 |
_eigen3_check_version() |
| 69 |
set(EIGEN3_FOUND ${EIGEN3_VERSION_OK}) |
| 70 |
|
| 71 |
else (EIGEN3_INCLUDE_DIR) |
| 72 |
|
| 73 |
# search first if an Eigen3Config.cmake is available in the system, |
| 74 |
# if successful this would set EIGEN3_INCLUDE_DIR and the rest of |
| 75 |
# the script will work as usual |
| 76 |
find_package(Eigen3 ${Eigen3_FIND_VERSION} NO_MODULE QUIET) |
| 77 |
|
| 78 |
if(NOT EIGEN3_INCLUDE_DIR) |
| 79 |
find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library |
| 80 |
HINTS |
| 81 |
${EIGEN_DIR} |
| 82 |
ENV EIGEN_DIR |
| 83 |
ENV EIGEN3_ROOT |
| 84 |
ENV EIGEN3_ROOT_DIR |
| 85 |
PATHS |
| 86 |
${CMAKE_INSTALL_PREFIX}/include |
| 87 |
${KDE4_INCLUDE_DIR} |
| 88 |
PATH_SUFFIXES eigen3 eigen |
| 89 |
) |
| 90 |
endif(NOT EIGEN3_INCLUDE_DIR) |
| 91 |
|
| 92 |
if(EIGEN3_INCLUDE_DIR) |
| 93 |
_eigen3_check_version() |
| 94 |
endif(EIGEN3_INCLUDE_DIR) |
| 95 |
|
| 96 |
include(FindPackageHandleStandardArgs) |
| 97 |
find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK) |
| 98 |
|
| 99 |
mark_as_advanced(EIGEN3_INCLUDE_DIR) |
| 100 |
|
| 101 |
endif(EIGEN3_INCLUDE_DIR) |