You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
3.3 KiB

  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. # STORMEIGEN3_FOUND - system has eigen lib with correct version
  10. # STORMEIGEN3_INCLUDE_DIR - the eigen include directory
  11. # STORMEIGEN3_VERSION - eigen version
  12. #
  13. # This module reads hints about search locations from
  14. # the following enviroment variables:
  15. #
  16. # STORMEIGEN3_ROOT
  17. # STORMEIGEN3_ROOT_DIR
  18. # Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
  19. # Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
  20. # Copyright (c) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
  21. # Redistribution and use is allowed according to the terms of the 2-clause BSD license.
  22. if(NOT Eigen3_FIND_VERSION)
  23. if(NOT Eigen3_FIND_VERSION_MAJOR)
  24. set(Eigen3_FIND_VERSION_MAJOR 2)
  25. endif(NOT Eigen3_FIND_VERSION_MAJOR)
  26. if(NOT Eigen3_FIND_VERSION_MINOR)
  27. set(Eigen3_FIND_VERSION_MINOR 91)
  28. endif(NOT Eigen3_FIND_VERSION_MINOR)
  29. if(NOT Eigen3_FIND_VERSION_PATCH)
  30. set(Eigen3_FIND_VERSION_PATCH 0)
  31. endif(NOT Eigen3_FIND_VERSION_PATCH)
  32. set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}")
  33. endif(NOT Eigen3_FIND_VERSION)
  34. macro(_eigen3_check_version)
  35. file(READ "${STORMEIGEN3_INCLUDE_DIR}/StormEigen/src/Core/util/Macros.h" _eigen3_version_header)
  36. string(REGEX MATCH "define[ \t]+STORMEIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
  37. set(STORMEIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}")
  38. string(REGEX MATCH "define[ \t]+STORMEIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
  39. set(STORMEIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}")
  40. string(REGEX MATCH "define[ \t]+STORMEIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
  41. set(STORMEIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}")
  42. set(STORMEIGEN3_VERSION ${STORMEIGEN3_WORLD_VERSION}.${STORMEIGEN3_MAJOR_VERSION}.${STORMEIGEN3_MINOR_VERSION})
  43. if(${STORMEIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
  44. set(STORMEIGEN3_VERSION_OK FALSE)
  45. else(${STORMEIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
  46. set(STORMEIGEN3_VERSION_OK TRUE)
  47. endif(${STORMEIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
  48. if(NOT STORMEIGEN3_VERSION_OK)
  49. message(STATUS "Eigen3 version ${STORMEIGEN3_VERSION} found in ${STORMEIGEN3_INCLUDE_DIR}, "
  50. "but at least version ${Eigen3_FIND_VERSION} is required")
  51. endif(NOT STORMEIGEN3_VERSION_OK)
  52. endmacro(_eigen3_check_version)
  53. if (STORMEIGEN3_INCLUDE_DIR)
  54. # in cache already
  55. _eigen3_check_version()
  56. set(STORMEIGEN3_FOUND ${STORMEIGEN3_VERSION_OK})
  57. else (STORMEIGEN3_INCLUDE_DIR)
  58. find_path(STORMEIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
  59. HINTS
  60. ENV STORMEIGEN3_ROOT
  61. ENV STORMEIGEN3_ROOT_DIR
  62. PATHS
  63. ${CMAKE_INSTALL_PREFIX}/include
  64. ${KDE4_INCLUDE_DIR}
  65. PATH_SUFFIXES eigen3 eigen
  66. )
  67. if(STORMEIGEN3_INCLUDE_DIR)
  68. _eigen3_check_version()
  69. endif(STORMEIGEN3_INCLUDE_DIR)
  70. include(FindPackageHandleStandardArgs)
  71. find_package_handle_standard_args(Eigen3 DEFAULT_MSG STORMEIGEN3_INCLUDE_DIR STORMEIGEN3_VERSION_OK)
  72. mark_as_advanced(STORMEIGEN3_INCLUDE_DIR)
  73. endif(STORMEIGEN3_INCLUDE_DIR)