mirror of https://github.com/GOSTSec/poolserver
R4SAS
6 years ago
11 changed files with 200 additions and 71 deletions
@ -1,23 +1,102 @@ |
|||||||
# Try to find the GMP librairies |
# .. cmake_module:: |
||||||
# GMP_FOUND - system has GMP lib |
# |
||||||
# GMP_INCLUDE_DIR - the GMP include directory |
# Find the GNU MULTI-Precision Bignum (GMP) library |
||||||
# GMP_LIBRARIES - Libraries needed to use GMP |
# and the corresponding C++ bindings GMPxx |
||||||
# Copyright (c) 2006, Laurent Montel, <montel@kde.org> |
# |
||||||
|
# You may set the following variables to modify the |
||||||
|
# behaviour of this module: |
||||||
|
# |
||||||
|
# :ref:`GMP_ROOT` |
||||||
|
# Path list to search for GMP and GMPxx |
||||||
|
# |
||||||
|
# Sets the following variables: |
||||||
|
# |
||||||
|
# :code:`GMP_FOUND` |
||||||
|
# True if the GMP library, the GMPxx headers and |
||||||
|
# the GMPxx library were found. |
||||||
|
# |
||||||
|
# .. cmake_variable:: GMP_ROOT |
||||||
|
# |
||||||
|
# You may set this variable to have :ref:`FindGMP` look |
||||||
|
# for the gmp and gmpxx packages in the given path before |
||||||
|
# inspecting system paths. |
||||||
# |
# |
||||||
# Redistribution and use is allowed according to the terms of the BSD license. |
|
||||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file. |
|
||||||
|
|
||||||
if (GMP_INCLUDE_DIR AND GMP_LIBRARIES) |
|
||||||
# Already in cache, be silent |
|
||||||
set(GMP_FIND_QUIETLY TRUE) |
|
||||||
endif (GMP_INCLUDE_DIR AND GMP_LIBRARIES) |
|
||||||
|
|
||||||
find_path(GMP_INCLUDE_DIR NAMES gmp.h ) |
# search for location of header gmpxx.h", only at positions given by the user |
||||||
find_library(GMP_LIBRARIES NAMES gmp libgmp ) |
find_path(GMPXX_INCLUDE_DIR |
||||||
find_library(GMPXX_LIBRARIES NAMES gmpxx libgmpxx ) |
NAMES "gmpxx.h" |
||||||
MESSAGE(STATUS "GMP libs: " ${GMP_LIBRARIES} " " ${GMPXX_LIBRARIES} ) |
PATHS ${GMP_PREFIX} ${GMP_ROOT} |
||||||
|
PATH_SUFFIXES include |
||||||
|
NO_DEFAULT_PATH) |
||||||
|
# try default paths now |
||||||
|
find_path(GMPXX_INCLUDE_DIR |
||||||
|
NAMES "gmpxx.h") |
||||||
|
|
||||||
|
# check if header is accepted |
||||||
|
include(CMakePushCheckState) |
||||||
|
cmake_push_check_state() |
||||||
|
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${GMPXX_INCLUDE_DIR}) |
||||||
|
include(CheckIncludeFileCXX) |
||||||
|
check_include_file_cxx("gmpxx.h" GMP_HEADER_WORKS) |
||||||
|
|
||||||
|
# look for library gmp, only at positions given by the user |
||||||
|
find_library(GMP_LIB |
||||||
|
NAMES gmp libgmp |
||||||
|
PATHS ${GMP_PREFIX} ${GMP_ROOT} "/usr/lib/x86_64-linux-gnu" |
||||||
|
PATH_SUFFIXES lib lib64 |
||||||
|
NO_DEFAULT_PATH |
||||||
|
DOC "GNU GMP library") |
||||||
|
# try default paths now |
||||||
|
find_library(GMP_LIB |
||||||
|
NAMES libgmp gmp) |
||||||
|
|
||||||
|
# look for library gmpxx, only at positions given by the user |
||||||
|
find_library(GMPXX_LIB |
||||||
|
NAMES gmpxx libgmpxx |
||||||
|
PATHS ${GMP_PREFIX} ${GMP_ROOT} "/usr/lib/x86_64-linux-gnu" |
||||||
|
PATH_SUFFIXES lib lib64 |
||||||
|
NO_DEFAULT_PATH |
||||||
|
DOC "GNU GMPXX library") |
||||||
|
# try default paths now |
||||||
|
find_library(GMPXX_LIB |
||||||
|
NAMES libgmpxx gmpxx) |
||||||
|
|
||||||
|
# check if library works |
||||||
|
if(GMP_LIB AND GMPXX_LIB) |
||||||
|
include(CheckSymbolExists) |
||||||
|
check_library_exists(${GMP_LIB} __gmpz_abs "" GMPXX_LIB_WORKS) |
||||||
|
endif(GMP_LIB AND GMPXX_LIB) |
||||||
|
cmake_pop_check_state() |
||||||
|
|
||||||
|
# behave like a CMake module is supposed to behave |
||||||
include(FindPackageHandleStandardArgs) |
include(FindPackageHandleStandardArgs) |
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GMP DEFAULT_MSG GMP_INCLUDE_DIR GMP_LIBRARIES) |
find_package_handle_standard_args( |
||||||
|
"GMP" |
||||||
|
DEFAULT_MSG |
||||||
|
GMPXX_INCLUDE_DIR GMP_LIB GMPXX_LIB GMP_HEADER_WORKS GMPXX_LIB_WORKS |
||||||
|
) |
||||||
|
|
||||||
|
mark_as_advanced(GMP_LIB GMPXX_LIB GMPXX_INCLUDE_DIR) |
||||||
|
|
||||||
|
# if GMPxx headers, GMP library, and GMPxx library are found, store results |
||||||
|
if(GMP_FOUND) |
||||||
|
set(GMP_INCLUDE_DIRS ${GMPXX_INCLUDE_DIR}) |
||||||
|
set(GMP_LIBRARIES ${GMP_LIB} ${GMPXX_LIB}) |
||||||
|
set(GMP_COMPILE_FLAGS "-DENABLE_GMP=1") |
||||||
|
# log result |
||||||
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log |
||||||
|
"Determining location of GMP, GMPxx succeeded:\n" |
||||||
|
"Include directory: ${GMP_INCLUDE_DIRS}\n" |
||||||
|
"Library directory: ${GMP_LIBRARIES}\n\n") |
||||||
|
else() |
||||||
|
# log errornous result |
||||||
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log |
||||||
|
"Determining location of GMP, GMPxx failed:\n" |
||||||
|
"Include directory: ${GMPXX_INCLUDE_DIR}\n" |
||||||
|
"gmp library directory: ${GMP_LIB}\n" |
||||||
|
"gmpxx library directory: ${GMPXX_LIB}\n\n") |
||||||
|
endif() |
||||||
|
|
||||||
mark_as_advanced(GMP_INCLUDE_DIR GMP_LIBRARIES) |
# set HAVE_GMP for config.h |
||||||
|
set(HAVE_GMP ${GMP_FOUND}) |
||||||
|
Loading…
Reference in new issue