Skip to content

Commit

Permalink
Replace GMP on MSVC builds with Chia's MPIR.
Browse files Browse the repository at this point in the history
  • Loading branch information
AmineKhaldi committed May 3, 2023
1 parent 45209cb commit a202742
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ if("$ENV{CFLAGS}" STREQUAL "")
endif()
else()
if (MSVC)
set(COMP_FLAGS "/O2" CACHE STRING "Default compiler flags.")
set(COMP_FLAGS "/MP /O2" CACHE STRING "Default compiler flags.")
else()
set(COMP_FLAGS "-pipe -std=c99 -O2 -funroll-loops -fomit-frame-pointer" CACHE STRING "Default compiler flags.")
endif()
Expand Down Expand Up @@ -311,7 +311,8 @@ else()
set(PFLAGS "")
endif()

if(ARITH STREQUAL "gmp" OR ARITH STREQUAL "gmp-sec")
# We'll be using our custom MPIR build instead of GMP for MSVC builds
if((ARITH STREQUAL "gmp" OR ARITH STREQUAL "gmp-sec") AND (NOT MSVC))
include(cmake/gmp.cmake)
if(GMP_FOUND)
include_directories(${GMP_INCLUDE_DIR})
Expand Down
8 changes: 7 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,13 @@ if (STLIB)
add_library(${RELIC_S} STATIC ${RELIC_SRCS} ${ARITH_OBJS})
endif()
add_dependencies(${RELIC_S} arith_objs)
target_link_libraries(${RELIC_S} ${ARITH_LIBS})
if(MSVC)
message(STATUS "Configured with MPIR (GMP fork)")
target_include_directories(${RELIC_S} PUBLIC ${MPIR_INCLUDE_DIR})
target_link_libraries(${RELIC_S} PRIVATE ${MPIR_IMPLIB})
else()
target_link_libraries(${RELIC_S} ${ARITH_LIBS})
endif()
link_libs(${RELIC_S})
install(TARGETS ${RELIC_S} ARCHIVE DESTINATION lib)
endif(STLIB)

0 comments on commit a202742

Please sign in to comment.