|
| 1 | +############################################################################### |
| 2 | +# |
| 3 | +# CMake script for finding the Eigen library. |
| 4 | +# |
| 5 | +# http://eigen.tuxfamily.org/index.php?title=Main_Page |
| 6 | +# |
| 7 | +# Copyright (c) 2006, 2007 Montel Laurent, <[email protected]> |
| 8 | +# Copyright (c) 2008, 2009 Gael Guennebaud, <[email protected]> |
| 9 | +# Copyright (c) 2009 Benoit Jacob <[email protected]> |
| 10 | +# Redistribution and use is allowed according to the terms of the 2-clause BSD |
| 11 | +# license. |
| 12 | +# |
| 13 | +# |
| 14 | +# Input variables: |
| 15 | +# |
| 16 | +# - Eigen_ROOT_DIR (optional): When specified, header files and libraries |
| 17 | +# will be searched for in `${Eigen_ROOT_DIR}/include` and |
| 18 | +# `${Eigen_ROOT_DIR}/libs` respectively, and the default CMake search order |
| 19 | +# will be ignored. When unspecified, the default CMake search order is used. |
| 20 | +# This variable can be specified either as a CMake or environment variable. |
| 21 | +# If both are set, preference is given to the CMake variable. |
| 22 | +# Use this variable for finding packages installed in a nonstandard location, |
| 23 | +# or for enforcing that one of multiple package installations is picked up. |
| 24 | +# |
| 25 | +# Cache variables (not intended to be used in CMakeLists.txt files) |
| 26 | +# |
| 27 | +# - Eigen_INCLUDE_DIR: Absolute path to package headers. |
| 28 | +# |
| 29 | +# |
| 30 | +# Output variables: |
| 31 | +# |
| 32 | +# - Eigen_FOUND: Boolean that indicates if the package was found |
| 33 | +# - Eigen_INCLUDE_DIRS: Paths to the necessary header files |
| 34 | +# - Eigen_VERSION: Version of Eigen library found |
| 35 | +# - Eigen_DEFINITIONS: Definitions to be passed on behalf of eigen |
| 36 | +# |
| 37 | +# |
| 38 | +# Example usage: |
| 39 | +# |
| 40 | +# # Passing the version means Eigen_FOUND will only be TRUE if a |
| 41 | +# # version >= the provided version is found. |
| 42 | +# find_package(Eigen 3.1.2) |
| 43 | +# if(NOT Eigen_FOUND) |
| 44 | +# # Error handling |
| 45 | +# endif() |
| 46 | +# ... |
| 47 | +# add_definitions(${Eigen_DEFINITIONS}) |
| 48 | +# ... |
| 49 | +# include_directories(${Eigen_INCLUDE_DIRS} ...) |
| 50 | +# |
| 51 | +############################################################################### |
| 52 | + |
| 53 | +find_package(PkgConfig) |
| 54 | +pkg_check_modules(PC_EIGEN eigen3) |
| 55 | +set(EIGEN_DEFINITIONS ${PC_EIGEN_CFLAGS_OTHER}) |
| 56 | + |
| 57 | + |
| 58 | +find_path(EIGEN_INCLUDE_DIR Eigen/Core |
| 59 | + HINTS ${PC_EIGEN_INCLUDEDIR} ${PC_EIGEN_INCLUDE_DIRS} |
| 60 | + "${Eigen_ROOT_DIR}" "$ENV{EIGEN_ROOT_DIR}" |
| 61 | + "${EIGEN_ROOT}" "$ENV{EIGEN_ROOT}" # Backwards Compatibility |
| 62 | + PATHS "$ENV{PROGRAMFILES}/Eigen" "$ENV{PROGRAMW6432}/Eigen" |
| 63 | + "$ENV{PROGRAMFILES}/Eigen 3.0.0" "$ENV{PROGRAMW6432}/Eigen 3.0.0" |
| 64 | + PATH_SUFFIXES eigen3 include/eigen3 include) |
| 65 | + |
| 66 | +set(EIGEN_INCLUDE_DIRS ${EIGEN_INCLUDE_DIR}) |
| 67 | + |
| 68 | +include(FindPackageHandleStandardArgs) |
| 69 | +find_package_handle_standard_args(Eigen DEFAULT_MSG EIGEN_INCLUDE_DIR) |
| 70 | + |
| 71 | +mark_as_advanced(EIGEN_INCLUDE_DIR) |
| 72 | + |
| 73 | +if(EIGEN_FOUND) |
| 74 | + message(STATUS "Eigen found (include: ${EIGEN_INCLUDE_DIRS})") |
| 75 | +endif(EIGEN_FOUND) |
| 76 | + |
| 77 | + |
| 78 | +set(Eigen_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS}) |
| 79 | +set(Eigen_FOUND ${EIGEN_FOUND}) |
| 80 | +set(Eigen_VERSION ${EIGEN_VERSION}) |
| 81 | +set(Eigen_DEFINITIONS ${EIGEN_DEFINITIONS}) |
0 commit comments