Skip to content

Commit

Permalink
Link GMP dynamically in a consistent way. (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmineKhaldi authored Apr 4, 2022
1 parent 5f15cfb commit 99aa096
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ FetchContent_Declare(

# Relic related options

set(STBIN TRUE)
set(STBIN "off" CACHE STRING "Relic - Build static binaries")

find_package(gmp)
if (GMP_FOUND)
message(STATUS "Found libgmp")
Expand Down Expand Up @@ -106,8 +107,6 @@ else()
set(FP_QNRES "on" CACHE STRING "")
endif()

set(STBIN "OFF" CACHE STRING "")

set(FP_METHD "INTEG;INTEG;INTEG;MONTY;LOWER;SLIDE" CACHE STRING "")

if(MSVC)
Expand Down
13 changes: 12 additions & 1 deletion cmake_modules/Findgmp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,18 @@ if(GMP_INCLUDES)
endif()
endif()

find_library(GMP_LIBRARIES gmp PATHS $ENV{GMPDIR} ${LIB_INSTALL_DIR})
if(STBIN)
set(_gmp_lib_name libgmp.a)
else()
set(_gmp_lib_name libgmp.so)
endif()

find_library(GMP_LIBRARIES
NAMES
${_gmp_lib_name} gmp.lib libgmp-10 libgmp gmp
PATHS
$ENV{GMPDIR} ${LIB_INSTALL_DIR}
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(gmp DEFAULT_MSG
Expand Down

0 comments on commit 99aa096

Please sign in to comment.