Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Refactor libsnark CMake config
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Mar 7, 2017
1 parent 3db341b commit 2bafb09
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ include(deps/boost.cmake)
include(deps/jsoncpp.cmake)
include(deps/jsonrpc.cmake)
include(deps/cryptopp.cmake)
include(deps/snark.cmake)
include(ProjectSnark)

configure_project(CPUID CURL EVMJIT FATDB MINIUPNPC ROCKSDB PARANOID TESTS VMTRACE)

Expand Down
28 changes: 28 additions & 0 deletions cmake/ProjectSnark.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
include(ExternalProject)

ExternalProject_Add(snark
PREFIX deps
# This points to a February 2017 version.
DOWNLOAD_NAME snark-6b7e494c.tar.gz
URL https://github.com/scipr-lab/libsnark/archive/6b7e494c2407eb8e91ad78635788decb2d736596.tar.gz
URL_HASH SHA256=c40ee69a15c8a5baf3980d3686112ccbe8511071faa1cda3875d43e693fc90e4
DOWNLOAD_NO_PROGRESS TRUE
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ""
BUILD_COMMAND CXX=${CMAKE_CXX_COMPILER} CC=${CMAKE_C_COMPILER} make
NO_PROCPS=1 STATIC=1 NO_SUPERCOP=1 NO_GTEST=1 NO_DOCS=1 CURVE=ALT_BN128
FEATUREFLAGS="-DBINARY_OUTPUT=1 -DMONTGOMERY_OUTPUT=1 -DNO_PT_COMPRESSION=1"
lib PREFIX=<INSTALL_DIR> install
INSTALL_COMMAND ""
)

# Create snark imported library
ExternalProject_Get_Property(snark INSTALL_DIR)
add_library(Snark STATIC IMPORTED)
set(SNARK_LIBRARY ${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}snark${CMAKE_STATIC_LIBRARY_SUFFIX})
file(MAKE_DIRECTORY ${INSTALL_DIR}/include/libsnark) # Must exist.
set(SNARK_INCLUDE_DIRS ${INSTALL_DIR}/include ${INSTALL_DIR}/include/libsnark)
set_property(TARGET Snark PROPERTY IMPORTED_LOCATION ${SNARK_LIBRARY})
set_property(TARGET Snark PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${SNARK_INCLUDE_DIRS})
add_dependencies(Snark snark)
unset(INSTALL_DIR)
2 changes: 1 addition & 1 deletion libdevcrypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ find_package(Utils)

target_include_directories(devcrypto PRIVATE ..)
target_include_directories(devcrypto PRIVATE ../utils)
target_link_libraries(devcrypto cryptopp snark ${Utils_SCRYPT_LIBRARIES} devcore)
target_link_libraries(devcrypto cryptopp Snark ${Utils_SCRYPT_LIBRARIES} devcore)

if (NOT EMSCRIPTEN)
target_link_libraries(devcrypto ${Utils_SECP256K1_LIBRARIES})
Expand Down

0 comments on commit 2bafb09

Please sign in to comment.