Skip to content

Commit

Permalink
feat: add seal for cmake project
Browse files Browse the repository at this point in the history
  • Loading branch information
dterazhao committed May 10, 2024
1 parent 99b2c9c commit 3933cd4
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 14 deletions.
31 changes: 17 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ option(ENABLE_IPCL "whether enable ipcl" OFF)
option(ENABLE_IC "whether enable ic" OFF)
add_definitions(-DMSGPACK_NO_BOOST -DUSE_CMAKE -DNO_USE_MSGPACK)

file(GLOB_RECURSE SRCS ${PROJECT_NAME}/library/*.cpp ${PROJECT_NAME}/library/*.cc ${PROJECT_NAME}/api/*.cc)
file(GLOB_RECURSE SRCS ${PROJECT_NAME}/library/*.cpp ${PROJECT_NAME}/library/*.cc ${PROJECT_NAME}/api/*.cc
${PROJECT_NAME}/algorithms/*.cpp ${PROJECT_NAME}/algorithms/*.cc
${PROJECT_NAME}/spi/*.cpp ${PROJECT_NAME}/spi/*.cc)
file(GLOB_RECURSE IPCL_SRCS ${PROJECT_NAME}/library/algorithms/paillier_ipcl/*.cc)
file(GLOB_RECURSE GPU_SRCS ${PROJECT_NAME}/library/algorithms/paillier_gpu/*.cc
${PROJECT_NAME}/library/algorithms/paillier_gpu/gpulib/*.cu)
file(GLOB_RECURSE PAILLIER_IC_SRCS ${PROJECT_NAME}/library/algorithms/paillier_ic/*.cc)
file(GLOB_RECURSE NP_SRCS ${PROJECT_NAME}/library/numpy/*.cc)
file(GLOB_RECURSE TEST_SRCS ${PROJECT_NAME}/library/*_test*.cc)
file(GLOB_RECURSE TEST_SRCS ${PROJECT_NAME}/library/*_test*.cc
${PROJECT_NAME}/spi/*_test*.cc ${PROJECT_NAME}/spi/test_*.cc)
file(GLOB_RECURSE BENCH_SRCS ${PROJECT_NAME}/library/*_bench.cc)
list(REMOVE_ITEM SRCS ${TEST_SRCS} ${BENCH_SRCS} ${NP_SRCS})
list(REMOVE_ITEM GPU_SRCS ${TEST_SRCS} ${BENCH_SRCS} ${NP_SRCS})
Expand Down Expand Up @@ -78,6 +81,17 @@ endif ()
include_directories(. include third_party/yacl third_party third_party/include)
link_directories(third_party/lib)

# Building tests
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.1
)
FetchContent_MakeAvailable(googletest)
add_library(GTest::GTest INTERFACE IMPORTED)
target_link_libraries(GTest::GTest INTERFACE GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main)

set(ABSL_LIB absl_int128 absl_strings absl_symbolize absl_stacktrace absl_throw_delegate)
set(GPU_LIB)
if (ENABLE_GPU)
Expand All @@ -89,20 +103,9 @@ endif ()
add_library(${PROJECT_NAME} SHARED ${SRCS})
#target_sources(${PROJECT_NAME} PRIVATE)
target_link_libraries(${PROJECT_NAME} yacl ${ABSL_LIB} ${GPU_LIB} # protobuf::libprotobuf protobuf::libprotobuf-lite
tommath fmt blake3 sodium curve25519 gmp)
tommath fmt blake3 sodium curve25519 gmp GTest::gtest GTest::gmock)
set(EXE_TARGETS)

# Building tests
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.1
)
FetchContent_MakeAvailable(googletest)
add_library(GTest::GTest INTERFACE IMPORTED)
target_link_libraries(GTest::GTest INTERFACE GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main)

# Building bench
foreach (bench_file ${BENCH_SRCS})
string(REPLACE ".cc" "" bench_name ${bench_file})
Expand Down
16 changes: 16 additions & 0 deletions third_party/build_seal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

CD=$(cd "$(dirname "$0")" || exit && pwd)
cd "$CD" || exit
. "$CD"/versions.sh

# build seal
# [ -d benchmark ] || git clone https://github.com/microsoft/SEAL.git
# shellcheck disable=SC2154
pkg=seal-"$seal_ver"
download_url=https://github.com/microsoft/SEAL/archive/refs/tags/v"$seal_ver".tar.gz
sh "$CD"/build_template.sh --pkg "$pkg" -u "$download_url" -o \
"-DSEAL_USE_MSGSL=OFF -DSEAL_BUILD_DEPS=OFF -DSEAL_USE_ZSTD=OFF -DSEAL_USE_ZLIB=OFF -DSEAL_THROW_ON_TRANSPARENT_CIPHERTEXT=OFF"

m_ver=${seal_ver%.*}
rm -rf "$CD"/include/seal && mv "$CD"/include/SEAL-$m_ver/seal "$CD"/include/ && rm -rf "$CD"/include/SEAL-$m_ver
Binary file added third_party/src/seal-4.1.1.tar.gz
Binary file not shown.
2 changes: 2 additions & 0 deletions third_party/versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ cd "$CD" || exit
# shellcheck disable=SC2034
gmp_ver=6.3.0
# shellcheck disable=SC2034
seal_ver=4.1.1
# shellcheck disable=SC2034
cgbn_ver=e8b9d265c7b84077d02340b0986f3c91b2eb02fb

0 comments on commit 3933cd4

Please sign in to comment.