# - Find Eigen Library
# Find teh native Eigen headers and Libraries
#
# EIGEN_INCLUDE_DIRS
# EIGEN_FOUND
#
# User can set the EIGEN_INSTALL environment variable to help find the installation

set(EIGEN_DEBUG 0)


if("${EIGEN_INSTALL}" STREQUAL "")
    set(EIGEN_INSTALL  $ENV{EIGEN_INSTALL})
endif()


SET(EIGEN_INCLUDE_SEARCH_DIRS
  ${EIGEN_INSTALL}/include/eigen3
)

FIND_PATH(EIGEN_INCLUDE_DIR
  NAMES Eigen/Eigen
  PATHS ${EIGEN_INCLUDE_SEARCH_DIRS} ${CMAKE_INSTALL_PREFIX}/include
  PATH_SUFFIXES eigen3 eigen
)

if(EIGEN_DEBUG)
MESSAGE(STATUS "EIGEN_INCLUDE_SEARCH_DIRS: ${EIGEN_INCLUDE_SEARCH_DIRS}")
MESSAGE(STATUS "EIGEN_INCLUDE_DIR: ${EIGEN_INCLUDE_DIR}")
endif(EIGEN_DEBUG)

# Copy the results to the output variables.
if(EIGEN_INCLUDE_DIR )
  SET(EIGEN_FOUND 1)
  SET(EIGEN_INCLUDE_DIRS ${EIGEN_INCLUDE_DIR})
ELSE(EIGEN_INCLUDE_DIR)
  SET(EIGEN_FOUND 0)
  SET(EIGEN_INCLUDE_DIRS)
ENDif(EIGEN_INCLUDE_DIR)

# Report the results.
if(NOT EIGEN_FOUND)
  SET(EIGEN_DIR_MESSAGE
    "EIGEN was not found. Make sure EIGEN_INCLUDE_DIR are set or set the EIGEN_INSTALL environment variable.")
  if(NOT EIGEN_FIND_QUIETLY)
    MESSAGE(STATUS "${EIGEN_DIR_MESSAGE}")
  ELSE(NOT EIGEN_FIND_QUIETLY)
    if(EIGEN_FIND_REQUIRED)
      MESSAGE(FATAL_ERROR "EIGEN was NOT found and is Required by this project")
    ENDif(EIGEN_FIND_REQUIRED)
  ENDif(NOT EIGEN_FIND_QUIETLY)
ENDif(NOT EIGEN_FOUND)

