Skip to content

Commit

Permalink
Updates to cmake to work around missing statics (Chia-Network#231)
Browse files Browse the repository at this point in the history
* Updates to cmake to work around missing statics

* Add in 32bit check
  • Loading branch information
emlowe authored Jun 29, 2021
1 parent 2641929 commit f95d7c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.14.0 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 99)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

IF(NOT CMAKE_BUILD_TYPE)
Expand Down Expand Up @@ -45,13 +48,17 @@ else()
set(ARITH "easy" CACHE STRING "")
endif()

if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(WSIZE 32 CACHE INTEGER "")
else()
set(WSIZE 64 CACHE INTEGER "")
endif()

if(EMSCRIPTEN)
# emscripten needs arch set to be none since it can't compile assembly
set(ARCH "" CACHE STRING "")
# emscripten is a 32 bit compiler
set(WSIZE 32 CACHE INTEGER "")
else()
set(WSIZE 64 CACHE INTEGER "")
endif()

set(TIMER "CYCLE" CACHE STRING "")
Expand Down
9 changes: 5 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,19 @@ add_library(blstmp ${HEADERS}
)

set(OPREFIX object_)
find_library(GMP_NAME NAMES libgmp.a gmp)
find_library(SODIUM_NAME NAMES libsodium.a sodium)
find_library(GMP_NAME NAMES libgmp.a)
find_library(SODIUM_NAME NAMES libsodium.a)

set(LIBRARIES_TO_COMBINE
COMMAND mkdir ${OPREFIX}$<TARGET_NAME:blstmp> || true && cd ${OPREFIX}$<TARGET_NAME:blstmp> && ${CMAKE_AR} -x $<TARGET_FILE:blstmp>
COMMAND mkdir ${OPREFIX}$<TARGET_NAME:relic_s> || true && cd ${OPREFIX}$<TARGET_NAME:relic_s> && ${CMAKE_AR} -x $<TARGET_FILE:relic_s>
)

if (GMP_FOUND)
if (NOT ${GMP_NAME} STREQUAL "GMP_NAME-NOTFOUND")
list(APPEND LIBRARIES_TO_COMBINE COMMAND mkdir ${OPREFIX}gmp || true && cd ${OPREFIX}gmp && ${CMAKE_AR} -x ${GMP_NAME})
endif()
if (SODIUM_FOUND)

if (NOT ${SODIUM_NAME} STREQUAL "SODIUM_NAME-NOTFOUND")
message("SODIUM_FOUND in src/CMakeLists.txt")
list(APPEND LIBRARIES_TO_COMBINE COMMAND mkdir ${OPREFIX}sodium || true && cd ${OPREFIX}sodium && ${CMAKE_AR} -x ${SODIUM_NAME})
target_compile_definitions(blstmp PRIVATE BLSALLOC_SODIUM=1)
Expand Down

0 comments on commit f95d7c6

Please sign in to comment.