snark.cmake 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. include(ExternalProject)
  2. include(GNUInstallDirs)
  3. ExternalProject_Add(snark-project
  4. PREFIX deps/snark
  5. # This points to a February version.
  6. DOWNLOAD_NAME snark.tar.gz
  7. URL https://github.com/scipr-lab/libsnark/archive/6b7e494c2407eb8e91ad78635788decb2d736596.tar.gz
  8. # URL_HASH SHA256=f1fddacadd2a0873f795d5614a85fecd5b6ff1d1c6e21dedc251703c54ce63aa
  9. # Keep source and archive in under source dir to avoid code duplication
  10. # for multiple build types and allow injecting the archive in isolated
  11. # builds (like Ubuntu PPA).
  12. DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR}/downloads
  13. SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/snark
  14. BUILD_IN_SOURCE 1
  15. CONFIGURE_COMMAND ""
  16. BUILD_COMMAND make
  17. NO_PROCPS=1 STATIC=1 NO_SUPERCOP=1 NO_GTEST=1 NO_DOCS=1 CURVE=ALT_BN128
  18. FEATUREFLAGS="-DBINARY_OUTPUT=1 -DMONTGOMERY_OUTPUT=1 -DNO_PT_COMPRESSION=1"
  19. lib PREFIX=<INSTALL_DIR> install
  20. INSTALL_COMMAND "" #make install PREFIX=<INSTALL_DIR>
  21. )
  22. # Create snark imported library
  23. ExternalProject_Get_Property(snark-project INSTALL_DIR)
  24. add_library(snark STATIC IMPORTED)
  25. if (MSVC)
  26. set(SNARK_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/src/snark/${CMAKE_STATIC_LIBRARY_PREFIX}snark-static${CMAKE_STATIC_LIBRARY_SUFFIX})
  27. else()
  28. set(SNARK_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/src/snark/${CMAKE_STATIC_LIBRARY_PREFIX}snark${CMAKE_STATIC_LIBRARY_SUFFIX})
  29. endif()
  30. set(SNARK_INCLUDE_DIR ${INSTALL_DIR}/include ${INSTALL_DIR}/include/libsnark)
  31. file(MAKE_DIRECTORY ${SNARK_INCLUDE_DIR}) # Must exist.
  32. set_property(TARGET snark PROPERTY IMPORTED_LOCATION ${SNARK_LIBRARY})
  33. set_property(TARGET snark PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${SNARK_INCLUDE_DIR})
  34. add_dependencies(snark snark-project)
  35. unset(INSTALL_DIR)