Skip to content
Snippets Groups Projects

Feature eigen

Merged Adrien Crovato requested to merge feature_eigen into master
3 files
+ 47
5
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 46
3
@@ -12,11 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# FindEIGEN.cmake - try to find Eigen headers
# FindEIGEN.cmake - try to find Eigen 3 headers
# The logic that checks the version comes from FindEigen3.cmake (source dir)
# ----------------------------------------------------------------------------
# output:
# EIGEN_FOUND : TRUE/FALSE
# EIGEN_INCLUDE_DIRS : where the Eigen/*.h are [cached]
# EIGEN_VERSION : version number of Eigen
# ----------------------------------------------------------------------------
# autodetection:
# utiliser "CMAKE_PREFIX_PATH=c:\local"
@@ -24,12 +26,53 @@
# ou "INCLUDE=c:\local\include"
# ----------------------------------------------------------------------------
# Check version (only for Eigen 3)
macro(_eigen3_check_version)
file(READ "${EIGEN_INCLUDE_DIRS}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)
string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
set(EIGEN_WORLD_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
set(EIGEN_MAJOR_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
set(EIGEN_MINOR_VERSION "${CMAKE_MATCH_1}")
set(EIGEN_VERSION ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})
if(${EIGEN_VERSION} VERSION_LESS ${EIGEN_FIND_VERSION})
message(FATAL_ERROR "Eigen version ${EIGEN_VERSION} found in ${EIGEN_INCLUDE_DIRS}, but at least version ${EIGEN_FIND_VERSION} is required!")
endif()
endmacro()
# Set a dummy version if not provided
if(NOT EIGEN_FIND_VERSION)
if(NOT EIGEN_FIND_VERSION_MAJOR)
set(EIGEN_FIND_VERSION_MAJOR 3)
endif()
if(NOT EIGEN_FIND_VERSION_MINOR)
set(EIGEN_FIND_VERSION_MINOR 3)
endif()
if(NOT EIGEN_FIND_VERSION_PATCH)
set(EIGEN_FIND_VERSION_PATCH 4)
endif()
set(EIGEN_FIND_VERSION "${EIGEN_FIND_VERSION_MAJOR}.${EIGEN_FIND_VERSION_MINOR}.${EIGEN_FIND_VERSION_PATCH}")
endif()
# Find the header and check the version
find_path(EIGEN_INCLUDE_DIRS "Eigen/Dense" PATHS "/usr/include/eigen3")
if (EIGEN_INCLUDE_DIRS)
_eigen3_check_version()
else()
message(FATAL_ERROR "Eigen3 headers not found! Define the path in the INCLUDE environment variable.")
endif()
# handle the QUIETLY and REQUIRED arguments and set EIGEN_FOUND to TRUE
# if all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(EIGEN DEFAULT_MSG
EIGEN_INCLUDE_DIRS)
find_package_handle_standard_args(EIGEN
FOUND_VAR EIGEN_FOUND
REQUIRED_VARS EIGEN_INCLUDE_DIRS
VERSION_VAR EIGEN_VERSION)
#MESSAGE(STATUS "EIGEN_FOUND = ${EIGEN_FOUND}")
Loading