# FindEIGEN3 # -------- # # Find the Eigen3 includes (header) # # IMPORTED Targets # ^^^^^^^^^^^^^^^^ # # This module defines :prop_tgt:`IMPORTED` target ``EIGEN3::EIGEN3``, if # EIGEN3 has been found. # # Result Variables # ^^^^^^^^^^^^^^^^ # # This module defines the following variables: # # :: # # EIGEN3_INCLUDE_DIRS - where to find signature_of_eigen3_matrix_library, etc. # EIGEN3_FOUND - True if eigen3 found. # # :: # # EIGEN3_VERSION_STRING - The version of eigen3 found (x.y.z) # EIGEN3_VERSION_WORLD - The world version of eigen3 # EIGEN3_VERSION_MAJOR - The major version of eigen3 # EIGEN3_VERSION_MINOR - The minor version of eigen3 # # Hints # ^^^^^ # # A user may set ``EIGEN3_ROOT`` to a eigen3 installation root to tell this # module where to look. #============================================================================= # This file is heavily inspired by the offical CMake module FindZLIB.cmake #============================================================================= # # # manager COMET Software Group # author andreas.jansen@tu-dresden.de set(_EIGEN3_SEARCHES) # Search EIGEN3_ROOT first if it is set. if(EIGEN3_ROOT) set(_EIGEN3_SEARCH_ROOT PATHS ${EIGEN3_ROOT} NO_DEFAULT_PATH) list(APPEND _EIGEN3_SEARCHES _EIGEN3_SEARCH_ROOT) endif() # Normal search. set(_EIGEN3_SEARCH_NORMAL PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Eigen3;InstallPath]" "$ENV{PROGRAMFILES}/eigen3" ) list(APPEND _EIGEN3_SEARCHES _EIGEN3_SEARCH_NORMAL) # Try each search configuration. foreach(search ${_EIGEN3_SEARCHES}) find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library ${${search}} PATH_SUFFIXES include include/eigen3) endforeach() # get version and set corrosponding variables if(EIGEN3_INCLUDE_DIR AND EXISTS "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" ) file(STRINGS "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" EIGEN3_VERSION_H REGEX "^#define[ \t]+EIGEN_[^_]+_VERSION.*" ) string(REGEX REPLACE "^.*EIGEN_WORLD_VERSION[ \t]([0-9]+).*$" "\\1" EIGEN3_VERSION_WORLD "${EIGEN3_VERSION_H}") string(REGEX REPLACE "^.*EIGEN_MAJOR_VERSION[ \t]([0-9]+).*$" "\\1" EIGEN3_VERSION_MAJOR "${EIGEN3_VERSION_H}") string(REGEX REPLACE "^.*EIGEN_MINOR_VERSION[ \t]([0-9]+).*$" "\\1" EIGEN3_VERSION_MINOR "${EIGEN3_VERSION_H}") set(EIGEN3_VERSION_STRING "${EIGEN3_VERSION_WORLD}.${EIGEN3_VERSION_MAJOR}.${EIGEN3_VERSION_MINOR}") set(EIGEN3_WORLD_VERSION "${EIGEN3_VERSION_WORLD}") set(EIGEN3_MAJOR_VERSION "${EIGEN3_VERSION_MAJOR}") set(EIGEN3_MINOR_VERSION "${EIGEN3_VERSION_MINOR}") endif() # handle the QUIETLY and REQUIRED arguments and set EIGEN3_FOUND to TRUE if # all listed variables are TRUE include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(EIGEN3 REQUIRED_VARS EIGEN3_INCLUDE_DIR VERSION_VAR EIGEN3_VERSION_STRING) if(EIGEN3_FOUND) set(EIGEN3_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR}) if(NOT TARGET EIGEN3::EIGEN3) add_library(EIGEN3::EIGEN3 INTERFACE IMPORTED) set_target_properties(EIGEN3::EIGEN3 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${EIGEN3_INCLUDE_DIRS}") endif() endif()