Skip to content

Commit

Permalink
fix gmp setup
Browse files Browse the repository at this point in the history
  • Loading branch information
battlmonstr committed May 26, 2023
1 parent e2d8d8c commit f549125
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@

include(ExternalProject)

# GMP
# declaring it first to be used by intx, libff
if(DEFINED GMP_LIBRARY)
add_library(gmplib STATIC IMPORTED)
set_target_properties(gmplib PROPERTIES IMPORTED_LOCATION "${GMP_LIBRARY}")
if(DEFINED GMP_INCLUDE_DIR)
set_target_properties(gmplib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GMP_INCLUDE_DIR}")
else()
message(FATAL_ERROR "GMP_INCLUDE_DIR is required if a custom GMP_LIBRARY is provided")
endif()
else()
find_package(gmp REQUIRED)
add_custom_target(gmplib DEPENDS gmp::GMP)

# derive the path variables from the package for intx, libff
get_target_property(GMP_INCLUDE_DIR gmp::GMP INTERFACE_INCLUDE_DIRECTORIES)
set(GMP_INCLUDE_DIR "${GMP_INCLUDE_DIR}" CACHE PATH "")
get_target_property(GMP_LIBRARY_DIR gmp::GMP INTERFACE_LINK_DIRECTORIES)
find_library(GMP_LIBRARY gmp "${GMP_LIBRARY_DIR}")
endif()

# evmone with dependencies
add_subdirectory(intx)

Expand Down Expand Up @@ -69,18 +90,6 @@ else()
target_compile_options(evmone PRIVATE -fno-exceptions)
endif()

# GMP
if(DEFINED GMP_LIBRARY)
add_library(gmplib STATIC IMPORTED)
set_target_properties(gmplib PROPERTIES IMPORTED_LOCATION "${GMP_LIBRARY}")
if(DEFINED GMP_INCLUDE_DIR)
set_target_properties(gmplib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GMP_INCLUDE_DIR}")
endif()
else()
find_package(gmp REQUIRED)
add_custom_target(gmplib DEPENDS gmp::gmp)
endif()

# secp256k1
add_library(secp256k1 secp256k1/src/secp256k1.c)
if(MSVC)
Expand Down

0 comments on commit f549125

Please sign in to comment.