Skip to content

Commit 74eda8a

Browse files
committed
Adds linked library compilation support for libfqfft and libff
1 parent 9e6b19f commit 74eda8a

File tree

4 files changed

+54
-21
lines changed

4 files changed

+54
-21
lines changed

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ set(
124124
"${CMAKE_CXX_FLAGS} ${OPT_FLAGS}"
125125
)
126126

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

223+
if("${USE_LINKED_LIBRARIES}")
224+
# libfqfft
225+
find_path(LIBFQFFT_INCLUDE_DIR NAMES libfqfft)
226+
set(LIBFQFFT_DIRECTORY ${LIBFQFFT_INCLUDE_DIR}/libfqfft)
227+
include_directories(${LIBFQFFT_DIRECTORY})
228+
229+
# libff
230+
find_path(LIBFF_INCLUDE_DIR NAMES libff)
231+
include_directories(${LIBFF_INCLUDE_DIR}/libff)
232+
find_library(LIBFF_LIBRARIES NAMES ff libff)
233+
endif()
234+
222235
find_program(
223236
MARKDOWN
224237

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ Create the Makefile:
272272

273273
$ mkdir build && cd build && cmake ..
274274

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

277277
$ make
278278

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

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

409+
* `cmake -DUSE_LINKED_LIBRARIES=ON`
410+
411+
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.
412+
409413
Not all combinations are tested together or supported by every part of the codebase.
410414

411415

depends/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ if("${WITH_SUPERCOP}")
3333
)
3434
endif()
3535

36-
OPTION(IS_LIBFF_PARENT OFF)
37-
add_subdirectory(libff)
36+
if(NOT "${USE_LINKED_LIBRARIES}")
37+
OPTION(IS_LIBFF_PARENT OFF)
38+
add_subdirectory(libff)
3839

39-
OPTION(IS_LIBFQFFT_PARENT OFF)
40-
add_subdirectory(libfqfft)
40+
OPTION(IS_LIBFQFFT_PARENT OFF)
41+
add_subdirectory(libfqfft)
42+
endif()

libsnark/CMakeLists.txt

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,37 @@ add_library(
4141
relations/ram_computations/rams/fooram/fooram_aux.cpp
4242
relations/ram_computations/rams/tinyram/tinyram_aux.cpp
4343
)
44-
target_link_libraries(
45-
snark
46-
47-
ff
48-
${GMP_LIBRARIES}
49-
${GMPXX_LIBRARIES}
50-
${CRYPTO_LIBRARIES}
51-
${PROCPS_LIBRARIES}
52-
${SNARK_EXTRALIBS}
53-
)
54-
target_include_directories(
55-
snark
44+
if("${USE_LINKED_LIBRARIES}")
45+
target_link_libraries(
46+
snark
47+
48+
ff
49+
${GMP_LIBRARIES}
50+
${GMPXX_LIBRARIES}
51+
${CRYPTO_LIBRARIES}
52+
${PROCPS_LIBRARIES}
53+
${LIBFF_LIBRARIES}
54+
${SNARK_EXTRALIBS}
55+
)
56+
else()
57+
target_link_libraries(
58+
snark
59+
60+
ff
61+
${GMP_LIBRARIES}
62+
${GMPXX_LIBRARIES}
63+
${CRYPTO_LIBRARIES}
64+
${PROCPS_LIBRARIES}
65+
${SNARK_EXTRALIBS}
66+
)
67+
target_include_directories(
68+
snark
5669

57-
PUBLIC
58-
${DEPENDS_DIR}/libff
59-
${DEPENDS_DIR}/libfqfft
60-
)
70+
PUBLIC
71+
${DEPENDS_DIR}/libff
72+
${DEPENDS_DIR}/libfqfft
73+
)
74+
endif()
6175

6276
install(
6377
DIRECTORY "" DESTINATION "include/libsnark"

0 commit comments

Comments
 (0)