Skip to content

Commit

Permalink
use MPIR on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
fpelliccioni committed Sep 29, 2017
1 parent 67ec623 commit e104db5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ option(ENABLE_MODULE_RECOVERY "Enable ECDSA pubkey recovery module." ON)
set(WITH_ASM "auto" CACHE STRING "Specify assembly optimizations to use (x86_64|arm|no|auto).")
set(WITH_FIELD "auto" CACHE STRING "Specify Field Implementation (64bit|32bit|auto).")
set(WITH_SCALAR "auto" CACHE STRING "Specify scalar implementation (64bit|32bit|auto).")
set(WITH_BIGNUM "auto" CACHE STRING "Specify Bignum Implementation (gmp|no|auto).")
set(WITH_BIGNUM "auto" CACHE STRING "Specify Bignum Implementation (gmp|mpir|no|auto).")

message(${WITH_BIGNUM})

Expand Down Expand Up @@ -224,6 +224,16 @@ if (${WITH_BIGNUM} STREQUAL "gmp")
target_include_directories(secp256k1 PUBLIC ${GMP_INCLUDE_DIR})
target_link_libraries(secp256k1 ${GMP_LIBRARIES})
endif()
elseif (${WITH_BIGNUM} STREQUAL "mpir")
target_compile_definitions(secp256k1 PUBLIC -DHAVE_LIBGMP=1)
target_compile_definitions(secp256k1 PUBLIC -DUSE_NUM_GMP=1)
target_compile_definitions(secp256k1 PUBLIC -DUSE_FIELD_INV_NUM=1)
target_compile_definitions(secp256k1 PUBLIC -DUSE_SCALAR_INV_NUM=1)

# if (NO_CONAN_AT_ALL)
# target_include_directories(secp256k1 PUBLIC ${GMP_INCLUDE_DIR})
# target_link_libraries(secp256k1 ${GMP_LIBRARIES})
# endif()
elseif (${WITH_BIGNUM} STREQUAL "no")
target_compile_definitions(secp256k1 PUBLIC -DUSE_NUM_NONE=1)
target_compile_definitions(secp256k1 PUBLIC -DUSE_FIELD_INV_BUILTIN=1)
Expand Down
14 changes: 12 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,16 @@ class Secp256k1Conan(ConanFile):
exports_sources = "src/*", "include/*", "CMakeLists.txt", "cmake/*", "secp256k1Config.cmake.in", "contrib/*", "test/*"

def requirements(self):
if self.settings.os == "Linux" or self.settings.os == "Macos":
# if self.settings.os == "Linux" or self.settings.os == "Macos":
# self.requires("gmp/6.1.2@bitprim/stable")


if self.settings.os == "Windows":
self.requires("mpir/3.0.0@bitprim/stable")
else:
self.requires("gmp/6.1.2@bitprim/stable")

#TODO(fernando): What happend with FreeBSD?

def build(self):
cmake = CMake(self)
Expand All @@ -100,7 +108,9 @@ def build(self):
cmake.definitions["ENABLE_MODULE_RECOVERY"] = option_on_off(self.options.enable_module_recovery)

if self.settings.os == "Windows":
cmake.definitions["WITH_BIGNUM"] = "no"
# cmake.definitions["WITH_BIGNUM"] = "no"
cmake.definitions["WITH_BIGNUM"] = "mpir"

if self.settings.compiler == "Visual Studio" and (self.settings.compiler.version != 12):
cmake.definitions["ENABLE_TESTS"] = "OFF" #Workaround. test broke MSVC
else:
Expand Down

0 comments on commit e104db5

Please sign in to comment.