Permalink
Browse files

Adds linked library compilation support for libfqfft and libff

  • Loading branch information...
howardwu committed Feb 26, 2018
1 parent 9e6b19f commit 74eda8ae599b4a5bcf583d23491de47f530d5195
Showing with 54 additions and 21 deletions.
  1. +13 −0 CMakeLists.txt
  2. +5 −1 README.md
  3. +6 −4 depends/CMakeLists.txt
  4. +30 −16 libsnark/CMakeLists.txt
@@ -124,6 +124,7 @@ set(
"${CMAKE_CXX_FLAGS} ${OPT_FLAGS}"
)

# GMP
find_path(GMP_INCLUDE_DIR NAMES gmp.h)
find_library(GMP_LIBRARIES NAMES gmp libgmp)
find_library(GMPXX_LIBRARIES NAMES gmpxx libgmpxx)
@@ -219,6 +220,18 @@ if("${USE_ASM}")
add_definitions(-DUSE_ASM)
endif()

if("${USE_LINKED_LIBRARIES}")
# libfqfft
find_path(LIBFQFFT_INCLUDE_DIR NAMES libfqfft)
set(LIBFQFFT_DIRECTORY ${LIBFQFFT_INCLUDE_DIR}/libfqfft)
include_directories(${LIBFQFFT_DIRECTORY})

# libff
find_path(LIBFF_INCLUDE_DIR NAMES libff)
include_directories(${LIBFF_INCLUDE_DIR}/libff)
find_library(LIBFF_LIBRARIES NAMES ff libff)
endif()

find_program(
MARKDOWN

@@ -272,7 +272,7 @@ Create the Makefile:

$ mkdir build && cd build && cmake ..

Then, to compile the library, tests, and profiling harness, run this within the `build directory:
Then, to compile the library, tests, and profiling harness, run this within the `build` directory:

$ make

@@ -406,6 +406,10 @@ to control these (you can see the default at the top of CMakeLists.txt).

Sets the dependency installation directory to the provided absolute path (default: installs dependencies in the respective submodule directories)

* `cmake -DUSE_LINKED_LIBRARIES=ON`

Setting this flag enables CMake to include installed `libfqfft` and `libff` libraries. This will tell the compiler to ignore the `libfqfft` and `libff` dependencies provided in the `depends` folder.

Not all combinations are tested together or supported by every part of the codebase.


@@ -33,8 +33,10 @@ if("${WITH_SUPERCOP}")
)
endif()

OPTION(IS_LIBFF_PARENT OFF)
add_subdirectory(libff)
if(NOT "${USE_LINKED_LIBRARIES}")
OPTION(IS_LIBFF_PARENT OFF)
add_subdirectory(libff)

OPTION(IS_LIBFQFFT_PARENT OFF)
add_subdirectory(libfqfft)
OPTION(IS_LIBFQFFT_PARENT OFF)
add_subdirectory(libfqfft)
endif()
@@ -41,23 +41,37 @@ add_library(
relations/ram_computations/rams/fooram/fooram_aux.cpp
relations/ram_computations/rams/tinyram/tinyram_aux.cpp
)
target_link_libraries(
snark

ff
${GMP_LIBRARIES}
${GMPXX_LIBRARIES}
${CRYPTO_LIBRARIES}
${PROCPS_LIBRARIES}
${SNARK_EXTRALIBS}
)
target_include_directories(
snark
if("${USE_LINKED_LIBRARIES}")
target_link_libraries(
snark

ff
${GMP_LIBRARIES}
${GMPXX_LIBRARIES}
${CRYPTO_LIBRARIES}
${PROCPS_LIBRARIES}
${LIBFF_LIBRARIES}
${SNARK_EXTRALIBS}
)
else()
target_link_libraries(
snark

ff
${GMP_LIBRARIES}
${GMPXX_LIBRARIES}
${CRYPTO_LIBRARIES}
${PROCPS_LIBRARIES}
${SNARK_EXTRALIBS}
)
target_include_directories(
snark

PUBLIC
${DEPENDS_DIR}/libff
${DEPENDS_DIR}/libfqfft
)
PUBLIC
${DEPENDS_DIR}/libff
${DEPENDS_DIR}/libfqfft
)
endif()

install(
DIRECTORY "" DESTINATION "include/libsnark"

0 comments on commit 74eda8a

Please sign in to comment.