diff --git a/.travis.yml b/.travis.yml index 73d8fdf98..c8c4b3d0a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,7 +46,7 @@ install: - sudo add-apt-repository --yes ppa:h-rayflood/llvm - sudo apt-get -qq update - if [[ $USE_TCMALLOC == TRUE ]]; then sudo add-apt-repository --yes ppa:agent-8131/ppa && sudo apt-get -qq update && sudo apt-get -qq install libgoogle-perftools-dev; fi - - sudo apt-get -qq install libgmp-dev + - sudo apt-get -qq install libgmp-dev libmpfr-dev - sudo apt-get -qq install cmake - sudo apt-get -qq install flex bison++ - sudo apt-get -qq install libstdc++-4.8-dev diff --git a/README.md b/README.md index a60958575..6132464c5 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ Requirements - C++11 compatible compiler - GMP (GNU multiprecision library) http://gmplib.org/ +- MPFR (GNU MPFR Library) + http://www.mpfr.org/ - (optional) gperftools https://code.google.com/p/gperftools/ - cmake diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 45c38844a..5217ee9ae 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,6 +6,9 @@ set(LEAN_VERSION_MINOR 1) set(CMAKE_COLOR_MAKEFILE ON) enable_testing() +# Set Module Path +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") + # Initialize CXXFLAGS. set(CMAKE_CXX_FLAGS "-Wall -std=c++11") set(CMAKE_CXX_FLAGS_DEBUG "-g -DLEAN_DEBUG -DLEAN_TRACE") @@ -27,17 +30,18 @@ else () endif () # GMP -include(cmake/FindGMP.cmake) set(EXTRA_LIBS ${EXTRA_LIBS} ${GMP_LIBRARIES}) +# MPFR +find_package(MPFR 2.3.0) +set(EXTRA_LIBS ${EXTRA_LIBS} ${MPFR_LIBRARIES}) + # Flex and Bison -include(cmake/FindBISONPP.cmake) find_package(FLEX REQUIRED) # tcmalloc option(tcmalloc "tcmalloc" ON) if("${tcmalloc}" MATCHES "ON") - include(cmake/FindTcmalloc.cmake) if(${TCMALLOC_FOUND}) set(EXTRA_LIBS ${EXTRA_LIBS} ${TCMALLOC_LIBRARIES}) endif() diff --git a/src/cmake/CheckTcmalloc.cc b/src/cmake/Modules/CheckTcmalloc.cc similarity index 100% rename from src/cmake/CheckTcmalloc.cc rename to src/cmake/Modules/CheckTcmalloc.cc diff --git a/src/cmake/FindBISONPP.cmake b/src/cmake/Modules/FindBISONPP.cmake similarity index 100% rename from src/cmake/FindBISONPP.cmake rename to src/cmake/Modules/FindBISONPP.cmake diff --git a/src/cmake/FindGMP.cmake b/src/cmake/Modules/FindGMP.cmake similarity index 100% rename from src/cmake/FindGMP.cmake rename to src/cmake/Modules/FindGMP.cmake diff --git a/src/cmake/Modules/FindMPFR.cmake b/src/cmake/Modules/FindMPFR.cmake new file mode 100644 index 000000000..15667405f --- /dev/null +++ b/src/cmake/Modules/FindMPFR.cmake @@ -0,0 +1,83 @@ +# Try to find the MPFR library +# See http://www.mpfr.org/ +# +# This module supports requiring a minimum version, e.g. you can do +# find_package(MPFR 2.3.0) +# to require version 2.3.0 to newer of MPFR. +# +# Once done this will define +# +# MPFR_FOUND - system has MPFR lib with correct version +# MPFR_INCLUDES - the MPFR include directory +# MPFR_LIBRARIES - the MPFR library +# MPFR_VERSION - MPFR version + +# Copyright (c) 2006, 2007 Montel Laurent, +# Copyright (c) 2008, 2009 Gael Guennebaud, +# Copyright (c) 2010 Jitse Niesen, +# Redistribution and use is allowed according to the terms of the BSD license. + +# Set MPFR_INCLUDES + +find_path(MPFR_INCLUDES + NAMES + mpfr.h + PATHS + $ENV{GMPDIR} + ${INCLUDE_INSTALL_DIR} +) + +# Set MPFR_FIND_VERSION to 1.0.0 if no minimum version is specified + +if(NOT MPFR_FIND_VERSION) + if(NOT MPFR_FIND_VERSION_MAJOR) + set(MPFR_FIND_VERSION_MAJOR 1) + endif(NOT MPFR_FIND_VERSION_MAJOR) + if(NOT MPFR_FIND_VERSION_MINOR) + set(MPFR_FIND_VERSION_MINOR 0) + endif(NOT MPFR_FIND_VERSION_MINOR) + if(NOT MPFR_FIND_VERSION_PATCH) + set(MPFR_FIND_VERSION_PATCH 0) + endif(NOT MPFR_FIND_VERSION_PATCH) + + set(MPFR_FIND_VERSION "${MPFR_FIND_VERSION_MAJOR}.${MPFR_FIND_VERSION_MINOR}.${MPFR_FIND_VERSION_PATCH}") +endif(NOT MPFR_FIND_VERSION) + + +if(MPFR_INCLUDES) + + # Set MPFR_VERSION + + file(READ "${MPFR_INCLUDES}/mpfr.h" _mpfr_version_header) + + string(REGEX MATCH "define[ \t]+MPFR_VERSION_MAJOR[ \t]+([0-9]+)" _mpfr_major_version_match "${_mpfr_version_header}") + set(MPFR_MAJOR_VERSION "${CMAKE_MATCH_1}") + string(REGEX MATCH "define[ \t]+MPFR_VERSION_MINOR[ \t]+([0-9]+)" _mpfr_minor_version_match "${_mpfr_version_header}") + set(MPFR_MINOR_VERSION "${CMAKE_MATCH_1}") + string(REGEX MATCH "define[ \t]+MPFR_VERSION_PATCHLEVEL[ \t]+([0-9]+)" _mpfr_patchlevel_version_match "${_mpfr_version_header}") + set(MPFR_PATCHLEVEL_VERSION "${CMAKE_MATCH_1}") + + set(MPFR_VERSION ${MPFR_MAJOR_VERSION}.${MPFR_MINOR_VERSION}.${MPFR_PATCHLEVEL_VERSION}) + + # Check whether found version exceeds minimum version + + if(${MPFR_VERSION} VERSION_LESS ${MPFR_FIND_VERSION}) + set(MPFR_VERSION_OK FALSE) + message(STATUS "MPFR version ${MPFR_VERSION} found in ${MPFR_INCLUDES}, " + "but at least version ${MPFR_FIND_VERSION} is required") + else(${MPFR_VERSION} VERSION_LESS ${MPFR_FIND_VERSION}) + set(MPFR_VERSION_OK TRUE) + endif(${MPFR_VERSION} VERSION_LESS ${MPFR_FIND_VERSION}) + +endif(MPFR_INCLUDES) + +# Set MPFR_LIBRARIES + +find_library(MPFR_LIBRARIES mpfr PATHS $ENV{GMPDIR} ${LIB_INSTALL_DIR}) + +# Epilogue + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(MPFR DEFAULT_MSG + MPFR_INCLUDES MPFR_LIBRARIES MPFR_VERSION_OK) +mark_as_advanced(MPFR_INCLUDES MPFR_LIBRARIES) \ No newline at end of file diff --git a/src/cmake/FindTcmalloc.cmake b/src/cmake/Modules/FindTcmalloc.cmake similarity index 100% rename from src/cmake/FindTcmalloc.cmake rename to src/cmake/Modules/FindTcmalloc.cmake