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 15# Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org> 16# Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr> 17# Copyright (c) 2010 Jitse Niesen, <jitse@maths.leeds.ac.uk> 18# Redistribution and use is allowed according to the terms of the BSD license. 19 20# Set MPFR_INCLUDES 21 22find_path(MPFR_INCLUDES 23 NAMES 24 mpfr.h 25 PATHS 26 $ENV{GMPDIR} 27 ${INCLUDE_INSTALL_DIR} 28) 29 30# Set MPFR_FIND_VERSION to 1.0.0 if no minimum version is specified 31 32if(NOT MPFR_FIND_VERSION) 33 if(NOT MPFR_FIND_VERSION_MAJOR) 34 set(MPFR_FIND_VERSION_MAJOR 1) 35 endif(NOT MPFR_FIND_VERSION_MAJOR) 36 if(NOT MPFR_FIND_VERSION_MINOR) 37 set(MPFR_FIND_VERSION_MINOR 0) 38 endif(NOT MPFR_FIND_VERSION_MINOR) 39 if(NOT MPFR_FIND_VERSION_PATCH) 40 set(MPFR_FIND_VERSION_PATCH 0) 41 endif(NOT MPFR_FIND_VERSION_PATCH) 42 43 set(MPFR_FIND_VERSION "${MPFR_FIND_VERSION_MAJOR}.${MPFR_FIND_VERSION_MINOR}.${MPFR_FIND_VERSION_PATCH}") 44endif(NOT MPFR_FIND_VERSION) 45 46 47if(MPFR_INCLUDES) 48 49 # Set MPFR_VERSION 50 51 file(READ "${MPFR_INCLUDES}/mpfr.h" _mpfr_version_header) 52 53 string(REGEX MATCH "define[ \t]+MPFR_VERSION_MAJOR[ \t]+([0-9]+)" _mpfr_major_version_match "${_mpfr_version_header}") 54 set(MPFR_MAJOR_VERSION "${CMAKE_MATCH_1}") 55 string(REGEX MATCH "define[ \t]+MPFR_VERSION_MINOR[ \t]+([0-9]+)" _mpfr_minor_version_match "${_mpfr_version_header}") 56 set(MPFR_MINOR_VERSION "${CMAKE_MATCH_1}") 57 string(REGEX MATCH "define[ \t]+MPFR_VERSION_PATCHLEVEL[ \t]+([0-9]+)" _mpfr_patchlevel_version_match "${_mpfr_version_header}") 58 set(MPFR_PATCHLEVEL_VERSION "${CMAKE_MATCH_1}") 59 60 set(MPFR_VERSION ${MPFR_MAJOR_VERSION}.${MPFR_MINOR_VERSION}.${MPFR_PATCHLEVEL_VERSION}) 61 62 # Check whether found version exceeds minimum version 63 64 if(${MPFR_VERSION} VERSION_LESS ${MPFR_FIND_VERSION}) 65 set(MPFR_VERSION_OK FALSE) 66 message(STATUS "MPFR version ${MPFR_VERSION} found in ${MPFR_INCLUDES}, " 67 "but at least version ${MPFR_FIND_VERSION} is required") 68 else(${MPFR_VERSION} VERSION_LESS ${MPFR_FIND_VERSION}) 69 set(MPFR_VERSION_OK TRUE) 70 endif(${MPFR_VERSION} VERSION_LESS ${MPFR_FIND_VERSION}) 71 72endif(MPFR_INCLUDES) 73 74# Set MPFR_LIBRARIES 75 76find_library(MPFR_LIBRARIES mpfr PATHS $ENV{GMPDIR} ${LIB_INSTALL_DIR}) 77 78# Epilogue 79 80include(FindPackageHandleStandardArgs) 81find_package_handle_standard_args(MPFR DEFAULT_MSG 82 MPFR_INCLUDES MPFR_LIBRARIES MPFR_VERSION_OK) 83mark_as_advanced(MPFR_INCLUDES MPFR_LIBRARIES) 84