GMP/MPIR egg hunt

This commit is contained in:
vscosta 2016-04-08 01:14:08 -07:00
parent 1649366574
commit 6b4cc7f8ff

View File

@ -9,38 +9,85 @@
# GMP_LIBRARIES_DIR - the directory the library we link with is found in. # GMP_LIBRARIES_DIR - the directory the library we link with is found in.
if(MVC) if(MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug") find_library(GMP_LIBRARIES NAMES mpir mpird
set(GMP_NAME "mpird") PATHS
else() $ENV{GMP_ROOT}
set(GMP_NAME "mpir") $ENV{GMP_ROOT}/lib
endif() ${GMP_ROOT}
else() ${GMP_ROOT}/lib
set(GMP_NAME gmp) ${CMAKE_SOURCE_DIR}/../tools/mpir/lib
endif() ${CMAKE_SOURCE_DIR}/../tools/mpird/lib
${CMAKE_SOURCE_DIR}/../mpir/lib
${CMAKE_SOURCE_DIR}/../mpird/lib
$ENV{PROGRAMFILES}/mpir/lib
$ENV{PROGRAMFILES}/mpird/lib
$ENV{HOME}/mpir/lib
$ENV{HOME}/mpird/lib
${CMAKE_INSTALL_PREFIX}/lib
DOC "Try first the MPIR DLL when in an Windows environment"
)
find_path(GMP_INCLUDE_DIRS get_filename_component(GMP_LIBRARIES_DIR "${GMP_LIBRARIES}" PATH)
NAMES ${GMP_NAME}.h
PATHS $ENV{GMP_ROOT}/include find_file(GMP_LIBRARY_DLL NAMES mpir.dll mpird.dll
$ENV{PROGRAMFILES}/mpir/include PATHS
${GMP_LIBRARIES_DIR}/../bin
${GMP_LIBRARIES_DIR}
) )
find_library(GMP_LIBRARIES NAMES ${GMP_NAME} find_path(GMP_INCLUDE_DIRS
PATHS $ENV{GMP_ROOT} $ENV{PROGRAMFILES}/mpir/lib $ENV{GMP_ROOT}/lib ${CMAKE_INSTALL_PREFIX}/lib NAMES mpir.h mpird.h
) PATHS
${GMP_LIBRARIES_DIR}/../include
${GMP_LIBRARIES_DIR}
)
find_library(GMP_LIBRARY_DLL NAMES ${GMP_NAME} else(MSVC)
PATHS "$ENV{PROGRAMFILES}/mpir/bin"
DOC "The MPIR library DLL" #use GMP, notice that there are two cases, everything is the same directory, or everything is in
#its proper places
find_library(GMP_LIBRARIES NAMES gmp
PATHS
$ENV{GMP_ROOT}
$ENV{GMP_ROOT}/lib
${GMP_ROOT}
${GMP_ROOT}/lib
/usr/local/opt/gmp/lib
/opt/lib
/usr/local/lib
$ENV{HOME}/lib
${CMAKE_INSTALL_PREFIX}/lib
) )
get_filename_component(GMP_LIBRARIES_DIR "${GMP_LIBRARIES}" PATH CACHE) get_filename_component(GMP_LIBRARIES_DIR "${GMP_LIBRARIES}" PATH CACHE)
if (WIN32)
find_library(GMP_LIBRARY_DLL NAMES gmp
PATHS
${GMP_LIBRARIES_DIR}/../bin
${GMP_LIBRARIES_DIR}
)
endif(WIN32)
find_file(GMP_INCLUDE_DIRS
NAMES gmp.h
PATHS
${GMP_LIBRARIES_DIR}/../include
${GMP_LIBRARIES_DIR}
)
endif(MSVC)
# handle the QUIET and REQUIRED arguments and set GMP_FOUND to TRUE if # handle the QUIET and REQUIRED arguments and set GMP_FOUND to TRUE if
# all listed variables are true # all listed variables are true
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
if(WIN32) if(WIN32)
find_package_handle_standard_args(GMP DEFAULT_MSG GMP_LIBRARIES GMP_LIBRARIES_DIR GMP_LIBRARY_DLL GMP_INCLUDE_DIRS) find_package_handle_standard_args(GMP DEFAULT_MSG GMP_LIBRARIES GMP_LIBRARIES_DIR GMP_LIBRARY_DLL GMP_INCLUDE_DIRS)
mark_as_advanced(GMP_LIBRARY_DLL)
else() else()
find_package_handle_standard_args(GMP DEFAULT_MSG GMP_LIBRARIES GMP_LIBRARIES_DIR GMP_INCLUDE_DIRS) find_package_handle_standard_args(GMP DEFAULT_MSG GMP_LIBRARIES GMP_LIBRARIES_DIR GMP_INCLUDE_DIRS)
endif() endif()