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.

80 lines
3.0 KiB

  1. # - Try to find Eigen2 lib
  2. #
  3. # This module supports requiring a minimum version, e.g. you can do
  4. # find_package(Eigen2 2.0.3)
  5. # to require version 2.0.3 to newer of Eigen2.
  6. #
  7. # Once done this will define
  8. #
  9. # STORMEIGEN2_FOUND - system has eigen lib with correct version
  10. # STORMEIGEN2_INCLUDE_DIR - the eigen include directory
  11. # STORMEIGEN2_VERSION - eigen version
  12. # Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
  13. # Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
  14. # Redistribution and use is allowed according to the terms of the BSD license.
  15. if(NOT Eigen2_FIND_VERSION)
  16. if(NOT Eigen2_FIND_VERSION_MAJOR)
  17. set(Eigen2_FIND_VERSION_MAJOR 2)
  18. endif(NOT Eigen2_FIND_VERSION_MAJOR)
  19. if(NOT Eigen2_FIND_VERSION_MINOR)
  20. set(Eigen2_FIND_VERSION_MINOR 0)
  21. endif(NOT Eigen2_FIND_VERSION_MINOR)
  22. if(NOT Eigen2_FIND_VERSION_PATCH)
  23. set(Eigen2_FIND_VERSION_PATCH 0)
  24. endif(NOT Eigen2_FIND_VERSION_PATCH)
  25. set(Eigen2_FIND_VERSION "${Eigen2_FIND_VERSION_MAJOR}.${Eigen2_FIND_VERSION_MINOR}.${Eigen2_FIND_VERSION_PATCH}")
  26. endif(NOT Eigen2_FIND_VERSION)
  27. macro(_eigen2_check_version)
  28. file(READ "${STORMEIGEN2_INCLUDE_DIR}/StormEigen/src/Core/util/Macros.h" _eigen2_version_header)
  29. string(REGEX MATCH "define[ \t]+STORMEIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen2_world_version_match "${_eigen2_version_header}")
  30. set(STORMEIGEN2_WORLD_VERSION "${CMAKE_MATCH_1}")
  31. string(REGEX MATCH "define[ \t]+STORMEIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen2_major_version_match "${_eigen2_version_header}")
  32. set(STORMEIGEN2_MAJOR_VERSION "${CMAKE_MATCH_1}")
  33. string(REGEX MATCH "define[ \t]+STORMEIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen2_minor_version_match "${_eigen2_version_header}")
  34. set(STORMEIGEN2_MINOR_VERSION "${CMAKE_MATCH_1}")
  35. set(STORMEIGEN2_VERSION ${STORMEIGEN2_WORLD_VERSION}.${STORMEIGEN2_MAJOR_VERSION}.${STORMEIGEN2_MINOR_VERSION})
  36. if((${STORMEIGEN2_WORLD_VERSION} NOTEQUAL 2) OR (${STORMEIGEN2_MAJOR_VERSION} GREATER 10) OR (${STORMEIGEN2_VERSION} VERSION_LESS ${Eigen2_FIND_VERSION}))
  37. set(STORMEIGEN2_VERSION_OK FALSE)
  38. else()
  39. set(STORMEIGEN2_VERSION_OK TRUE)
  40. endif()
  41. if(NOT STORMEIGEN2_VERSION_OK)
  42. message(STATUS "Eigen2 version ${STORMEIGEN2_VERSION} found in ${STORMEIGEN2_INCLUDE_DIR}, "
  43. "but at least version ${Eigen2_FIND_VERSION} is required")
  44. endif(NOT STORMEIGEN2_VERSION_OK)
  45. endmacro(_eigen2_check_version)
  46. if (STORMEIGEN2_INCLUDE_DIR)
  47. # in cache already
  48. _eigen2_check_version()
  49. set(STORMEIGEN2_FOUND ${STORMEIGEN2_VERSION_OK})
  50. else (STORMEIGEN2_INCLUDE_DIR)
  51. find_path(STORMEIGEN2_INCLUDE_DIR NAMES StormEigen/Core
  52. PATHS
  53. ${INCLUDE_INSTALL_DIR}
  54. ${KDE4_INCLUDE_DIR}
  55. PATH_SUFFIXES eigen2
  56. )
  57. if(STORMEIGEN2_INCLUDE_DIR)
  58. _eigen2_check_version()
  59. endif(STORMEIGEN2_INCLUDE_DIR)
  60. include(FindPackageHandleStandardArgs)
  61. find_package_handle_standard_args(Eigen2 DEFAULT_MSG STORMEIGEN2_INCLUDE_DIR STORMEIGEN2_VERSION_OK)
  62. mark_as_advanced(STORMEIGEN2_INCLUDE_DIR)
  63. endif(STORMEIGEN2_INCLUDE_DIR)