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.

83 lines
2.8 KiB

  1. # Try to find the MPFR library
  2. # See http://www.mpfr.org/
  3. #
  4. # This module supports requiring a minimum version, e.g. you can do
  5. # find_package(MPFR 2.3.0)
  6. # to require version 2.3.0 to newer of MPFR.
  7. #
  8. # Once done this will define
  9. #
  10. # MPFR_FOUND - system has MPFR lib with correct version
  11. # MPFR_INCLUDES - the MPFR include directory
  12. # MPFR_LIBRARIES - the MPFR library
  13. # MPFR_VERSION - MPFR version
  14. # Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
  15. # Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
  16. # Copyright (c) 2010 Jitse Niesen, <jitse@maths.leeds.ac.uk>
  17. # Redistribution and use is allowed according to the terms of the BSD license.
  18. # Set MPFR_INCLUDES
  19. find_path(MPFR_INCLUDES
  20. NAMES
  21. mpfr.h
  22. PATHS
  23. $ENV{GMPDIR}
  24. ${INCLUDE_INSTALL_DIR}
  25. )
  26. # Set MPFR_FIND_VERSION to 1.0.0 if no minimum version is specified
  27. if(NOT MPFR_FIND_VERSION)
  28. if(NOT MPFR_FIND_VERSION_MAJOR)
  29. set(MPFR_FIND_VERSION_MAJOR 1)
  30. endif(NOT MPFR_FIND_VERSION_MAJOR)
  31. if(NOT MPFR_FIND_VERSION_MINOR)
  32. set(MPFR_FIND_VERSION_MINOR 0)
  33. endif(NOT MPFR_FIND_VERSION_MINOR)
  34. if(NOT MPFR_FIND_VERSION_PATCH)
  35. set(MPFR_FIND_VERSION_PATCH 0)
  36. endif(NOT MPFR_FIND_VERSION_PATCH)
  37. set(MPFR_FIND_VERSION "${MPFR_FIND_VERSION_MAJOR}.${MPFR_FIND_VERSION_MINOR}.${MPFR_FIND_VERSION_PATCH}")
  38. endif(NOT MPFR_FIND_VERSION)
  39. if(MPFR_INCLUDES)
  40. # Set MPFR_VERSION
  41. file(READ "${MPFR_INCLUDES}/mpfr.h" _mpfr_version_header)
  42. string(REGEX MATCH "define[ \t]+MPFR_VERSION_MAJOR[ \t]+([0-9]+)" _mpfr_major_version_match "${_mpfr_version_header}")
  43. set(MPFR_MAJOR_VERSION "${CMAKE_MATCH_1}")
  44. string(REGEX MATCH "define[ \t]+MPFR_VERSION_MINOR[ \t]+([0-9]+)" _mpfr_minor_version_match "${_mpfr_version_header}")
  45. set(MPFR_MINOR_VERSION "${CMAKE_MATCH_1}")
  46. string(REGEX MATCH "define[ \t]+MPFR_VERSION_PATCHLEVEL[ \t]+([0-9]+)" _mpfr_patchlevel_version_match "${_mpfr_version_header}")
  47. set(MPFR_PATCHLEVEL_VERSION "${CMAKE_MATCH_1}")
  48. set(MPFR_VERSION ${MPFR_MAJOR_VERSION}.${MPFR_MINOR_VERSION}.${MPFR_PATCHLEVEL_VERSION})
  49. # Check whether found version exceeds minimum version
  50. if(${MPFR_VERSION} VERSION_LESS ${MPFR_FIND_VERSION})
  51. set(MPFR_VERSION_OK FALSE)
  52. message(STATUS "MPFR version ${MPFR_VERSION} found in ${MPFR_INCLUDES}, "
  53. "but at least version ${MPFR_FIND_VERSION} is required")
  54. else(${MPFR_VERSION} VERSION_LESS ${MPFR_FIND_VERSION})
  55. set(MPFR_VERSION_OK TRUE)
  56. endif(${MPFR_VERSION} VERSION_LESS ${MPFR_FIND_VERSION})
  57. endif(MPFR_INCLUDES)
  58. # Set MPFR_LIBRARIES
  59. find_library(MPFR_LIBRARIES mpfr PATHS $ENV{GMPDIR} ${LIB_INSTALL_DIR})
  60. # Epilogue
  61. include(FindPackageHandleStandardArgs)
  62. find_package_handle_standard_args(MPFR DEFAULT_MSG
  63. MPFR_INCLUDES MPFR_LIBRARIES MPFR_VERSION_OK)
  64. mark_as_advanced(MPFR_INCLUDES MPFR_LIBRARIES)